Open lolgesten opened 6 years ago
Oh wait. It's stranger than that. It's intermittent. Running the tests over and over, sometimes it succeeds.
Could it be that the pg_temp
is not isolated per connection and we get concurrency problems between the two tests?
Hi, yeah there is some kind of problem with isolating the tables in Postgres. I think the problem is that CREATE TYPE ENUM
is not local to the (temporary) schema. Rather than bother to understand it properly I just serialized the tests like RUST_TEST_THREADS=1 cargo test --manifest-path=tests/Cargo.toml --features="postgres"
(see travis.yml). Still inexplicably fails sometimes but much more rarely.
But I would welcome a proper way to do it!
To go into more detail, when we obtain a PgConnection
, we run conn.execute("SET search_path TO pg_temp;").unwrap();
. Now pg_temp
is actually an alias to a temporary schema which by my understanding should be connection-local (see https://dba.stackexchange.com/questions/76494/temporary-schema-per-connection). Then we should be able to create types and tables isolated from other connections.
But, for whatever reason, it just don't work the way I expect.
Exciting stuff. Thanks! My problem was (obviously) not your package, but my code :D
Good to know. I'll keep this issue open to remind myself that the testing setup is an unfortunate hack.
Hi! In my code I think I have an issue with renaming of nullable enum values, so I figured I try running your tests and maybe extending them. However I didn't get that far, because I get test fails with the tests that are already there.
Is this something to do with my setup? I tried both postgres 9 and 10.