From 5c711bbe5fc9fa113ebd750812af19ce83a940b7 Mon Sep 17 00:00:00 2001 From: Jason Gessner Date: Thu, 5 Mar 2026 02:14:20 +0000 Subject: [PATCH 1/2] Add id operand to search grammar. --- lib/search_query_builder.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/search_query_builder.rb b/lib/search_query_builder.rb index 0a34ce7..57acd75 100644 --- a/lib/search_query_builder.rb +++ b/lib/search_query_builder.rb @@ -216,7 +216,9 @@ def self.both(field) FieldData.new(:string, both('stripped_text'), %w[text x], 'The text of a card, stripped of all formatting symbols and marks.'), FieldData.new(:string, both('stripped_title'), %w[title _], - 'The title of a card, stripped of all formatting symbols and marks.') + 'The title of a card, stripped of all formatting symbols and marks.'), + FieldData.new(:string, both('id'), %w[id], + 'The string id for this type.') ] # rubocop:enable Layout/LineLength def self.search_filter_docs @@ -324,7 +326,7 @@ def initialize(query) end # Generate SQL query and parameters from AST - # This has the side effect of adding the SQL parameters to @where_values + # This has the side effect of adding the SQL parameters to @whereues @where_values = [] # TODO(plural): Capture any exceptions in here and return them as well formatted errors. @where = transform.apply(@parse_tree).construct_clause(@where_values, fields) @@ -462,10 +464,9 @@ def construct_clause(parameters, context) # Booleans when :boolean - unless %w[true false t f 1 0].include?(value) + unless %w[true false t f 1 0 any].include?(value) raise format('Invalid value "%s" for boolean field "%s"', value:, field: context.keyword) end - parameters << value format('%s %s ?', sql: context.field.sql, operator: sql_operator) From 52f2f019c8d4cdf7933280b9079e38ad71f7dbbc Mon Sep 17 00:00:00 2001 From: Jason Gessner Date: Thu, 5 Mar 2026 02:23:27 +0000 Subject: [PATCH 2/2] Fix lint --- lib/search_query_builder.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/search_query_builder.rb b/lib/search_query_builder.rb index 57acd75..258faad 100644 --- a/lib/search_query_builder.rb +++ b/lib/search_query_builder.rb @@ -467,6 +467,7 @@ def construct_clause(parameters, context) unless %w[true false t f 1 0 any].include?(value) raise format('Invalid value "%s" for boolean field "%s"', value:, field: context.keyword) end + parameters << value format('%s %s ?', sql: context.field.sql, operator: sql_operator)