Skip to content

Commit 9d6f83f

Browse files
renovate[bot]wschurman
authored andcommitted
chore(deps): lock file maintenance
1 parent 1365b11 commit 9d6f83f

5 files changed

Lines changed: 297 additions & 359 deletions

File tree

‎packages/entity-database-adapter-knex/src/PostgresEntityDatabaseAdapter.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class PostgresEntityDatabaseAdapter<
9191
.select()
9292
.from(tableName)
9393
.whereRaw(`(??) = ANY(?)`, [
94-
tableColumns[0],
94+
tableColumns[0]!,
9595
tableTuples.map((tableTuple) => tableTuple[0]),
9696
]),
9797
);
@@ -147,7 +147,7 @@ export class PostgresEntityDatabaseAdapter<
147147
`(${orderBySpecification.columnFragment.sql}) ${orderDirection}${nullsSuffix}`,
148148
orderBySpecification.columnFragment.getKnexBindings((fieldName) =>
149149
getDatabaseFieldForEntityField(this.entityConfiguration, fieldName),
150-
),
150+
) as readonly Knex.RawBinding[],
151151
);
152152
}
153153
}
@@ -231,7 +231,7 @@ export class PostgresEntityDatabaseAdapter<
231231
sqlFragment.sql,
232232
sqlFragment.getKnexBindings((fieldName) =>
233233
getDatabaseFieldForEntityField(this.entityConfiguration, fieldName),
234-
),
234+
) as readonly Knex.RawBinding[],
235235
);
236236
}
237237

‎packages/entity-database-adapter-knex/src/SQLOperator.ts‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export type SupportedSQLValue =
1212
| Date
1313
| Buffer
1414
| bigint
15-
| undefined // Will be treated as NULL
1615
| readonly SupportedSQLValue[] // For IN clauses and array types
1716
| Readonly<{ [key: string]: unknown }>; // For JSON/JSONB columns
1817

@@ -303,7 +302,7 @@ export function sql<TFields extends Record<string, any>>(
303302
strings.forEach((string, i) => {
304303
sqlString += string;
305304
if (i < values.length) {
306-
const value = values[i];
305+
const value = values[i]!;
307306

308307
if (value instanceof SQLFragment) {
309308
// Handle nested SQL fragments
@@ -368,7 +367,7 @@ export class SQLChainableFragment<
368367
> extends SQLFragment<TFields> {
369368
/**
370369
* Generates an equality condition (`= value`).
371-
* Automatically converts `null`/`undefined` to `IS NULL`.
370+
* Automatically converts `null` to `IS NULL`.
372371
*
373372
* @param value - The value to compare against
374373
* @returns A {@link SQLFragment} representing the equality condition
@@ -382,7 +381,7 @@ export class SQLChainableFragment<
382381

383382
/**
384383
* Generates an inequality condition (`!= value`).
385-
* Automatically converts `null`/`undefined` to `IS NOT NULL`.
384+
* Automatically converts `null` to `IS NOT NULL`.
386385
*
387386
* @param value - The value to compare against
388387
* @returns A {@link SQLFragment} representing the inequality condition
@@ -635,9 +634,7 @@ type ExtractFragmentFields<T> = T extends SQLFragment<infer F> ? F : never;
635634
// Conditional value types for expression overloads.
636635
// Uses SQLChainableFragment<any, ...> so that TExpr alone drives inference (single type param).
637636
type FragmentValueNullable<TFragment> =
638-
TFragment extends SQLChainableFragment<any, infer TValue>
639-
? TValue | null | undefined
640-
: SupportedSQLValue;
637+
TFragment extends SQLChainableFragment<any, infer TValue> ? TValue | null : SupportedSQLValue;
641638

642639
type FragmentValue<TFragment> =
643640
TFragment extends SQLChainableFragment<any, infer TValue> ? TValue : SupportedSQLValue;
@@ -950,7 +947,7 @@ function isNotNullHelper<TFields extends Record<string, any>>(
950947

951948
/**
952949
* Generates an equality condition (`= value`) from a fragment.
953-
* Automatically converts `null`/`undefined` to `IS NULL`.
950+
* Automatically converts `null` to `IS NULL`.
954951
*
955952
* @param fragment - A SQLFragment or SQLChainableFragment to compare
956953
* @param value - The value to compare against
@@ -961,7 +958,7 @@ function eqHelper<TFragment extends SQLFragment<any>>(
961958
): SQLFragment<ExtractFragmentFields<TFragment>>;
962959
/**
963960
* Generates an equality condition (`= value`) from a field name.
964-
* Automatically converts `null`/`undefined` to `IS NULL`.
961+
* Automatically converts `null` to `IS NULL`.
965962
*
966963
* @param fieldName - The entity field name to compare
967964
* @param value - The value to compare against
@@ -979,7 +976,7 @@ function eqHelper<TFields extends Record<string, any>>(
979976

980977
/**
981978
* Generates an inequality condition (`!= value`) from a fragment.
982-
* Automatically converts `null`/`undefined` to `IS NOT NULL`.
979+
* Automatically converts `null` to `IS NOT NULL`.
983980
*
984981
* @param fragment - A SQLFragment or SQLChainableFragment to compare
985982
* @param value - The value to compare against
@@ -990,7 +987,7 @@ function neqHelper<TFragment extends SQLFragment<any>>(
990987
): SQLFragment<ExtractFragmentFields<TFragment>>;
991988
/**
992989
* Generates an inequality condition (`!= value`) from a field name.
993-
* Automatically converts `null`/`undefined` to `IS NOT NULL`.
990+
* Automatically converts `null` to `IS NOT NULL`.
994991
*
995992
* @param fieldName - The entity field name to compare
996993
* @param value - The value to compare against

‎packages/entity-database-adapter-knex/src/__tests__/SQLOperator-test.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,11 @@ describe('SQLOperator', () => {
258258
});
259259

260260
it('handles all SupportedSQLValue types in getDebugString', () => {
261-
const fragment = new SQLFragment('INSERT INTO test VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)', [
261+
const fragment = new SQLFragment('INSERT INTO test VALUES (?, ?, ?, ?, ?, ?, ?, ?)', [
262262
{ type: 'value', value: 'string' },
263263
{ type: 'value', value: 123 },
264264
{ type: 'value', value: true },
265265
{ type: 'value', value: null },
266-
{ type: 'value', value: undefined },
267266
{ type: 'value', value: new Date('2024-01-01T00:00:00.000Z') },
268267
{ type: 'value', value: Buffer.from('hello') },
269268
{ type: 'value', value: BigInt(999) },
@@ -272,7 +271,7 @@ describe('SQLOperator', () => {
272271

273272
const text = fragment.getDebugString();
274273
expect(text).toBe(
275-
"INSERT INTO test VALUES ('string', 123, TRUE, NULL, NULL, '2024-01-01T00:00:00.000Z', '\\x68656c6c6f', 999, ARRAY[1, 2, 3])",
274+
"INSERT INTO test VALUES ('string', 123, TRUE, NULL, '2024-01-01T00:00:00.000Z', '\\x68656c6c6f', 999, ARRAY[1, 2, 3])",
276275
);
277276
});
278277

‎packages/entity-database-adapter-knex/src/internal/EntityKnexDataManager.ts‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -480,17 +480,16 @@ export class EntityKnexDataManager<
480480
baseWhere: SQLFragment<TFields> | undefined,
481481
cursorCondition: SQLFragment<TFields> | null,
482482
): SQLFragment<TFields> {
483-
const conditions = [baseWhere, cursorCondition].filter((it) => !!it);
484-
if (conditions.length === 0) {
485-
return sql`TRUE`;
483+
if (!baseWhere) {
484+
return cursorCondition ?? sql`TRUE`;
486485
}
487-
if (conditions.length === 1) {
488-
return conditions[0]!;
486+
487+
if (!cursorCondition) {
488+
return baseWhere;
489489
}
490-
// Wrap baseWhere in parens if combining with cursor condition
491-
// We know we have exactly 2 conditions at this point
492-
const [first, second] = conditions;
493-
return sql`(${first}) AND ${second}`;
490+
491+
// Wrap baseWhere in parens when combining with cursor condition
492+
return sql`(${baseWhere}) AND ${cursorCondition}`;
494493
}
495494

496495
private augmentOrderByIfNecessary(

0 commit comments

Comments
 (0)