Skip to content

Commit 090c6e3

Browse files
committed
[int] added test
1 parent cfed15e commit 090c6e3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

integration-tests/tests/pg/common-pt1.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,27 @@ export function tests(test: Test) {
974974
expect(result).toHaveLength(1);
975975
});
976976

977+
// https://github.com/drizzle-team/drizzle-orm/issues/4468
978+
test.concurrent('prepared statement with placeholder in .where', async ({ db, push }) => {
979+
const usersTable = pgTable('users_391', {
980+
id: serial('id').primaryKey(),
981+
name: text('name').notNull(),
982+
createdAt: timestamp('created_at', { withTimezone: true }).notNull().default(sql`now()`),
983+
});
984+
985+
await push({ usersTable });
986+
await db.insert(usersTable).values({ name: 'John' });
987+
const stmt = db
988+
.select()
989+
.from(usersTable)
990+
.where(lt(usersTable.createdAt, sql`now() - interval '${sql.placeholder('timeWindow')}'`))
991+
.prepare('get_old_users');
992+
993+
const result = await stmt.execute({ timeWindow: '40 days' });
994+
995+
expect(result).toEqual([]);
996+
});
997+
977998
test.concurrent('Insert all defaults in 1 row', async ({ db, push }) => {
978999
const users = pgTable('users_42', {
9791000
id: serial('id').primaryKey(),

0 commit comments

Comments
 (0)