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: pinned shortcut comparison operators (#4987)
Neo6b507ff6002d
diff --git a/plugin/filter/common_converter.go b/plugin/filter/common_converter.goindex 73c693911..6ad0a04c3 100644--- a/plugin/filter/common_converter.go+++ b/plugin/filter/common_converter.go@@ -122,7 +122,7 @@ func (c *CommonSQLConverter) handleComparisonOperator(ctx *ConvertContext, callEreturn err}- if !slices.Contains([]string{"creator_id", "created_ts", "updated_ts", "visibility", "content", "has_task_list", "has_link", "has_code", "has_incomplete_tasks"}, identifier) {+ if !slices.Contains([]string{"creator_id", "created_ts", "updated_ts", "visibility", "content", "pinned", "has_task_list", "has_link", "has_code", "has_incomplete_tasks"}, identifier) {return errors.Errorf("invalid identifier for %s", callExpr.Function)}@@ -140,6 +140,8 @@ func (c *CommonSQLConverter) handleComparisonOperator(ctx *ConvertContext, callEreturn c.handleStringComparison(ctx, identifier, operator, value)case "creator_id":return c.handleIntComparison(ctx, identifier, operator, value)+ case "pinned":+ return c.handlePinnedComparison(ctx, operator, value)case "has_task_list", "has_link", "has_code", "has_incomplete_tasks":return c.handleBooleanComparison(ctx, identifier, operator, value)}@@ -491,6 +493,35 @@ func (c *CommonSQLConverter) handleIntComparison(ctx *ConvertContext, field, opereturn nil}+func (c *CommonSQLConverter) handlePinnedComparison(ctx *ConvertContext, operator string, value interface{}) error {+ if operator != "=" && operator != "!=" {+ return errors.Errorf("invalid operator for pinned field")+ }++ valueBool, ok := value.(bool)+ if !ok {+ return errors.New("invalid boolean value for pinned field")+ }++ tablePrefix := c.dialect.GetTablePrefix("memo")++ var sqlExpr string+ if _, ok := c.dialect.(*PostgreSQLDialect); ok {+ sqlExpr = fmt.Sprintf("%s.pinned %s %s", tablePrefix, operator, c.dialect.GetParameterPlaceholder(c.paramIndex))+ } else {+ sqlExpr = fmt.Sprintf("%s.`pinned` %s %s", tablePrefix, operator, c.dialect.GetParameterPlaceholder(c.paramIndex))+ }++ if _, err := ctx.Buffer.WriteString(sqlExpr); err != nil {+ return err+ }++ ctx.Args = append(ctx.Args, c.dialect.GetBooleanValue(valueBool))+ c.paramIndex++++ return nil+}+func (c *CommonSQLConverter) handleBooleanComparison(ctx *ConvertContext, field, operator string, value interface{}) error {if operator != "=" && operator != "!=" {return errors.Errorf("invalid operator for %s", field)@@ -574,7 +605,7 @@ func (c *CommonSQLConverter) handleBooleanComparison(ctx *ConvertContext, field,// Handle PostgreSQL differently - it uses the raw operatorif _, ok := c.dialect.(*PostgreSQLDialect); ok {- var jsonExtract = c.dialect.GetJSONExtract(jsonPath)+ jsonExtract := c.dialect.GetJSONExtract(jsonPath)sqlExpr := fmt.Sprintf("(%s)::boolean %s %s",jsonExtract,