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

fix: Make rust_decimal and bigdecimal decoding more lenient #2688

Merged

Conversation

cameronbraid
Copy link
Contributor

fixes readysettech/readyset#143

When using readyset as a caching proxy - readyset returns a decimal with the following type info MySqlTypeInfo { type: Decimal, flags: ColumnFlags(0x0), char_set: 33, max_size: Some(1024) }

Currently rust_decimal and bigdecimal expect an exact match for the type info MySqlTypeInfo { type: NewDecimal, flags: ColumnFlags(BINARY), char_set: 63, max_size: None }

Therefore the following error occurs when readyset sends a valid decimal type

    error occurred while decoding column "price": mismatched types; Rust type `core::option::Option<rust_decimal::decimal::Decimal>` (as SQL type `DECIMAL`) is not compatible with SQL type `DECIMAL`

This patch makes the Type<MySql> for Decimal more lenient by matching MySqlTypeInfo that has ColumType::Decimal | ColumnType::NewDecimal to be parsed by both rust_decimal and bigdecimal types

cameronbraid added a commit to cameronbraid/readyset_seaorm_issues that referenced this pull request Aug 9, 2023
cameronbraid added a commit to cameronbraid/readyset_seaorm_issues that referenced this pull request Aug 10, 2023
PR launchbadge/sqlx#2688

split has_decimal binaries into separate files

add view_type table which contains a bool column which causes issues
@abonander
Copy link
Collaborator

@cameronbraid what is the status of this PR?

@cameronbraid
Copy link
Contributor Author

@abonander I don't know. I hope someone will review it and merge it.

@abonander
Copy link
Collaborator

@cameronbraid the commit message suggests that you were still working on the problem. If you rebase it should clear the CI error.

fixes readysettech/readyset#143

When using readyset as a caching proxy - readyset returns a decimal with the following type info `MySqlTypeInfo { type: Decimal, flags: ColumnFlags(0x0), char_set: 33, max_size: Some(1024) }`

Currently rust_decimal and bigdecimal expect an exact match for the type info `MySqlTypeInfo { type: NewDecimal, flags: ColumnFlags(BINARY), char_set: 63, max_size: None }`

Therefore the following error  occurs when readyset sends a valid decimal type

```
    error occurred while decoding column "price": mismatched types; Rust type `core::option::Option<rust_decimal::decimal::Decimal>` (as SQL type `DECIMAL`) is not compatible with SQL type `DECIMAL`
```

This patch makes the `Type<MySql> for Decimal` more lenient by matching `MySqlTypeInfo` that has ColumType::Decimal |  ColumnType::NewDecimal to be parsed by both rust_decimal and bigdecimal types
@cameronbraid
Copy link
Contributor Author

@abonander thanks, I have done the rebase. Lets see where that takes us.

@abonander abonander merged commit b91e4de into launchbadge:main Nov 7, 2023
64 checks passed
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.

MySQL DECIMAL type issue
2 participants