Skip to content

Commit ecd22fb

Browse files
authored
Merge pull request #3186 from weiznich/fix/allow_mysql_tables_with_datetime_and_json_sql_types
Allow mysql schemas that contain either a json or a datatime field
2 parents b51e658 + 5282adb commit ecd22fb

File tree

5 files changed

+43
-0
lines changed

5 files changed

+43
-0
lines changed

diesel_cli/src/print_schema.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ fn mysql_diesel_types() -> HashSet<&'static str> {
144144

145145
types.insert("TinyInt");
146146
types.insert("Tinyint");
147+
types.insert("Datetime");
148+
types.insert("Json");
147149
types
148150
}
149151

diesel_cli/tests/print_schema.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ fn print_schema_unsigned() {
124124
test_print_schema("print_schema_unsigned", vec!["--with-docs"]);
125125
}
126126

127+
#[test]
128+
#[cfg(feature = "mysql")]
129+
fn print_schema_datetime_for_mysql() {
130+
test_print_schema("print_schema_datetime_for_mysql", vec!["--with-docs"]);
131+
}
132+
127133
#[test]
128134
#[cfg(not(windows))]
129135
fn print_schema_patch_file() {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[print_schema]
2+
file = "src/schema.rs"
3+
with_docs = true
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// @generated automatically by Diesel CLI.
2+
3+
diesel::table! {
4+
/// Representation of the `users` table.
5+
///
6+
/// (Automatically generated by Diesel.)
7+
users (id) {
8+
/// The `id` column of the `users` table.
9+
///
10+
/// Its SQL type is `Integer`.
11+
///
12+
/// (Automatically generated by Diesel.)
13+
id -> Integer,
14+
/// The `datetime` column of the `users` table.
15+
///
16+
/// Its SQL type is `Datetime`.
17+
///
18+
/// (Automatically generated by Diesel.)
19+
datetime -> Datetime,
20+
/// The `nullable_datetime` column of the `users` table.
21+
///
22+
/// Its SQL type is `Nullable<Datetime>`.
23+
///
24+
/// (Automatically generated by Diesel.)
25+
nullable_datetime -> Nullable<Datetime>,
26+
}
27+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CREATE TABLE users (
2+
id INTEGER PRIMARY KEY,
3+
datetime DATETIME NOT NULL,
4+
nullable_datetime DATETIME
5+
);

0 commit comments

Comments
 (0)