jet/sqlbuilder/string_expression_test.go

48 lines
1.7 KiB
Go
Raw Normal View History

2019-05-29 14:03:38 +02:00
package sqlbuilder
import (
"testing"
)
2019-06-01 18:04:56 +02:00
func TestStringEQ(t *testing.T) {
exp := table3StrCol.EQ(table2ColStr)
2019-06-01 18:04:56 +02:00
assertExpressionSerialize(t, exp, "(table3.col2 = table2.colStr)")
exp = table3StrCol.EQ(String("JOHN"))
assertExpressionSerialize(t, exp, "(table3.col2 = $1)", "JOHN")
2019-05-29 14:03:38 +02:00
}
func TestStringNOT_EQ(t *testing.T) {
exp := table3StrCol.NOT_EQ(table2ColStr)
2019-06-01 18:04:56 +02:00
assertExpressionSerialize(t, exp, "(table3.col2 != table2.colStr)")
assertExpressionSerialize(t, table3StrCol.NOT_EQ(String("JOHN")), "(table3.col2 != $1)", "JOHN")
2019-05-29 14:03:38 +02:00
}
func TestStringGT(t *testing.T) {
exp := table3StrCol.GT(table2ColStr)
2019-06-01 18:04:56 +02:00
assertExpressionSerialize(t, exp, "(table3.col2 > table2.colStr)")
assertExpressionSerialize(t, table3StrCol.GT(String("JOHN")), "(table3.col2 > $1)", "JOHN")
2019-05-29 14:03:38 +02:00
}
func TestStringGT_EQ(t *testing.T) {
exp := table3StrCol.GT_EQ(table2ColStr)
2019-06-01 18:04:56 +02:00
assertExpressionSerialize(t, exp, "(table3.col2 >= table2.colStr)")
assertExpressionSerialize(t, table3StrCol.GT_EQ(String("JOHN")), "(table3.col2 >= $1)", "JOHN")
2019-05-29 14:03:38 +02:00
}
func TestStringLT(t *testing.T) {
exp := table3StrCol.LT(table2ColStr)
2019-06-01 18:04:56 +02:00
assertExpressionSerialize(t, exp, "(table3.col2 < table2.colStr)")
assertExpressionSerialize(t, table3StrCol.LT(String("JOHN")), "(table3.col2 < $1)", "JOHN")
2019-05-29 14:03:38 +02:00
}
func TestStringLT_EQ(t *testing.T) {
exp := table3StrCol.LT_EQ(table2ColStr)
2019-06-01 18:04:56 +02:00
assertExpressionSerialize(t, exp, "(table3.col2 <= table2.colStr)")
assertExpressionSerialize(t, table3StrCol.LT_EQ(String("JOHN")), "(table3.col2 <= $1)", "JOHN")
2019-05-29 14:03:38 +02:00
}
func TestStringCONCAT(t *testing.T) {
assertExpressionSerialize(t, table3StrCol.CONCAT(table2ColStr), "(table3.col2 || table2.colStr)")
assertExpressionSerialize(t, table3StrCol.CONCAT(String("JOHN")), "(table3.col2 || $1)", "JOHN")
}