Diesel currently supports only the main MySQL data types, defined here. In that documentation page the MySQL documentation is linked, were it can be seen that there are more types (MEDIUMINT, DECIMAL, VARCHAR, VARBINARY, TINYBLOB, TINYTEXT, MEDIUMBLOB, MEDIUMTEXT, LONGBLOB, LONGTEXT and BIT) that are not supported by the current implementation.
Trying to use these types gives these errors:
error[E0412]: cannot find type `Mediumint` in this scope
--> src/db/schema.rs:3:1
|
3 | infer_schema!("dotenv:DATABASE_URL");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
|
= note: this error originates in a macro outside of the current crate
error[E0412]: cannot find type `Decimal` in this scope
--> src/db/schema.rs:3:1
|
3 | infer_schema!("dotenv:DATABASE_URL");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
|
= note: this error originates in a macro outside of the current crate
Reported in Rust user's forum here.
Since the diesel_infer_schema seems to only work off of the default SQL types, this might require some direction on how a maintainer can help out.
edit: I have a custom U24 struct for Mediumint, and BIT is the same as TINYINT(1), which is already handled by the code so a pub type could be used there to finish that one.
The Decimal type is currently being implemented for postgres in #837. I'll probably implement it for MySQL once it's done for pg.
mediumint cannot be deserialized as is since there is not i24 type. Would considering it as an integer be ok ? @sgrif
I figured primitives were the only acceptable types. If mediumint could just be a i32, that would solve a lot of problems at the expense of one byte per use.
We can implement FromSql<MediumInt> for i32, but not ToSql. It'd be similar to the situation with Timestamptz where we allow things like DateTime<Local> in ToSql but not FromSql. I think the situation for MediumInt would be significantly more painful however, since there would be no type which would implement both ToSql and FromSql for it.
Task list, to keep track:
Feel free to copy this comment in the top. IMO, this makes it easier to keep track of the issue :-)
edit: Mmm, nevermind. Seems like only MEDIUMINT is missing.
Yeah, and we can't add support for it as there is no type in rust to serialize/deserialize it.
The only type left is mediumint which we aren't going to support. Closing this.
Most helpful comment
The only type left is mediumint which we aren't going to support. Closing this.