postgres-nio
postgres-nio copied to clipboard
Support simple queries, to support multiple queries in a single command
Describe the bug
When evaluating multiple insert statements in a deferred query, versions <= 1.4.4 would succeed, but >= 1.5.0 will fail with the message "cannot insert multiple commands into a prepared statement"
To Reproduce
Use postgres-nio version >= 1.5.0, and run the following on a test database:
try postgres.simpleQuery("""
CREATE TABLE test (
user_id serial PRIMARY KEY,
username VARCHAR ( 50 ) UNIQUE NOT NULL
);
""").wait()
try postgres.simpleQuery("""
SET CONSTRAINTS ALL DEFERRED;
INSERT INTO "test" ("user_id", "username") VALUES ('1', 'user1');
INSERT INTO "test" ("user_id", "username") VALUES ('2', 'user2');
INSERT INTO "test" ("user_id", "username") VALUES ('3', 'user3');
INSERT INTO "test" ("user_id", "username") VALUES ('4', 'user4');
INSERT INTO "test" ("user_id", "username") VALUES ('5', 'user5');
COMMIT;
""").wait()
Expected behavior
That it would complete successfully with the rows inserted into the table. This is the behavior in versions <= 1.4.4.
Environment
This was tested with postgres-kit v2.3.0, and varying versions of postgres-nio.
- Vapor Framework version: N/A, this was observed with only postgres-nio and postgres-kit dependencies
- Vapor Toolbox version: N/A, this was observed with only postgres-nio and postgres-kit dependencies
- OS version: macOS Big Sur v11.2.1
@NeedleInAJayStack Thanks for raising this issue. Work on this has begun: https://github.com/vapor/postgres-nio/pull/146
Thanks @fabianfett! Let me know if I can help.
I also stumbled upon this error and added a procedure in the database to be called from my web app as a (at least preliminary) solution.
Hi, is there any update on this?