Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
217dd1a
Change MySQL's number handling to be more permissive
sgrif Jan 7, 2018
a16c576
Allow dead code in mysql if chrono feature is disabled
weiznich Feb 17, 2020
5b80a18
Improve type mapping in mysql backend
weiznich Feb 17, 2020
3cc4192
Only convert the mysql ffi type if it's not null
weiznich Feb 18, 2020
b285e5c
Improve conversion of the received mysql value bytes to MYSQL_TIME
weiznich Feb 19, 2020
4cd1db8
Improve the conversion from decimal to various integer types in the
weiznich Feb 20, 2020
de0b452
Write some bind tests for mysql
weiznich May 11, 2020
2facb24
Try to cleanup mysql type metadata implementation
weiznich May 15, 2020
d1eed7c
More type fixes
weiznich May 16, 2020
0b6c61e
Enable json support for mysql
weiznich May 16, 2020
2300231
Fix CI
weiznich Jun 2, 2020
6ea97a3
Fix and test the json support for mysql as well
weiznich Jun 3, 2020
67aceb2
Rustfmt
weiznich Jun 3, 2020
8325d51
Fix custom types example
weiznich Jun 3, 2020
6ac48a7
Try to fix json handling for mysql 8.0
weiznich Jun 3, 2020
94e66ed
Update ci to ubuntu 20.04 to get hopefully a newer mysql version
weiznich Jun 3, 2020
1b0453f
Fix #2373
weiznich Jun 4, 2020
54ffbf3
Add a changelog entry for mysql value change
weiznich Jun 5, 2020
db56fce
Add a comment clarifying why we have a own variant of `MYSQL_TIME`
weiznich Jun 5, 2020
5668b75
Improve the documentation for `MysqlType`
weiznich Jun 5, 2020
f94495a
Some cleanup and minor style improvments for changes in binds.rs
weiznich Jun 5, 2020
1d46c44
Add back default features
weiznich Jun 5, 2020
9ad9558
Address review comments
weiznich Jun 8, 2020
f783850
Unify changelog entries regarding to `MysqlType`
weiznich Jun 10, 2020
a1d71bb
Remove a few debug annotations from prototypeing
weiznich Jun 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
matrix:
rust: ["stable", "beta", "nightly"]
backend: ["postgres", "sqlite", "mysql"]
os: [ubuntu-18.04, macos-latest, windows-latest]
os: [ubuntu-20.04, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
Expand Down
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/
[raw-value-2-0-0]: http://docs.diesel.rs/diesel/backend/type.RawValue.html

* The type metadata for MySQL has been changed to include sign information. If
you are implementing `HasSqlType` for `Mysql` manually, or manipulating a
`Mysql::TypeMetadata`, you will need to take the new struct
`MysqlTypeMetadata` instead.
you are implementing `HasSqlType` for `Mysql` manually, you may need to adjust
your implementation to fully use the new unsigned variants in `MysqlType`

* The minimal officially supported rustc version is now 1.40.0

Expand Down Expand Up @@ -94,6 +93,7 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/
`#[non_exhaustive]`. If you matched on one of those variants explicitly you need to
introduce a wild card match instead.


### Fixed

* Many types were incorrectly considered non-aggregate when they should not
Expand Down Expand Up @@ -127,6 +127,8 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/

[the SQLite URI documentation]: https://www.sqlite.org/uri.html

* We've refactored our type translation layer for Mysql to handle more types now.

### Deprecated

* `diesel_(prefix|postfix|infix)_operator!` have been deprecated. These macros
Expand Down
2 changes: 1 addition & 1 deletion diesel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ huge-tables = ["64-column-tables"]
128-column-tables = ["64-column-tables"]
postgres = ["pq-sys", "bitflags", "diesel_derives/postgres"]
sqlite = ["libsqlite3-sys", "diesel_derives/sqlite"]
mysql = ["mysqlclient-sys", "url", "percent-encoding", "diesel_derives/mysql"]
mysql = ["mysqlclient-sys", "url", "percent-encoding", "diesel_derives/mysql", "bitflags"]
with-deprecated = []
deprecated-time = ["time"]
network-address = ["ipnetwork", "libc"]
Expand Down
68 changes: 33 additions & 35 deletions diesel/src/mysql/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,56 +12,54 @@ use crate::sql_types::TypeMetadata;
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct Mysql;

/// The full type metadata for MySQL
///
/// This includes the type of the value, and whether it is signed.
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
pub struct MysqlTypeMetadata {
/// The underlying data type
///
/// Affects the `buffer_type` sent to libmysqlclient
pub data_type: MysqlType,

/// Is this type signed?
///
/// Affects the `is_unsigned` flag sent to libmysqlclient
pub is_unsigned: bool,
}

#[allow(missing_debug_implementations)]
/// Represents the possible forms a bind parameter can be transmitted as.
/// Each variant represents one of the forms documented at
/// <https://dev.mysql.com/doc/refman/5.7/en/c-api-prepared-statement-type-codes.html>
///
/// The null variant is omitted, as we will never prepare a statement in which
/// one of the bind parameters can always be NULL
/// Represents possible types, that can be transmitted as via the
/// Mysql wire protocol
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
#[non_exhaustive]
pub enum MysqlType {
/// Sets `buffer_type` to `MYSQL_TYPE_TINY`
/// A 8 bit signed integer
Tiny,
/// Sets `buffer_type` to `MYSQL_TYPE_SHORT`
/// A 8 bit unsigned integer
UnsignedTiny,
/// A 16 bit signed integer
Short,
/// Sets `buffer_type` to `MYSQL_TYPE_LONG`
/// A 16 bit unsigned integer
UnsignedShort,
/// A 32 bit signed integer
Long,
/// Sets `buffer_type` to `MYSQL_TYPE_LONGLONG`
/// A 32 bit unsigned integer
UnsignedLong,
/// A 64 bit signed integer
LongLong,
/// Sets `buffer_type` to `MYSQL_TYPE_FLOAT`
/// A 64 bit unsigned integer
UnsignedLongLong,
/// A 32 bit floating point number
Float,
/// Sets `buffer_type` to `MYSQL_TYPE_DOUBLE`
/// A 64 bit floating point number
Double,
/// Sets `buffer_type` to `MYSQL_TYPE_TIME`
/// A fixed point decimal value
Numeric,
/// A datatype to store a time value
Time,
/// Sets `buffer_type` to `MYSQL_TYPE_DATE`
/// A datatype to store a date value
Date,
/// Sets `buffer_type` to `MYSQL_TYPE_DATETIME`
/// A datatype containing timestamp values ranging from
/// '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.
DateTime,
/// Sets `buffer_type` to `MYSQL_TYPE_TIMESTAMP`
/// A datatype containing timestamp values ranging from
/// 1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.
Timestamp,
/// Sets `buffer_type` to `MYSQL_TYPE_STRING`
/// A datatype for string values
String,
/// Sets `buffer_type` to `MYSQL_TYPE_BLOB`
/// A datatype containing binary large objects
Blob,
/// A value containing a set of bit's
Bit,
/// A user defined set type
Set,
/// A user defined enum type
Enum,
}

impl Backend for Mysql {
Expand All @@ -75,7 +73,7 @@ impl<'a> HasRawValue<'a> for Mysql {
}

impl TypeMetadata for Mysql {
type TypeMetadata = MysqlTypeMetadata;
type TypeMetadata = MysqlType;
type MetadataLookup = ();
}

Expand Down
Loading