Skip to content

Commit

Permalink
feat: add bigint to sql.join (#530)
Browse files Browse the repository at this point in the history
#529

Co-authored-by: Gajus Kuizinas <gajus@gajus.com>
  • Loading branch information
oguimbal and gajus authored Mar 22, 2024
1 parent 062bc51 commit 436a2e9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/factories/createPrimitiveValueExpressions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const createPrimitiveValueExpressions = (
): readonly PrimitiveValueExpression[] => {
const primitiveValueExpressions: Array<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
any[] | Buffer | boolean | number | string | null
any[] | Buffer | boolean | number | string | bigint | null
> = [];

for (const value of values) {
Expand All @@ -22,6 +22,7 @@ export const createPrimitiveValueExpressions = (
typeof value === 'string' ||
typeof value === 'number' ||
typeof value === 'boolean' ||
typeof value === 'bigint' ||
value === null
) {
primitiveValueExpressions.push(value);
Expand Down
13 changes: 13 additions & 0 deletions test/slonik/templateTags/sql/join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@ test('offsets positional parameter indexes', (t) => {
});
});

test('supports bigint', (t) => {
const query = sql.fragment`SELECT ${1n}, ${sql.join(
[sql.fragment`to_timestamp(${2n})`, 3n],
sql.fragment`, `,
)}, ${4n}`;

t.deepEqual(query, {
sql: 'SELECT $1, to_timestamp($2), $3, $4',
type: FragmentToken,
values: [1n, 2n, 3n, 4n],
});
});

test('nests expressions', (t) => {
const query = sql.fragment`SELECT ${sql.join(
[
Expand Down

0 comments on commit 436a2e9

Please sign in to comment.