Database: Support NULL and int64 in SAKE filter

This commit is contained in:
Palapeli 2026-04-01 06:29:44 -04:00
parent 4f281ef7cc
commit 2418fbf37d
No known key found for this signature in database
GPG Key ID: 1FFE8F556A474925
2 changed files with 3 additions and 2 deletions

View File

@ -81,7 +81,7 @@ func (this *expression) filterSwitchFunction(node *filter.TreeNode) {
func (this *expression) filterAppendNode(node *filter.TreeNode) {
switch v := node.Value.(type) {
case *filter.NumberToken:
this.query += "'" + strconv.FormatInt(int64(int32(v.Value)), 10) + "'"
this.query += "'" + strconv.FormatInt(v.Value, 10) + "'"
case *filter.IdentityToken:
this.filterAppendQueryValue(v)
case *filter.OperatorToken:
@ -171,7 +171,7 @@ func (this *expression) filterAppendQueryValue(token *filter.IdentityToken) {
return
}
this.query += "(fields->" + this.filterPushArg(token.Name) + "->>'value')"
this.query += "COALESCE(fields->" + this.filterPushArg(token.Name) + "->>'value', '0')"
}

View File

@ -29,6 +29,7 @@ func testGenerateFilter(t *testing.T, expression string) (string, error) {
func TestSakeFilter(t *testing.T) {
testGenerateFilter(t, "ownerid = 1")
testGenerateFilter(t, "course = 12 and gameid = 1687 and time < 195")
testGenerateFilter(t, "wiiid = 8880667695734424 and num_ratings = 0")
// Random complex filter I made up
testGenerateFilter(t, "gameid = 1687 and (test = 'aaa' or (DROP = 100000) and ((((UPDATE != 4))))) or (1 = 2 + 7 & SELECT - 9)")