dzql 0.6.21 → 0.6.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dzql",
3
- "version": "0.6.21",
3
+ "version": "0.6.22",
4
4
  "description": "Database-first real-time framework with TypeScript support",
5
5
  "repository": {
6
6
  "type": "git",
@@ -203,14 +203,32 @@ function buildFinalExistsCheck(finalHop: string, valueExpr: string): string {
203
203
  conditions.push(`${targetTable}.id = ${valueExpr}`);
204
204
  }
205
205
 
206
- // Temporal/active condition
206
+ // Temporal/active condition - may have multiple comma-separated parts
207
+ // e.g., {active} or {role='admin'} or {active,role=admin}
207
208
  if (condition) {
208
- // Handle simple boolean condition like {active}
209
- if (condition.match(/^[a-zA-Z0-9_]+$/)) {
210
- conditions.push(`${targetTable}.${condition} = true`);
211
- } else {
212
- // Handle complex condition like {role='admin'}
213
- conditions.push(`${targetTable}.${condition}`);
209
+ // Split by comma for multiple conditions
210
+ const conditionParts = condition.split(',').map(c => c.trim());
211
+ for (const part of conditionParts) {
212
+ // Handle simple boolean condition like {active}
213
+ if (part.match(/^[a-zA-Z0-9_]+$/)) {
214
+ conditions.push(`${targetTable}.${part} = true`);
215
+ } else {
216
+ // Handle complex condition like role='admin' or role=admin
217
+ // Convert role=admin to role = 'admin' for proper SQL
218
+ const eqMatch = part.match(/^([a-zA-Z0-9_]+)=(.+)$/);
219
+ if (eqMatch) {
220
+ const field = eqMatch[1];
221
+ let value = eqMatch[2];
222
+ // If value is already quoted, use as-is; otherwise quote it
223
+ if (!value.startsWith("'") && !value.match(/^\d+$/)) {
224
+ value = `'${value}'`;
225
+ }
226
+ conditions.push(`${targetTable}.${field} = ${value}`);
227
+ } else {
228
+ // Fallback: use as-is (e.g., complex expression)
229
+ conditions.push(`${targetTable}.${part}`);
230
+ }
231
+ }
214
232
  }
215
233
  }
216
234
 
@@ -224,4 +242,4 @@ function buildFinalExistsCheck(finalHop: string, valueExpr: string): string {
224
242
  const whereClause = conditions.join(' AND ');
225
243
 
226
244
  return `EXISTS (SELECT 1 FROM ${targetTable} WHERE ${whereClause})`;
227
- }
245
+ }