postgresdk 0.16.8 → 0.16.9

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.
Files changed (3) hide show
  1. package/dist/cli.js +20 -10
  2. package/dist/index.js +20 -10
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -4979,17 +4979,27 @@ function buildWhereClause(
4979
4979
  paramIndex++;
4980
4980
  break;
4981
4981
  case '$in':
4982
- if (Array.isArray(opValue) && opValue.length > 0) {
4983
- whereParts.push(\`"\${key}" = ANY($\${paramIndex})\`);
4984
- whereParams.push(opValue);
4985
- paramIndex++;
4982
+ if (Array.isArray(opValue)) {
4983
+ if (opValue.length > 0) {
4984
+ whereParts.push(\`"\${key}" = ANY($\${paramIndex})\`);
4985
+ whereParams.push(opValue);
4986
+ paramIndex++;
4987
+ } else {
4988
+ // Empty $in is logically FALSE - matches nothing
4989
+ whereParts.push('FALSE');
4990
+ }
4986
4991
  }
4987
4992
  break;
4988
4993
  case '$nin':
4989
- if (Array.isArray(opValue) && opValue.length > 0) {
4990
- whereParts.push(\`"\${key}" != ALL($\${paramIndex})\`);
4991
- whereParams.push(opValue);
4992
- paramIndex++;
4994
+ if (Array.isArray(opValue)) {
4995
+ if (opValue.length > 0) {
4996
+ whereParts.push(\`"\${key}" != ALL($\${paramIndex})\`);
4997
+ whereParams.push(opValue);
4998
+ paramIndex++;
4999
+ } else {
5000
+ // Empty $nin is logically TRUE - matches everything (but we still need a condition)
5001
+ // This is handled by simply not adding a condition
5002
+ }
4993
5003
  }
4994
5004
  break;
4995
5005
  case '$like':
@@ -5284,14 +5294,14 @@ export async function listRecords(
5284
5294
  // Get total count for pagination
5285
5295
  const countText = \`SELECT COUNT(*) FROM "\${ctx.table}" \${countWhereSQL}\`;
5286
5296
  log.debug(\`LIST \${ctx.table} COUNT SQL:\`, countText, "params:", countParams);
5287
- const countResult = await ctx.pg.query(countText, prepareParams(countParams));
5297
+ const countResult = await ctx.pg.query(countText, countParams);
5288
5298
  const total = parseInt(countResult.rows[0].count, 10);
5289
5299
 
5290
5300
  // Get paginated data
5291
5301
  const text = \`SELECT \${selectClause} FROM "\${ctx.table}" \${whereSQL} \${orderBySQL} LIMIT \${limitParam} OFFSET \${offsetParam}\`;
5292
5302
  log.debug(\`LIST \${ctx.table} SQL:\`, text, "params:", allParams);
5293
5303
 
5294
- const { rows } = await ctx.pg.query(text, prepareParams(allParams));
5304
+ const { rows } = await ctx.pg.query(text, allParams);
5295
5305
  const parsedRows = parseVectorColumns(rows, ctx.vectorColumns);
5296
5306
 
5297
5307
  // Calculate hasMore
package/dist/index.js CHANGED
@@ -4078,17 +4078,27 @@ function buildWhereClause(
4078
4078
  paramIndex++;
4079
4079
  break;
4080
4080
  case '$in':
4081
- if (Array.isArray(opValue) && opValue.length > 0) {
4082
- whereParts.push(\`"\${key}" = ANY($\${paramIndex})\`);
4083
- whereParams.push(opValue);
4084
- paramIndex++;
4081
+ if (Array.isArray(opValue)) {
4082
+ if (opValue.length > 0) {
4083
+ whereParts.push(\`"\${key}" = ANY($\${paramIndex})\`);
4084
+ whereParams.push(opValue);
4085
+ paramIndex++;
4086
+ } else {
4087
+ // Empty $in is logically FALSE - matches nothing
4088
+ whereParts.push('FALSE');
4089
+ }
4085
4090
  }
4086
4091
  break;
4087
4092
  case '$nin':
4088
- if (Array.isArray(opValue) && opValue.length > 0) {
4089
- whereParts.push(\`"\${key}" != ALL($\${paramIndex})\`);
4090
- whereParams.push(opValue);
4091
- paramIndex++;
4093
+ if (Array.isArray(opValue)) {
4094
+ if (opValue.length > 0) {
4095
+ whereParts.push(\`"\${key}" != ALL($\${paramIndex})\`);
4096
+ whereParams.push(opValue);
4097
+ paramIndex++;
4098
+ } else {
4099
+ // Empty $nin is logically TRUE - matches everything (but we still need a condition)
4100
+ // This is handled by simply not adding a condition
4101
+ }
4092
4102
  }
4093
4103
  break;
4094
4104
  case '$like':
@@ -4383,14 +4393,14 @@ export async function listRecords(
4383
4393
  // Get total count for pagination
4384
4394
  const countText = \`SELECT COUNT(*) FROM "\${ctx.table}" \${countWhereSQL}\`;
4385
4395
  log.debug(\`LIST \${ctx.table} COUNT SQL:\`, countText, "params:", countParams);
4386
- const countResult = await ctx.pg.query(countText, prepareParams(countParams));
4396
+ const countResult = await ctx.pg.query(countText, countParams);
4387
4397
  const total = parseInt(countResult.rows[0].count, 10);
4388
4398
 
4389
4399
  // Get paginated data
4390
4400
  const text = \`SELECT \${selectClause} FROM "\${ctx.table}" \${whereSQL} \${orderBySQL} LIMIT \${limitParam} OFFSET \${offsetParam}\`;
4391
4401
  log.debug(\`LIST \${ctx.table} SQL:\`, text, "params:", allParams);
4392
4402
 
4393
- const { rows } = await ctx.pg.query(text, prepareParams(allParams));
4403
+ const { rows } = await ctx.pg.query(text, allParams);
4394
4404
  const parsedRows = parseVectorColumns(rows, ctx.vectorColumns);
4395
4405
 
4396
4406
  // Calculate hasMore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postgresdk",
3
- "version": "0.16.8",
3
+ "version": "0.16.9",
4
4
  "description": "Generate a typed server/client SDK from a Postgres schema (includes, Zod, Hono).",
5
5
  "type": "module",
6
6
  "bin": {