-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: support diesel-rs #13787
Comments
This is almost verbatim the example from https://github.com/diesel-rs/diesel/tree/3ae353c3aff8a7ea64ed6cb39b3a045ac86cd60e/examples/postgres with minor adjustments: 1. after `diesel setup`, edit the created `up.sql` and `down.sql` to contain only a trivial statement (like `SELECT 1`). This is necessary because by default they contain a [random trigger] that CockroachDB can't handle. 2. `schema.rs` was manually spelled out using the `table!` macro. The tutorial uses `infer_schema!` for which we don't have all the [internals]. Note that we use `BigInt` to properly support CockroachDB's `SERIAL` type. In turn, `struct Post` has `id: i64` instead of `i32`. 3. Some adjustments in `show_posts` to list the ID which is otherwise impossible to guess. 4. Pinned the diesel dependency for no good reason (to hopefully have this go stale later). There are likely more problems not discovered by this toy example. See the [tracking issue]. [random trigger]: https://github.com/diesel-rs/diesel/blob/master/diesel_cli/src/setup_sql/postgres/initial_setup/up.sql [internals]: cockroachdb/cockroach#8675 [tracking issue]: cockroachdb/cockroach#13787
I played with this again today and while I don't remember whether I had to add more workarounds originally, it doesn't seem so bad, in fact, it's actually usable: https://github.com/tschottdorf/cockroachdb-diesel-example I'll probably explore using the query builder portion more (not so crazy about using ORMs generally). |
Any update on this? Diesel is now at |
No updates, I'm afraid. Pull requests welcome, of course! |
But looks like we’re making progress with #21615! Thanks, @nvanbenschoten! |
I revisited this a bit today. It looks like there are a few test suites within the diesel source code. Here's how I ran them:
Here are the failures in the
|
So if I want to use CockroachDB with diesel are will I be fine if I don't run into one of the gotchas, or is it essentially not really going to work at all until these are fixed? I've got an app I'm thinking of building and I'm thinking about using CockroachDB and Diesel. It's a very simple app that will probably only have like two or three tables, mostly storing basic user information necessary to have accounts and also probably some either binary or JSON data. Is it possible that I could use Diesel with Cockroach without problems in this case? |
Hey @zicklag, although no promises because it's unsupported, it's possible that your app will work just fine. Even if you want to query JSON from Diesel, that should work okay because I see that running |
I took a whack at this today; here are my notes. @rafiss and I found what we think is a bug in cockroachdb, #58069 A couple augmentations to @jordanlewis 's instructions above:
As a next step, setting up a roachtest for diesel would let us easily triage test failures. By combining this with a command to set the Cockroach default int size to 4 bytes and using something like |
We have marked this issue as stale because it has been inactive for |
The following are known to block supporting diesel-rs.
updated_at
field; however it seems that this isn't used for anything and was added "just because")referential_constraints
, perhaps others)The list is likely incomplete, but with hacky workarounds to these I was at least able to create a simple table and read from it.
cc @cuongdo
Jira issue: CRDB-6111
The text was updated successfully, but these errors were encountered: