Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 911f86a

Browse files
authored
[flights, recent regression] Quickfix __quesma_match for bools (#1385)
a) I think we trimmed `%` from strings a bit too often b) if trimming `%` from bools or numbers helps, then let's do this as well. After: ![Screenshot 2025-03-28 at 21 26 53](https://github.com/user-attachments/assets/76fe9449-44ca-462b-b643-8ab8ca124e5b) Before: ![Screenshot 2025-03-28 at 21 34 57](https://github.com/user-attachments/assets/10d6d988-13e5-4cbb-9abd-ff749d059efc)
1 parent e453e40 commit 911f86a

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

platform/frontend_connectors/schema_transformer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,6 @@ func (s *SchemaCheckPass) applyMatchOperator(indexSchema schema.Schema, query *m
11061106
return model.NewInfixExpr(lhs, "ILIKE", rhs.Clone())
11071107
}
11081108
equal := func() model.Expr {
1109-
rhsValue = strings.Trim(rhsValue, "%")
11101109
return model.NewInfixExpr(lhs, "=", rhs.Clone())
11111110
}
11121111

@@ -1123,6 +1122,8 @@ func (s *SchemaCheckPass) applyMatchOperator(indexSchema schema.Schema, query *m
11231122
// TODO: improve? we seem to be `ilike'ing` too much
11241123
switch field.Type.String() {
11251124
case schema.QuesmaTypeInteger.Name, schema.QuesmaTypeLong.Name, schema.QuesmaTypeUnsignedLong.Name, schema.QuesmaTypeFloat.Name, schema.QuesmaTypeBoolean.Name:
1125+
rhs.Value = strings.Trim(rhsValue, "%")
1126+
rhs.EscapeType = model.NormalNotEscaped
11261127
return equal()
11271128
default:
11281129
return ilike()

platform/frontend_connectors/schema_transformer_test.go

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,7 @@ func Test_applyMatchOperator(t *testing.T) {
11431143
schemaTable := schema.Table{
11441144
Columns: map[string]schema.Column{
11451145
"message": {Name: "message", Type: "String"},
1146+
"easy": {Name: "easy", Type: "Bool"},
11461147
"map_str_str": {Name: "map_str_str", Type: "Map(String, String)"},
11471148
"map_str_int": {Name: "map_str_int", Type: "Map(String, Int)"},
11481149
"count": {Name: "count", Type: "Int64"},
@@ -1203,7 +1204,34 @@ func Test_applyMatchOperator(t *testing.T) {
12031204
WhereClause: model.NewInfixExpr(
12041205
model.NewColumnRef("count"),
12051206
"=",
1206-
model.NewLiteral("'123'"),
1207+
model.NewLiteral("123"),
1208+
),
1209+
},
1210+
},
1211+
},
1212+
{
1213+
name: "match operator transformation for Bool",
1214+
query: &model.Query{
1215+
TableName: "test",
1216+
SelectCommand: model.SelectCommand{
1217+
FromClause: model.NewTableRef("test"),
1218+
Columns: []model.Expr{model.NewColumnRef("message")},
1219+
WhereClause: model.NewInfixExpr(
1220+
model.NewColumnRef("easy"),
1221+
model.MatchOperator,
1222+
model.NewLiteralWithEscapeType("true", model.NotEscapedLikeFull),
1223+
),
1224+
},
1225+
},
1226+
expected: &model.Query{
1227+
TableName: "test",
1228+
SelectCommand: model.SelectCommand{
1229+
FromClause: model.NewTableRef("test"),
1230+
Columns: []model.Expr{model.NewColumnRef("message")},
1231+
WhereClause: model.NewInfixExpr(
1232+
model.NewColumnRef("easy"),
1233+
"=",
1234+
model.TrueExpr,
12071235
),
12081236
},
12091237
},

0 commit comments

Comments
 (0)