File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
integration-tests/tests/pg Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff 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 ( ) ,
You can’t perform that action at this time.
0 commit comments