File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -94,8 +94,6 @@ pub async fn execute_command(
9494 /*
9595 * Updating all diagnostics: the changes caused by the statement execution
9696 * might affect many files.
97- *
98- * TODO: in test.sql, this seems to work after create table, but not after drop table.
9997 */
10098 session. update_all_diagnostics ( ) . await ;
10199
Original file line number Diff line number Diff line change @@ -42,7 +42,18 @@ pub async fn check_sql(params: TypecheckParams<'_>) -> Option<TypecheckDiagnosti
4242 return None ;
4343 }
4444
45- let res = params. conn . prepare ( params. sql ) . await ;
45+ let mut conn = match params. conn . acquire ( ) . await {
46+ Ok ( c) => c,
47+ Err ( _) => return None ,
48+ } ;
49+
50+ // Postgres caches prepared statements within the current DB session (connection).
51+ // This can cause issues if the underlying table schema changes while statements
52+ // are cached. By closing the connection after use, we ensure a fresh state for
53+ // each typecheck operation.
54+ conn. close_on_drop ( ) ;
55+
56+ let res = conn. prepare ( params. sql ) . await ;
4657
4758 match res {
4859 Ok ( _) => None ,
You can’t perform that action at this time.
0 commit comments