You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
584 B

2 years ago
  1. package vql
  2. import (
  3. "encoding/json"
  4. "log"
  5. "testing"
  6. )
  7. func Test_toOrderSql(t *testing.T) {
  8. text := `{
  9. "as": "test",
  10. "select": [
  11. "col1",
  12. "col2"
  13. ],
  14. "from": {
  15. "as": "test",
  16. "select": [
  17. "col1",
  18. "col2"
  19. ],
  20. "from": "table1"
  21. },
  22. "join": "left join table2 on table1.id = table2.id",
  23. "where": {
  24. "col1": "value1",
  25. "col2": "value2",
  26. "col3": 12
  27. }
  28. }`
  29. var builder Builder2
  30. err := json.Unmarshal([]byte(text), &builder)
  31. if err != nil {
  32. t.Error(err)
  33. }
  34. sql, err := builder.Sql()
  35. if err != nil {
  36. t.Error(err)
  37. }
  38. log.Println(sql)
  39. }