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

Give a more specific error message for unsigned types #757

Closed
wants to merge 1 commit into from

Conversation

sgrif
Copy link
Member

@sgrif sgrif commented Feb 24, 2017

We don't yet support these types in MySQL, but the error a user will
recieve is not terribly helpful, since the type will contain a space so
the table! macro invocation will just have bad tokens.

This gives a more specific error message for unsigned types, as well as
ensuring that we get a reasonable error for other types would result in
a bad macro invocation. (I'm not actually aware of any other types which
have a space, but I'd rather not dig through the entire manual right
now)

In theory we could exclude unsigned floats from this, since unsigned
floats aren't actually a thing and that "type" in MySQL is basically
just a check constraint, but I'd rather hold off and actually represent
in Diesel that the type is different when we add support for unsigned
integer types.

Fixes #754.

@sgrif sgrif requested a review from killercup February 24, 2017 16:38
@sgrif sgrif force-pushed the sg-unsigned-error branch 2 times, most recently from 711ecec to b4d3c01 Compare February 24, 2017 19:50
Copy link
Member

@killercup killercup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

let column_type = match determine_column_type(column, connection) {
Ok(t) => t,
Err(e) => return Err(format!(
"Error determining type of {}.{}: {}",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some back ticks?

We don't yet support these types in MySQL, but the error a user will
recieve is not terribly helpful, since the type will contain a space so
the `table!` macro invocation will just have bad tokens.

This gives a more specific error message for unsigned types, as well as
ensuring that we get a reasonable error for other types would result in
a bad macro invocation. (I'm not actually aware of any other types which
have a space, but I'd rather not dig through the entire manual right
now)

In theory we could exclude unsigned floats from this, since unsigned
floats aren't actually a thing and that "type" in MySQL is basically
just a check constraint, but I'd rather hold off and actually represent
in Diesel that the type is different when we add support for unsigned
integer types.

Fixes #754.
@sgrif sgrif closed this Feb 25, 2017
@sgrif sgrif deleted the sg-unsigned-error branch February 25, 2017 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants