SQLite custom type support #4654
-
Hello, I am a new developper to SQLite, Rust and Diesel. From my understanding, it is possible to create a table in SQLite with the following query, with custom types that are internally stored by SQLite as a type that it recognizes: When I try to do this for diesel, running a migration for the creation of this table, the initial creation of the table works, but running the I know the usual solution would be to modify the SQL create query to be a type directly supported by SQLite, but I was wondering if there is a workaround solution for these custom types. The reason I am asking this is because I am working on a sqlite database (containing such custom SQLite types) that has already been created by other developers (who did not use Diesel to build its content) and I wanted to use diesel print-schema on it. This is a first step to my project, and I will probably replicate the creation of the database later on using diesel, but I still wanted to start off with this, if it is indeed possible. When I was looking at the documentation, I did read up on the sql_types module and the possibility to implement a custom sql type, but from my understanding this is relevant to how you want to represent the SQL data in Rust (on the Diesel side) and therefore not really relevant to my problem. I hope I was clear, and thanks in advance for your feedback! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
At the time of writing diesel/diesel_cli/src/infer_schema_internals/sqlite.rs Lines 322 to 379 in 58be152 The only workaround that comes to my mind is to filter out the relevant tables via the CLI flags and later manually write a Now we have some ideas how to make this mapping more flexible by essentially let users specify/customize it via their diesel.toml file. That's nothing we've started to implement yet, and at least I personally do unfortunately also not have the capacity to do that yet. |
Beta Was this translation helpful? Give feedback.
At the time of writing
diesel print-schema
(and any other subcommand of the CLI tool that emits the schema astable!
macro) does not support this as it uses a hard coded list of types. You can find this list here:diesel/diesel_cli/src/infer_schema_internals/sqlite.rs
Lines 322 to 379 in 58be152