@@ -142,7 +142,7 @@ import PuddySqlTags from './PuddySqlTags.mjs';
142142 *
143143 * @typedef {Object } BoostValue
144144 * @property {string[] } [columns] - List of columns to apply the boost on.
145- * @property {string } [operator='LIKE '] - Operator used in the condition (e.g., '=', 'LIKE').
145+ * @property {''|'LIKE'|'ILIKE' } [operator=''] - Operator used in the condition (e.g., '=', 'LIKE').
146146 * @property {string|string[] } [value] - Value to match in the condition.
147147 * @property {boolean } [array=false] - When true, performs matching using `json_each()` for JSON/ARRAY columns instead of text comparison.
148148 * @property {number } [weight=1] - Weight factor to boost results matching the condition.
@@ -621,12 +621,16 @@ class PuddySqlQuery {
621621 // Boost
622622 for ( const boost of boostArray ) {
623623 // Validator
624- const { columns, operator = 'LIKE ' , value, weight = 1 , array = false } = boost ;
624+ const { columns, operator = '' , value, weight = 1 , array = false } = boost ;
625625 if ( typeof operator !== 'string' )
626626 throw new Error ( `operator requires an string value. Got: ${ typeof operator } ` ) ;
627627 const opValue = operator . toUpperCase ( ) ;
628628 if ( typeof weight !== 'number' || Number . isNaN ( weight ) )
629629 throw new Error ( `Boost 'weight' must be a valid number. Got: ${ weight } ` ) ;
630+ if ( [ 'LIKE' , 'ILIKE' , '' ] . indexOf ( opValue ) < 0 )
631+ throw new TypeError (
632+ `Invalid operator '${ opValue } '. Only 'LIKE', 'ILIKE', or empty string '' are allowed.` ,
633+ ) ;
630634
631635 // No columns mode
632636 if ( ! columns ) {
0 commit comments