Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
fix: tests
johnnyjoye24f92b7198f
diff --git a/store/db/mysql/memo_filter.go b/store/db/mysql/memo_filter.goindex b7cdee86b..b69332968 100644--- a/store/db/mysql/memo_filter.go+++ b/store/db/mysql/memo_filter.go@@ -184,7 +184,7 @@ func (d *DB) convertWithTemplates(ctx *filter.ConvertContext, expr *exprv1.Expr)if !ok {return errors.Errorf("invalid boolean value for %s", identifier)}-+// Map identifier to JSON pathvar jsonPath stringswitch identifier {@@ -195,7 +195,7 @@ func (d *DB) convertWithTemplates(ctx *filter.ConvertContext, expr *exprv1.Expr)case "has_incomplete_tasks":jsonPath = "$.property.hasIncompleteTasks"}-+// Use JSON_EXTRACT for boolean comparison like has_task_listvar sqlTemplate stringif operator == "=" {@@ -323,7 +323,7 @@ func (d *DB) convertWithTemplates(ctx *filter.ConvertContext, expr *exprv1.Expr)return err}} else if identifier == "has_code" {- // Handle has_code as a standalone boolean identifier+ // Handle has_code as a standalone boolean identifierif _, err := ctx.Buffer.WriteString("JSON_EXTRACT(`memo`.`payload`, '$.property.hasCode') = CAST('true' AS JSON)"); err != nil {return err}diff --git a/store/db/postgres/memo_filter.go b/store/db/postgres/memo_filter.goindex cbb3b088c..e982880fc 100644--- a/store/db/postgres/memo_filter.go+++ b/store/db/postgres/memo_filter.go@@ -192,7 +192,7 @@ func (d *DB) convertWithParameterIndex(ctx *filter.ConvertContext, expr *exprv1.if !ok {return paramIndex, errors.Errorf("invalid boolean value for %s", identifier)}-+// Map identifier to JSON pathvar jsonPath stringswitch identifier {@@ -203,22 +203,14 @@ func (d *DB) convertWithParameterIndex(ctx *filter.ConvertContext, expr *exprv1.case "has_incomplete_tasks":jsonPath = "$.property.hasIncompleteTasks"}-+// Use JSON path for boolean comparison with PostgreSQL parameter placeholderplaceholder := filter.GetParameterPlaceholder(dbType, paramIndex)var sqlTemplate stringif operator == "=" {- if valueBool {- sqlTemplate = fmt.Sprintf("(%s->'payload'->'property'->>'%s')::boolean = %s", filter.GetSQL("table_prefix", dbType), strings.TrimPrefix(jsonPath, "$.property."), placeholder)- } else {- sqlTemplate = fmt.Sprintf("(%s->'payload'->'property'->>'%s')::boolean = %s", filter.GetSQL("table_prefix", dbType), strings.TrimPrefix(jsonPath, "$.property."), placeholder)- }+ sqlTemplate = fmt.Sprintf("(%s->'payload'->'property'->>'%s')::boolean = %s", filter.GetSQL("table_prefix", dbType), strings.TrimPrefix(jsonPath, "$.property."), placeholder)} else { // operator == "!="- if valueBool {- sqlTemplate = fmt.Sprintf("(%s->'payload'->'property'->>'%s')::boolean != %s", filter.GetSQL("table_prefix", dbType), strings.TrimPrefix(jsonPath, "$.property."), placeholder)- } else {- sqlTemplate = fmt.Sprintf("(%s->'payload'->'property'->>'%s')::boolean != %s", filter.GetSQL("table_prefix", dbType), strings.TrimPrefix(jsonPath, "$.property."), placeholder)- }+ sqlTemplate = fmt.Sprintf("(%s->'payload'->'property'->>'%s')::boolean != %s", filter.GetSQL("table_prefix", dbType), strings.TrimPrefix(jsonPath, "$.property."), placeholder)}if _, err := ctx.Buffer.WriteString(sqlTemplate); err != nil {return paramIndex, err@@ -347,7 +339,7 @@ func (d *DB) convertWithParameterIndex(ctx *filter.ConvertContext, expr *exprv1.return paramIndex, err}} else if identifier == "has_code" {- // Handle has_code as a standalone boolean identifier+ // Handle has_code as a standalone boolean identifierif _, err := ctx.Buffer.WriteString(fmt.Sprintf("(%s->'payload'->'property'->>'hasCode')::boolean = true", filter.GetSQL("table_prefix", dbType))); err != nil {return paramIndex, err}diff --git a/store/db/sqlite/memo_filter.go b/store/db/sqlite/memo_filter.goindex 17f22f98b..b231f085f 100644--- a/store/db/sqlite/memo_filter.go+++ b/store/db/sqlite/memo_filter.go@@ -184,7 +184,7 @@ func (d *DB) convertWithTemplates(ctx *filter.ConvertContext, expr *exprv1.Expr)if !ok {return errors.Errorf("invalid boolean value for %s", identifier)}-+// Map identifier to JSON pathvar jsonPath stringswitch identifier {@@ -195,7 +195,7 @@ func (d *DB) convertWithTemplates(ctx *filter.ConvertContext, expr *exprv1.Expr)case "has_incomplete_tasks":jsonPath = "$.property.hasIncompleteTasks"}-+// Use JSON_EXTRACT for boolean comparison like has_task_listvar sqlTemplate stringif operator == "=" {@@ -323,7 +323,7 @@ func (d *DB) convertWithTemplates(ctx *filter.ConvertContext, expr *exprv1.Expr)return err}} else if identifier == "has_code" {- // Handle has_code as a standalone boolean identifier+ // Handle has_code as a standalone boolean identifierif _, err := ctx.Buffer.WriteString("JSON_EXTRACT(`memo`.`payload`, '$.property.hasCode') = JSON('true')"); err != nil {return err}