Skip to content

Commit

Permalink
Added test for passing Date object to postgres-js serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
gp27 committed Aug 27, 2024
1 parent c8359a1 commit 8eda7e5
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions integration-tests/tests/pg/postgres-js.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,33 @@ test('test mode string for timestamp with timezone in different timezone', async
await db.execute(sql`drop table if exists ${table}`);
});

test('date object passed to sql tagged function', async () => {
const table = pgTable('all_columns', {
id: serial('id').primaryKey(),
timestamp: timestamp('timestamp_string', { mode: 'date', precision: 3 }).notNull(),
});

await db.execute(sql`drop table if exists ${table}`);

await db.execute(sql`
create table ${table} (
id serial primary key,
timestamp_string timestamp(3) not null
)
`);

const queryDate = new Date('2022-01-01 02:00:00.123456');

const result = db.execute<{
id: number;
timestamp_string: string;
}>(sql`select * from ${table} where ${table.timestamp} = ${queryDate}`);

expect(result).to.not.throw();

await db.execute(sql`drop table if exists ${table}`);
});

skipTests([
'migrator : default migration strategy',
'migrator : migrate with custom schema',
Expand Down

0 comments on commit 8eda7e5

Please sign in to comment.