postgresdk 0.16.8 → 0.16.10
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/dist/cli.js +29 -13
- package/dist/index.js +29 -13
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4119,7 +4119,9 @@ ${baseSelectType}
|
|
|
4119
4119
|
* @example Insert${Type}<{ metadata: MyMetadataType }>
|
|
4120
4120
|
*/
|
|
4121
4121
|
export type Insert${Type}<TJsonb extends Partial<_Insert${Type}Base> = {}> =
|
|
4122
|
-
|
|
4122
|
+
{} extends TJsonb
|
|
4123
|
+
? _Insert${Type}Base
|
|
4124
|
+
: Omit<_Insert${Type}Base, keyof TJsonb> & TJsonb;
|
|
4123
4125
|
|
|
4124
4126
|
/**
|
|
4125
4127
|
* Type for updating an existing ${table.name} record.
|
|
@@ -4129,7 +4131,9 @@ export type Insert${Type}<TJsonb extends Partial<_Insert${Type}Base> = {}> =
|
|
|
4129
4131
|
* @example Update${Type}<{ metadata: MyMetadataType }>
|
|
4130
4132
|
*/
|
|
4131
4133
|
export type Update${Type}<TJsonb extends Partial<_Select${Type}Base> = {}> =
|
|
4132
|
-
|
|
4134
|
+
{} extends TJsonb
|
|
4135
|
+
? Partial<_Insert${Type}Base>
|
|
4136
|
+
: Partial<Omit<_Insert${Type}Base, keyof TJsonb> & TJsonb>;
|
|
4133
4137
|
|
|
4134
4138
|
/**
|
|
4135
4139
|
* Type representing a ${table.name} record from the database.
|
|
@@ -4139,7 +4143,9 @@ export type Update${Type}<TJsonb extends Partial<_Select${Type}Base> = {}> =
|
|
|
4139
4143
|
* @example Select${Type}<{ metadata: MyMetadataType }>
|
|
4140
4144
|
*/
|
|
4141
4145
|
export type Select${Type}<TJsonb extends Partial<_Select${Type}Base> = {}> =
|
|
4142
|
-
|
|
4146
|
+
{} extends TJsonb
|
|
4147
|
+
? _Select${Type}Base
|
|
4148
|
+
: Omit<_Select${Type}Base, keyof TJsonb> & TJsonb;
|
|
4143
4149
|
`;
|
|
4144
4150
|
}
|
|
4145
4151
|
return `/**
|
|
@@ -4979,17 +4985,27 @@ function buildWhereClause(
|
|
|
4979
4985
|
paramIndex++;
|
|
4980
4986
|
break;
|
|
4981
4987
|
case '$in':
|
|
4982
|
-
if (Array.isArray(opValue)
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4988
|
+
if (Array.isArray(opValue)) {
|
|
4989
|
+
if (opValue.length > 0) {
|
|
4990
|
+
whereParts.push(\`"\${key}" = ANY($\${paramIndex})\`);
|
|
4991
|
+
whereParams.push(opValue);
|
|
4992
|
+
paramIndex++;
|
|
4993
|
+
} else {
|
|
4994
|
+
// Empty $in is logically FALSE - matches nothing
|
|
4995
|
+
whereParts.push('FALSE');
|
|
4996
|
+
}
|
|
4986
4997
|
}
|
|
4987
4998
|
break;
|
|
4988
4999
|
case '$nin':
|
|
4989
|
-
if (Array.isArray(opValue)
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
5000
|
+
if (Array.isArray(opValue)) {
|
|
5001
|
+
if (opValue.length > 0) {
|
|
5002
|
+
whereParts.push(\`"\${key}" != ALL($\${paramIndex})\`);
|
|
5003
|
+
whereParams.push(opValue);
|
|
5004
|
+
paramIndex++;
|
|
5005
|
+
} else {
|
|
5006
|
+
// Empty $nin is logically TRUE - matches everything (but we still need a condition)
|
|
5007
|
+
// This is handled by simply not adding a condition
|
|
5008
|
+
}
|
|
4993
5009
|
}
|
|
4994
5010
|
break;
|
|
4995
5011
|
case '$like':
|
|
@@ -5284,14 +5300,14 @@ export async function listRecords(
|
|
|
5284
5300
|
// Get total count for pagination
|
|
5285
5301
|
const countText = \`SELECT COUNT(*) FROM "\${ctx.table}" \${countWhereSQL}\`;
|
|
5286
5302
|
log.debug(\`LIST \${ctx.table} COUNT SQL:\`, countText, "params:", countParams);
|
|
5287
|
-
const countResult = await ctx.pg.query(countText,
|
|
5303
|
+
const countResult = await ctx.pg.query(countText, countParams);
|
|
5288
5304
|
const total = parseInt(countResult.rows[0].count, 10);
|
|
5289
5305
|
|
|
5290
5306
|
// Get paginated data
|
|
5291
5307
|
const text = \`SELECT \${selectClause} FROM "\${ctx.table}" \${whereSQL} \${orderBySQL} LIMIT \${limitParam} OFFSET \${offsetParam}\`;
|
|
5292
5308
|
log.debug(\`LIST \${ctx.table} SQL:\`, text, "params:", allParams);
|
|
5293
5309
|
|
|
5294
|
-
const { rows } = await ctx.pg.query(text,
|
|
5310
|
+
const { rows } = await ctx.pg.query(text, allParams);
|
|
5295
5311
|
const parsedRows = parseVectorColumns(rows, ctx.vectorColumns);
|
|
5296
5312
|
|
|
5297
5313
|
// Calculate hasMore
|
package/dist/index.js
CHANGED
|
@@ -3218,7 +3218,9 @@ ${baseSelectType}
|
|
|
3218
3218
|
* @example Insert${Type}<{ metadata: MyMetadataType }>
|
|
3219
3219
|
*/
|
|
3220
3220
|
export type Insert${Type}<TJsonb extends Partial<_Insert${Type}Base> = {}> =
|
|
3221
|
-
|
|
3221
|
+
{} extends TJsonb
|
|
3222
|
+
? _Insert${Type}Base
|
|
3223
|
+
: Omit<_Insert${Type}Base, keyof TJsonb> & TJsonb;
|
|
3222
3224
|
|
|
3223
3225
|
/**
|
|
3224
3226
|
* Type for updating an existing ${table.name} record.
|
|
@@ -3228,7 +3230,9 @@ export type Insert${Type}<TJsonb extends Partial<_Insert${Type}Base> = {}> =
|
|
|
3228
3230
|
* @example Update${Type}<{ metadata: MyMetadataType }>
|
|
3229
3231
|
*/
|
|
3230
3232
|
export type Update${Type}<TJsonb extends Partial<_Select${Type}Base> = {}> =
|
|
3231
|
-
|
|
3233
|
+
{} extends TJsonb
|
|
3234
|
+
? Partial<_Insert${Type}Base>
|
|
3235
|
+
: Partial<Omit<_Insert${Type}Base, keyof TJsonb> & TJsonb>;
|
|
3232
3236
|
|
|
3233
3237
|
/**
|
|
3234
3238
|
* Type representing a ${table.name} record from the database.
|
|
@@ -3238,7 +3242,9 @@ export type Update${Type}<TJsonb extends Partial<_Select${Type}Base> = {}> =
|
|
|
3238
3242
|
* @example Select${Type}<{ metadata: MyMetadataType }>
|
|
3239
3243
|
*/
|
|
3240
3244
|
export type Select${Type}<TJsonb extends Partial<_Select${Type}Base> = {}> =
|
|
3241
|
-
|
|
3245
|
+
{} extends TJsonb
|
|
3246
|
+
? _Select${Type}Base
|
|
3247
|
+
: Omit<_Select${Type}Base, keyof TJsonb> & TJsonb;
|
|
3242
3248
|
`;
|
|
3243
3249
|
}
|
|
3244
3250
|
return `/**
|
|
@@ -4078,17 +4084,27 @@ function buildWhereClause(
|
|
|
4078
4084
|
paramIndex++;
|
|
4079
4085
|
break;
|
|
4080
4086
|
case '$in':
|
|
4081
|
-
if (Array.isArray(opValue)
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4087
|
+
if (Array.isArray(opValue)) {
|
|
4088
|
+
if (opValue.length > 0) {
|
|
4089
|
+
whereParts.push(\`"\${key}" = ANY($\${paramIndex})\`);
|
|
4090
|
+
whereParams.push(opValue);
|
|
4091
|
+
paramIndex++;
|
|
4092
|
+
} else {
|
|
4093
|
+
// Empty $in is logically FALSE - matches nothing
|
|
4094
|
+
whereParts.push('FALSE');
|
|
4095
|
+
}
|
|
4085
4096
|
}
|
|
4086
4097
|
break;
|
|
4087
4098
|
case '$nin':
|
|
4088
|
-
if (Array.isArray(opValue)
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4099
|
+
if (Array.isArray(opValue)) {
|
|
4100
|
+
if (opValue.length > 0) {
|
|
4101
|
+
whereParts.push(\`"\${key}" != ALL($\${paramIndex})\`);
|
|
4102
|
+
whereParams.push(opValue);
|
|
4103
|
+
paramIndex++;
|
|
4104
|
+
} else {
|
|
4105
|
+
// Empty $nin is logically TRUE - matches everything (but we still need a condition)
|
|
4106
|
+
// This is handled by simply not adding a condition
|
|
4107
|
+
}
|
|
4092
4108
|
}
|
|
4093
4109
|
break;
|
|
4094
4110
|
case '$like':
|
|
@@ -4383,14 +4399,14 @@ export async function listRecords(
|
|
|
4383
4399
|
// Get total count for pagination
|
|
4384
4400
|
const countText = \`SELECT COUNT(*) FROM "\${ctx.table}" \${countWhereSQL}\`;
|
|
4385
4401
|
log.debug(\`LIST \${ctx.table} COUNT SQL:\`, countText, "params:", countParams);
|
|
4386
|
-
const countResult = await ctx.pg.query(countText,
|
|
4402
|
+
const countResult = await ctx.pg.query(countText, countParams);
|
|
4387
4403
|
const total = parseInt(countResult.rows[0].count, 10);
|
|
4388
4404
|
|
|
4389
4405
|
// Get paginated data
|
|
4390
4406
|
const text = \`SELECT \${selectClause} FROM "\${ctx.table}" \${whereSQL} \${orderBySQL} LIMIT \${limitParam} OFFSET \${offsetParam}\`;
|
|
4391
4407
|
log.debug(\`LIST \${ctx.table} SQL:\`, text, "params:", allParams);
|
|
4392
4408
|
|
|
4393
|
-
const { rows } = await ctx.pg.query(text,
|
|
4409
|
+
const { rows } = await ctx.pg.query(text, allParams);
|
|
4394
4410
|
const parsedRows = parseVectorColumns(rows, ctx.vectorColumns);
|
|
4395
4411
|
|
|
4396
4412
|
// Calculate hasMore
|