jet/string_expression_test.go

83 lines
3.7 KiB
Go
Raw Normal View History

2019-06-21 13:56:57 +02:00
package jet
2019-05-29 14:03:38 +02:00
import (
"testing"
)
2019-06-01 18:04:56 +02:00
func TestStringEQ(t *testing.T) {
exp := table3StrCol.EQ(table2ColStr)
2019-07-30 11:18:12 +02:00
assertPostgreClauseSerialize(t, exp, "(table3.col2 = table2.col_str)")
2019-06-01 18:04:56 +02:00
exp = table3StrCol.EQ(String("JOHN"))
2019-07-30 11:18:12 +02:00
assertPostgreClauseSerialize(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-07-30 11:18:12 +02:00
assertPostgreClauseSerialize(t, exp, "(table3.col2 != table2.col_str)")
assertPostgreClauseSerialize(t, table3StrCol.NOT_EQ(String("JOHN")), "(table3.col2 != $1)", "JOHN")
2019-05-29 14:03:38 +02:00
}
2019-07-19 17:19:58 +02:00
func TestStringExpressionIS_DISTINCT_FROM(t *testing.T) {
2019-07-30 11:18:12 +02:00
assertPostgreClauseSerialize(t, table3StrCol.IS_DISTINCT_FROM(table2ColStr), "(table3.col2 IS DISTINCT FROM table2.col_str)")
assertPostgreClauseSerialize(t, table3StrCol.IS_DISTINCT_FROM(String("JOHN")), "(table3.col2 IS DISTINCT FROM $1)", "JOHN")
2019-07-19 17:19:58 +02:00
}
func TestStringExpressionIS_NOT_DISTINCT_FROM(t *testing.T) {
2019-07-30 11:18:12 +02:00
assertPostgreClauseSerialize(t, table3StrCol.IS_NOT_DISTINCT_FROM(table2ColStr), "(table3.col2 IS NOT DISTINCT FROM table2.col_str)")
assertPostgreClauseSerialize(t, table3StrCol.IS_NOT_DISTINCT_FROM(String("JOHN")), "(table3.col2 IS NOT DISTINCT FROM $1)", "JOHN")
2019-07-19 17:19:58 +02:00
}
2019-05-29 14:03:38 +02:00
func TestStringGT(t *testing.T) {
exp := table3StrCol.GT(table2ColStr)
2019-07-30 11:18:12 +02:00
assertPostgreClauseSerialize(t, exp, "(table3.col2 > table2.col_str)")
assertPostgreClauseSerialize(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-07-30 11:18:12 +02:00
assertPostgreClauseSerialize(t, exp, "(table3.col2 >= table2.col_str)")
assertPostgreClauseSerialize(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-07-30 11:18:12 +02:00
assertPostgreClauseSerialize(t, exp, "(table3.col2 < table2.col_str)")
assertPostgreClauseSerialize(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-07-30 11:18:12 +02:00
assertPostgreClauseSerialize(t, exp, "(table3.col2 <= table2.col_str)")
assertPostgreClauseSerialize(t, table3StrCol.LT_EQ(String("JOHN")), "(table3.col2 <= $1)", "JOHN")
2019-05-29 14:03:38 +02:00
}
func TestStringCONCAT(t *testing.T) {
2019-07-30 11:18:12 +02:00
assertPostgreClauseSerialize(t, table3StrCol.CONCAT(table2ColStr), "(table3.col2 || table2.col_str)")
assertPostgreClauseSerialize(t, table3StrCol.CONCAT(String("JOHN")), "(table3.col2 || $1)", "JOHN")
}
func TestStringLIKE(t *testing.T) {
2019-07-30 11:18:12 +02:00
assertPostgreClauseSerialize(t, table3StrCol.LIKE(table2ColStr), "(table3.col2 LIKE table2.col_str)")
assertPostgreClauseSerialize(t, table3StrCol.LIKE(String("JOHN")), "(table3.col2 LIKE $1)", "JOHN")
}
func TestStringNOT_LIKE(t *testing.T) {
2019-07-30 11:18:12 +02:00
assertPostgreClauseSerialize(t, table3StrCol.NOT_LIKE(table2ColStr), "(table3.col2 NOT LIKE table2.col_str)")
assertPostgreClauseSerialize(t, table3StrCol.NOT_LIKE(String("JOHN")), "(table3.col2 NOT LIKE $1)", "JOHN")
}
func TestStringSIMILAR_TO(t *testing.T) {
2019-07-30 11:18:12 +02:00
assertPostgreClauseSerialize(t, table3StrCol.SIMILAR_TO(table2ColStr), "(table3.col2 SIMILAR TO table2.col_str)")
assertPostgreClauseSerialize(t, table3StrCol.SIMILAR_TO(String("JOHN")), "(table3.col2 SIMILAR TO $1)", "JOHN")
}
func TestStringNOT_SIMILAR_TO(t *testing.T) {
2019-07-30 11:18:12 +02:00
assertPostgreClauseSerialize(t, table3StrCol.NOT_SIMILAR_TO(table2ColStr), "(table3.col2 NOT SIMILAR TO table2.col_str)")
assertPostgreClauseSerialize(t, table3StrCol.NOT_SIMILAR_TO(String("JOHN")), "(table3.col2 NOT SIMILAR TO $1)", "JOHN")
}
2019-06-07 14:23:14 +02:00
func TestStringExp(t *testing.T) {
2019-07-30 11:18:12 +02:00
assertPostgreClauseSerialize(t, StringExp(table2ColFloat), "table2.col_float")
assertPostgreClauseSerialize(t, StringExp(table2ColFloat).NOT_LIKE(String("abc")), "(table2.col_float NOT LIKE $1)", "abc")
2019-06-07 14:23:14 +02:00
}