Skip to content
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

No support for some MySQL data types #830

Closed
Razican opened this issue Mar 29, 2017 · 7 comments
Closed

No support for some MySQL data types #830

Razican opened this issue Mar 29, 2017 · 7 comments

Comments

@Razican
Copy link
Member

Razican commented Mar 29, 2017

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.

@Thomspoon
Copy link

Thomspoon commented Apr 30, 2017

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.

@Eijebong
Copy link
Member

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

@Thomspoon
Copy link

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.

@sgrif
Copy link
Member

sgrif commented May 1, 2017

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.

@rubdos
Copy link
Contributor

rubdos commented Aug 5, 2017

@Eijebong
Copy link
Member

Eijebong commented Aug 5, 2017

Yeah, and we can't add support for it as there is no type in rust to serialize/deserialize it.

@sgrif
Copy link
Member

sgrif commented Aug 5, 2017

The only type left is mediumint which we aren't going to support. Closing this.

@sgrif sgrif closed this as completed Aug 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants