Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd support for Uuid to SQLite #364
Comments
This comment has been minimized.
|
As far as I'm aware there is no data type in SQLite that maps to UUID? |
This comment has been minimized.
flosse
commented
Jul 1, 2016
I'm sorry. You're totally right! |
flosse
closed this
Jul 1, 2016
This comment has been minimized.
|
No there is not, but the UUID could just be (de)serialized to |
This comment has been minimized.
0xcaff
commented
May 23, 2018
•
|
I've implemented storing UUIDs in SQLite using I can make a pull request with an adaptation of this code if anyone is interested. |
This comment has been minimized.
sameer
commented
Aug 15, 2018
|
I'm interested @0xcaff, would appreciate it if you have the time to do a PR for this. |
This comment has been minimized.
0xcaff
commented
Aug 15, 2018
|
I’d like thoughts from a contributor before making a PR. Thoughts @sgrif? |
This comment has been minimized.
|
Our policy for including mappings between certain SQL types an rust types is like following:
Given that (and given that it is quite easy to write a new type wrapper for this outside of diesel) I would say that impl should not be part of diesel itself. |
This comment has been minimized.
0xcaff
commented
Aug 15, 2018
•
|
Playing devils advocate here. I'd argue that uuid is a fundamental type. Many applications use the Also, diesel/diesel/src/sql_types/mod.rs Lines 267 to 282 in 85e0007 |
This comment has been minimized.
sameer
commented
Aug 16, 2018
|
Either it should be implemented for both or none. It's misleading to implement it for If it shouldn't be, is there some way this could be provided in a standardized manner? It is odd for users to have to manually implement |
This comment has been minimized.
|
In my opinion |
This comment has been minimized.
|
We also support it because SQLite does have a ton of built-in functions for dealing with dates. Yes, it represents them as strings, but that's ultimately an implementation detail, not something relevant to whether the type exists or not. Importantly, there is a canonical way to represent a date in SQLite. That is not the true of UUIDs. We could store the raw bytes, or we could store the text representation. It's not obvious which we should choose, and we would be incompatible with existing databases when we choose one or the other. Ultimately when there's a clear representation of a type and semantically it exists for a given backend, we support it even if there's some mismatch. For example, even PG's datetime type supports a different range of dates than chrono. Given that SQLite is fully dynamically typed, if we really wanted to only support what strictly could be represented, the only type that we could support for SQLite is |
flosse commentedJul 1, 2016
It would be nice to be able to use
uuid::Uuidwithin the structs in combination of SQLite!