File tree Expand file tree Collapse file tree
print_schema/print_schema_unsigned
diesel_infer_schema/infer_schema_internals/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,11 @@ for Rust libraries in [RFC #1105](https://github.com/rust-lang/rfcs/blob/master/
1212
1313[ record-1-3-0 ] : http://docs.diesel.rs/diesel/pg/types/sql_types/struct.Record.html
1414
15+ ### Fixed
16+
17+ * ` diesel print-schema ` and ` infer_schema! ` now properly handle unsigned types
18+ in MySQL
19+
1520## [ 1.2.2] - 2018-04-12
1621
1722### Changed
Original file line number Diff line number Diff line change @@ -69,6 +69,12 @@ fn print_schema_column_renaming() {
6969 test_print_schema ( "print_schema_column_renaming" , vec ! [ "--with-docs" ] ) ;
7070}
7171
72+ #[ test]
73+ #[ cfg( feature = "mysql" ) ]
74+ fn print_schema_unsigned ( ) {
75+ test_print_schema ( "print_schema_unsigned" , vec ! [ "--with-docs" ] ) ;
76+ }
77+
7278#[ cfg( feature = "sqlite" ) ]
7379const BACKEND : & str = "sqlite" ;
7480#[ cfg( feature = "postgres" ) ]
Original file line number Diff line number Diff line change 1+ [print_schema ]
2+ file = " src/schema.rs"
3+ with_docs = true
Original file line number Diff line number Diff line change 1+ table ! {
2+ /// Representation of the `users1` table.
3+ ///
4+ /// (Automatically generated by Diesel.)
5+ users1 ( id) {
6+ /// The `id` column of the `users1` table.
7+ ///
8+ /// Its SQL type is `Unsigned<Integer>`.
9+ ///
10+ /// (Automatically generated by Diesel.)
11+ id -> Unsigned <Integer >,
12+ /// The `x` column of the `users1` table.
13+ ///
14+ /// Its SQL type is `Nullable<Unsigned<Integer>>`.
15+ ///
16+ /// (Automatically generated by Diesel.)
17+ x -> Nullable <Unsigned <Integer >>,
18+ }
19+ }
20+
21+ table ! {
22+ /// Representation of the `users2` table.
23+ ///
24+ /// (Automatically generated by Diesel.)
25+ users2 ( id) {
26+ /// The `id` column of the `users2` table.
27+ ///
28+ /// Its SQL type is `Integer`.
29+ ///
30+ /// (Automatically generated by Diesel.)
31+ id -> Integer ,
32+ }
33+ }
34+
35+ allow_tables_to_appear_in_same_query ! (
36+ users1,
37+ users2,
38+ ) ;
Original file line number Diff line number Diff line change 1+ CREATE TABLE users1 (id INTEGER UNSIGNED PRIMARY KEY , x INTEGER UNSIGNED);
2+ CREATE TABLE users2 (id INTEGER PRIMARY KEY );
Original file line number Diff line number Diff line change @@ -34,7 +34,13 @@ impl fmt::Display for ColumnType {
3434 if self . is_array {
3535 write ! ( out, "Array<" ) ?;
3636 }
37+ if self . is_unsigned {
38+ write ! ( out, "Unsigned<" ) ?;
39+ }
3740 write ! ( out, "{}" , self . rust_name) ?;
41+ if self . is_unsigned {
42+ write ! ( out, ">" ) ?;
43+ }
3844 if self . is_array {
3945 write ! ( out, ">" ) ?;
4046 }
You can’t perform that action at this time.
0 commit comments