Skip to content

Commit

Permalink
Added tests to all dialects
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelelz committed Dec 27, 2023
1 parent ba82dba commit 41bde97
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
23 changes: 23 additions & 0 deletions integration-tests/tests/libsql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
min,
Name,
name,
notInArray,
placeholder,
sql,
sum,
Expand Down Expand Up @@ -956,6 +957,28 @@ test.serial('select with group by complex query', async (t) => {
t.deepEqual(result, [{ name: 'Jane' }]);
});

test.serial('select with empty array in inArray', async (t) => {
const { db } = t.context;

await db.insert(usersTable).values([{ name: 'John' }, { name: 'Jane' }, { name: 'Jane' }]);

const result = await db.select({ name: usersTable.name }).from(usersTable)
.where(inArray(usersTable.id, []));

t.deepEqual(result, []);
});

test.serial('select with empty array in notInArray', async (t) => {
const { db } = t.context;

await db.insert(usersTable).values([{ name: 'John' }, { name: 'Jane' }, { name: 'Jane' }]);

const result = await db.select({ name: usersTable.name }).from(usersTable)
.where(notInArray(usersTable.id, []));

t.deepEqual(result, [{ name: 'John' }, { name: 'Jane' }, { name: 'Jane' }]);
});

test.serial('build query', async (t) => {
const { db } = t.context;

Expand Down
23 changes: 23 additions & 0 deletions integration-tests/tests/mysql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
max,
min,
Name,
notInArray,
placeholder,
sql,
sum,
Expand Down Expand Up @@ -760,6 +761,28 @@ test.serial('select with group by as column + sql', async (t) => {
t.deepEqual(result, [{ name: 'John' }, { name: 'Jane' }, { name: 'Jane' }]);
});

test.serial('select with empty array in inArray', async (t) => {
const { db } = t.context;

await db.insert(usersTable).values([{ name: 'John' }, { name: 'Jane' }, { name: 'Jane' }]);

const result = await db.select({ name: usersTable.name }).from(usersTable)
.where(inArray(usersTable.id, []));

t.deepEqual(result, []);
});

test.serial('select with empty array in notInArray', async (t) => {
const { db } = t.context;

await db.insert(usersTable).values([{ name: 'John' }, { name: 'Jane' }, { name: 'Jane' }]);

const result = await db.select({ name: usersTable.name }).from(usersTable)
.where(notInArray(usersTable.id, []));

t.deepEqual(result, [{ name: 'John' }, { name: 'Jane' }, { name: 'Jane' }]);
});

test.serial('select with group by complex query', async (t) => {
const { db } = t.context;

Expand Down
23 changes: 23 additions & 0 deletions integration-tests/tests/pg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
max,
min,
name,
notInArray,
placeholder,
type SQL,
sql,
Expand Down Expand Up @@ -1728,6 +1729,28 @@ test.serial('array types', async (t) => {
t.deepEqual(res, values);
});

test.serial('select with empty array in inArray', async (t) => {
const { db } = t.context;

await db.insert(usersTable).values([{ name: 'John' }, { name: 'Jane' }, { name: 'Jane' }]);

const result = await db.select({ name: usersTable.name }).from(usersTable)
.where(inArray(usersTable.id, []));

t.deepEqual(result, []);
});

test.serial('select with empty array in notInArray', async (t) => {
const { db } = t.context;

await db.insert(usersTable).values([{ name: 'John' }, { name: 'Jane' }, { name: 'Jane' }]);

const result = await db.select({ name: usersTable.name }).from(usersTable)
.where(notInArray(usersTable.id, []));

t.deepEqual(result, [{ name: 'John' }, { name: 'Jane' }, { name: 'Jane' }]);
});

test.serial('select for ...', (t) => {
const { db } = t.context;

Expand Down
23 changes: 23 additions & 0 deletions integration-tests/tests/postgres.js.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
lt,
Name,
name,
notInArray,
placeholder,
type SQL,
sql,
Expand Down Expand Up @@ -1318,6 +1319,28 @@ test.serial('select count w/ custom mapper', async (t) => {
t.deepEqual(res, [{ count: 2 }]);
});

test.serial('select with empty array in inArray', async (t) => {
const { db } = t.context;

await db.insert(usersTable).values([{ name: 'John' }, { name: 'Jane' }, { name: 'Jane' }]);

const result = await db.select({ name: usersTable.name }).from(usersTable)
.where(inArray(usersTable.id, []));

t.deepEqual(result, []);
});

test.serial('select with empty array in notInArray', async (t) => {
const { db } = t.context;

await db.insert(usersTable).values([{ name: 'John' }, { name: 'Jane' }, { name: 'Jane' }]);

const result = await db.select({ name: usersTable.name }).from(usersTable)
.where(notInArray(usersTable.id, []));

t.deepEqual(result, [{ name: 'John' }, { name: 'Jane' }, { name: 'Jane' }]);
});

test.serial('select for ...', (t) => {
const { db } = t.context;

Expand Down

0 comments on commit 41bde97

Please sign in to comment.