diff --git a/ascii.go b/ascii.go index f18d153..1c32964 100644 --- a/ascii.go +++ b/ascii.go @@ -31,6 +31,10 @@ func (c *STableField) IsSearchable() bool { return c.spec.IsSearchable() } +func (c *STableField) GetWidth() int { + return c.spec.GetWidth() +} + func getTableField(f IQueryField) *STableField { if gotypes.IsNil(f) { return nil @@ -47,10 +51,10 @@ func getTableField(f IQueryField) *STableField { } } -func IsFieldText(f IQueryField) bool { +func IsLongFieldText(f IQueryField) bool { tf := getTableField(f) if tf != nil { - return tf.IsText() && tf.IsSearchable() + return tf.IsText() && tf.IsSearchable() && tf.GetWidth() == 0 } return false } diff --git a/backends/dameng/conditions.go b/backends/dameng/conditions.go index 5ffc0e9..482ca18 100644 --- a/backends/dameng/conditions.go +++ b/backends/dameng/conditions.go @@ -32,7 +32,7 @@ func (t *SDamengEqualsCondition) WhereClause() string { // Equals filter conditions func (dameng *SDamengBackend) Equals(f sqlchemy.IQueryField, v interface{}) sqlchemy.ICondition { // log.Debugf("field %s isFieldText: %v %#v", f.Name(), sqlchemy.IsFieldText(f), f) - if sqlchemy.IsFieldText(f) { + if sqlchemy.IsLongFieldText(f) { c := SDamengEqualsCondition{sqlchemy.NewTupleCondition(f, v)} return &c } else { diff --git a/backends/dameng/query_test.go b/backends/dameng/query_test.go index 8462df5..5aab21c 100644 --- a/backends/dameng/query_test.go +++ b/backends/dameng/query_test.go @@ -49,7 +49,7 @@ func TestQuery(t *testing.T) { t.Run("query selected fields varchar ", func(t *testing.T) { testReset() q := testTable.Query(testTable.Field("col0")).Equals("col0", "abce") - want := `SELECT "t1"."col0" AS "col0" FROM "test" AS "t1" WHERE TEXT_EQUAL("t1"."col0" , ? )` + want := `SELECT "t1"."col0" AS "col0" FROM "test" AS "t1" WHERE "t1"."col0" = ? ` testGotWant(t, q.String(), want) })