11import { isJsonObject } from 'tiny-essentials' ;
22import { pg } from './Modules.mjs' ;
3-
43import PuddySqlInstance from './TinySQL.mjs' ;
54import PuddySqlTags from './TinySqlTags.mjs' ;
65
7- const clientBase = new pg . Client ( ) ;
8-
96/**
107 * Tag group definition used to build dynamic SQL clauses for tag filtering.
118 *
@@ -432,7 +429,7 @@ class PuddySqlQuery {
432429 * - `weight` (number): numeric weight applied when condition matches (default: 1)
433430 * - If `columns` is omitted, the `value` is treated as a raw SQL condition inserted directly into the CASE.
434431 *
435- * Escaping of all values is handled by `Client .escapeLiteral()` for SQL safety (PostgreSQL).
432+ * Escaping of all values is handled by `pg .escapeLiteral()` for SQL safety (PostgreSQL).
436433 *
437434 * @param {SelectQuery } input - Select clause definition.
438435 * @returns {string } - A valid SQL SELECT clause string.
@@ -524,7 +521,7 @@ class PuddySqlQuery {
524521 if ( opValue === 'IN' ) {
525522 const conditions = columns . map ( ( col ) => {
526523 if ( Array . isArray ( value ) ) {
527- const inList = value . map ( ( v ) => clientBase . escapeLiteral ( v ) ) . join ( ', ' ) ;
524+ const inList = value . map ( ( v ) => pg . escapeLiteral ( v ) ) . join ( ', ' ) ;
528525 return `${ col } IN (${ inList } )` ;
529526 } else {
530527 console . warn ( `IN operator expected array, got` , value ) ;
@@ -533,7 +530,7 @@ class PuddySqlQuery {
533530 } ) ;
534531 cases . push ( `WHEN ${ conditions . join ( ' OR ' ) } THEN ${ weight } ` ) ;
535532 } else {
536- const safeVal = clientBase . escapeLiteral (
533+ const safeVal = pg . escapeLiteral (
537534 [ 'LIKE' , 'ILIKE' ] . includes ( opValue ) ? `%${ value } %` : value ,
538535 ) ;
539536 const conditions = columns . map ( ( col ) => `${ col } ${ operator } ${ safeVal } ` ) ;
0 commit comments