sqltool_test.go 623 B

12345678910111213141516171819202122232425262728293031323334
  1. package datacenter
  2. import "testing"
  3. func TestSelect(t *testing.T) {
  4. var q = &Query{}
  5. q.Select("a,b b2,c as c2")
  6. t.Logf("query=%s", q)
  7. q = &Query{}
  8. q.Select(" * ")
  9. t.Logf("query=%s", q)
  10. }
  11. func TestWhere(t *testing.T) {
  12. var q = &Query{}
  13. q.Select("a,b,c as yeah").Where(
  14. ConditionMapType{
  15. "field1": ConditionIn(1, 2, 3, 4),
  16. "field3": ConditionIn("OK"),
  17. },
  18. ConditionMapType{
  19. "field2": ConditionGt(100),
  20. },
  21. ConditionMapType{
  22. "field1": ConditionGte(100),
  23. })
  24. t.Logf("query=%s", q)
  25. }
  26. func TestSort(t *testing.T) {
  27. var q = &Query{}
  28. q.Order("field1 desc, field2")
  29. t.Logf("query=%s", q)
  30. }