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

Comments

Projects
None yet
6 participants
@Razican

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

This comment has been minimized.

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

This comment has been minimized.

Member

Eijebong commented Apr 30, 2017

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

This comment has been minimized.

Thomspoon commented Apr 30, 2017

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

This comment has been minimized.

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

This comment has been minimized.

Contributor

rubdos commented Aug 5, 2017

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.

@Eijebong

This comment has been minimized.

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

This comment has been minimized.

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 Aug 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment