-
|
With a schema like so: create table referenced_table (
id text not null primary key
);
create table referencing_table (
foreign_key text not null references referenced_table(id)
);
insert into referenced_table (id) values ('foo');and then try to insert several items with forPrepared_: forPrepared_ ["bar", "foo"] $
insertInto #referencing_table
(Values_ (Set (param @1) `as` #foreign_key))
OnConflictDoRaise
(Returning_ Nil)in a transaction, catching the thrown exceptions with Is it possible to still use prepared statements while either observing the first exception or observing all of the exceptions separately? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
Hmmm, I think you might be limited by the exceptions that Postgres itself is throwing. However, you may try experimenting with using the lower level primitive |
Beta Was this translation helpful? Give feedback.
-
|
I tried reproducing with Unfortunately I wasn't able to try The best solution I've found for now is to run the queries completely separately (e.g. |
Beta Was this translation helpful? Give feedback.
-
|
I think the problem is that the I think this might actually be fixed in 0.9.0, because you're no longer using bracket to ensure |
Beta Was this translation helpful? Give feedback.
I think the problem is that the
deallocatewhich isbracket-ed aroundexecPreparedis also failing, because the enclosing transaction is aborted and this masks the original error. https://hackage.haskell.org/package/squeal-postgresql-0.8.1.1/docs/src/Squeal.PostgreSQL.Session.html#line-158I think this might actually be fixed in 0.9.0, because you're no longer using bracket to ensure
deallocateis called.