-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[Postgres] Test and document support for Cockroach DB #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Okay, I'm not someone who uses PgSQL or CockroachDB in production, but wanted to help the project in some way, so I downloaded and ran cockroachDB and tested a few queries. I tried running the compile-time checked So far, here's how it goes with cockroachDB. When I run a simple
When I try to run an insert query (using a prepared statement, with the
I'm not sure why this error is originating, or how to fix this, but thought I'll put this out here to help test. Oh also, I ran these queries on the terminal myself and they seem to work fine. |
Postgres uses
That's potentially interesting / something we could easily fix if I can pinpoint it. Did you use master or 0.3 SQLx? |
I used 0.3, from crates.io, specifically, 0.3.5 |
I'm also getting that, for all of my queries : error: unsupported comparison operator: <oid> = <int4>
--> src/db/user.rs:79:20
|
79 | let user = sqlx::query_as!(
| ____________________^
80 | | User,
81 | | "SELECT *
82 | | FROM defaultdb.users
83 | | WHERE id = $1",
84 | | id
85 | | )
| |_________^
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) and with sqlx cli, when doing a migration that was working on postgres, I get:
I'm on sqlx 0.3 |
I'm seeing the exact same error:
|
Cockroach 20.2 just came out.
|
I’m getting the same error as @RemiKalbe when trying to use Postgres enigma with cockroach. Other than that things work fine |
Hi everyone i'm using cargo sqlx prepare(v0.5.3) for cockroach v21 and i get
i didn't use any json features |
Hello! I was playing around and got an error while inserting values into an enum column. The code works fine with Postgres, so I guess this is related to CockroachDB. sqlx: 0.5.5
use sqlx::postgres::PgPoolOptions;
use sqlx::query::Query;
use sqlx::{query, Postgres};
#[derive(Clone, Copy, Debug, sqlx::Type)]
#[sqlx(rename_all = "lowercase")]
pub enum Foobar {
One,
Two,
Three,
}
#[async_std::main]
async fn main() {
let pool = PgPoolOptions::new()
.max_connections(5)
.connect("postgres://root:root@localhost:26257/defaultdb")
.await
.unwrap();
let queries: Vec<Query<Postgres, _>> = vec![
query("CREATE TYPE Foobar as ENUM ('one', 'two', 'three')"),
query("CREATE TABLE tbl (foobar Foobar)"),
query("INSERT INTO tbl (foobar) VALUES ($1)").bind(Foobar::One),
];
for query in queries {
query.execute(&pool).await.unwrap();
}
} |
I've updated to cockroach v21.1, and it seems to be working correctly 🙌 |
I get an error saying |
you can use #1248 |
Thank you very much will try your fork for now. I hope it gets merged quickly. |
One more while running migrations:
|
Just to update, locking during migrations can be configured now, thanks to #2063 |
Hi Is there an update on this? I have created the following workaround, however I'm worried about nested transaction. Furthermore you lose the ability to work with #[tokio::test]
async fn cockroachdb_test() -> anyhow::Result<()> {
let pool = PgPool::connect("postgres://root@db:26257/defaultdb?sslmode=disable").await?;
let mut transaction = pool.begin().await?;
sqlx::query!(
r#"
CREATE DATABASE test;
"#
)
.execute(&mut *transaction)
.await?;
sqlx::query!(
r#"
USE test;
"#
)
.execute(&mut *transaction)
.await?;
migrate!()
.set_locking(false)
.run(&mut *transaction)
.await?;
test_function(transaction);
// Rollback
drop(transaction);
Ok(())
} |
Removing the following line solves the issue for CockroachDB, however this is not an ideal solution. Perhaps we are lucky enough that the bug have been fixed by PostgresSQL? If not a possible refactor of how the databases are created and stored for deletion could do the trick. |
How is this going? |
No description provided.
The text was updated successfully, but these errors were encountered: