Skip to content

Commit cd217e1

Browse files
PuddySqlTags.md updated.
1 parent 60e3d60 commit cd217e1

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

docs/PuddySqlTags.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,25 @@ Builds a SQL `WHERE` clause from a tag group definition.
235235

236236
---
237237

238+
### `parseWhereFlat(group: TagCriteria, pCache: Pcache): string`
239+
240+
Builds an SQL `WHERE` clause for *flat* tag tables — where each row contains a single tag value.
241+
242+
* Does **not** use `EXISTS` or `json_each`
243+
* Supports **negation** (`!tag`)
244+
* Handles **wildcards** (`*`, `?`) when enabled
245+
* Allows **OR groups** using nested arrays
246+
* Updates `pCache` in-place with positional parameters (`$1`, `$2`, ...)
247+
248+
📝 **Returns**:
249+
A complete SQL `WHERE` expression string like:
250+
251+
```sql
252+
(tag = $1 AND (tag LIKE $2 OR tag != $3))
253+
```
254+
255+
---
256+
238257
## 🧬 Internal Parsing Logic
239258

240259
### `#extractSpecialsFromChunks(chunks: Chunks): object`

test/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ const db = new PuddySql.Instance();
262262
return value;
263263
}});
264264

265-
const tagsList = `(pinkie pie OR rarity) AND (applejack OR rarity) AND (farm OR boutique) AND (!party OR balloons) AND rating:safe AND order:random AND NOT order:random2`;
265+
const tagsList = `(pinkie pie OR rarity) AND (applejack OR rarity) AND (farm OR boutique) AND (!party OR balloons^2) AND rating:safe AND order:random AND NOT order:random2`;
266266

267267
console.log('\n🔖 \x1b[34mParse Tags: JSON\x1b[0m\n');
268268
console.log(tagsList);

0 commit comments

Comments
 (0)