mirror of https://github.com/usememos/memos.git
fix test
This commit is contained in:
parent
44ea846460
commit
fd825dde3d
|
|
@ -35,12 +35,12 @@ var SQLTemplates = map[string]SQLTemplate{
|
|||
"json_contains_element": {
|
||||
SQLite: "JSON_EXTRACT(`memo`.`payload`, '$.tags') LIKE ?",
|
||||
MySQL: "JSON_CONTAINS(JSON_EXTRACT(`memo`.`payload`, '$.tags'), ?)",
|
||||
PostgreSQL: "memo.payload->'tags' @> jsonb_build_array(?::text)",
|
||||
PostgreSQL: "memo.payload->'tags' @> jsonb_build_array(?)",
|
||||
},
|
||||
"json_contains_tag": {
|
||||
SQLite: "JSON_EXTRACT(`memo`.`payload`, '$.tags') LIKE ?",
|
||||
MySQL: "JSON_CONTAINS(JSON_EXTRACT(`memo`.`payload`, '$.tags'), ?)",
|
||||
PostgreSQL: "memo.payload->'tags' @> jsonb_build_array(?::text)",
|
||||
PostgreSQL: "memo.payload->'tags' @> jsonb_build_array(?)",
|
||||
},
|
||||
"boolean_true": {
|
||||
SQLite: "JSON_EXTRACT(`memo`.`payload`, '$.property.hasTaskList') = 1",
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ func TestConvertExprToSQL(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
filter: `tag in ["tag1", "tag2"]`,
|
||||
want: "(memo.payload->'tags' @> jsonb_build_array($1) OR memo.payload->'tags' @> jsonb_build_array($2))",
|
||||
want: "(memo.payload->'tags' @> jsonb_build_array($1::text) OR memo.payload->'tags' @> jsonb_build_array($2::text))",
|
||||
args: []any{"tag1", "tag2"},
|
||||
},
|
||||
{
|
||||
filter: `!(tag in ["tag1", "tag2"])`,
|
||||
want: "NOT ((memo.payload->'tags' @> jsonb_build_array($1) OR memo.payload->'tags' @> jsonb_build_array($2)))",
|
||||
want: "NOT ((memo.payload->'tags' @> jsonb_build_array($1::text) OR memo.payload->'tags' @> jsonb_build_array($2::text)))",
|
||||
args: []any{"tag1", "tag2"},
|
||||
},
|
||||
{
|
||||
|
|
@ -42,7 +42,7 @@ func TestConvertExprToSQL(t *testing.T) {
|
|||
},
|
||||
{
|
||||
filter: `tag in ['tag1'] || content.contains('hello')`,
|
||||
want: "(memo.payload->'tags' @> jsonb_build_array($1) OR memo.content ILIKE $2)",
|
||||
want: "(memo.payload->'tags' @> jsonb_build_array($1::text) OR memo.content ILIKE $2)",
|
||||
args: []any{"tag1", "%hello%"},
|
||||
},
|
||||
{
|
||||
|
|
@ -107,7 +107,7 @@ func TestConvertExprToSQL(t *testing.T) {
|
|||
},
|
||||
{
|
||||
filter: `"work" in tags`,
|
||||
want: "memo.payload->'tags' @> jsonb_build_array($1)",
|
||||
want: "memo.payload->'tags' @> jsonb_build_array($1::text)",
|
||||
args: []any{"work"},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue