Skip to content

Commit 0bb67c1

Browse files
committed
Move the Tinyint type from ::mysql::data_types to ::types
The data_types module should only be for types that don't have a rust primitive type to be mapped to.
1 parent 39c1b85 commit 0bb67c1

3 files changed

Lines changed: 18 additions & 25 deletions

File tree

diesel/src/mysql/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,3 @@ pub mod types;
77
pub use self::backend::{Mysql, MysqlType};
88
pub use self::connection::MysqlConnection;
99
pub use self::query_builder::MysqlQueryBuilder;
10-
pub mod data_types {
11-
#[doc(inline)]
12-
pub use super::types::Tinyint;
13-
}

diesel/src/mysql/types/mod.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,29 @@
1-
use byteorder::WriteBytesExt;
21
#[cfg(feature = "chrono")]
32
mod date_and_time;
43

4+
use byteorder::WriteBytesExt;
55
use mysql::{Mysql, MysqlType};
66
use std::error::Error as StdError;
77
use std::io::Write;
8-
use types::{self, ToSql, IsNull, FromSql, HasSqlType};
8+
use types::{ToSql, IsNull, FromSql, HasSqlType};
99

10-
/// The tinyint SQL type. This is only available on MySQL.
11-
///
12-
/// ### [`ToSql`](/diesel/types/trait.ToSql.html) impls
13-
///
14-
/// - [`i8`][i8]
15-
///
16-
/// ### [`FromSql`](/diesel/types/trait.FromSql.html) impls
17-
///
18-
/// - [`i8`][i8]
19-
///
20-
/// [i8]: https://doc.rust-lang.org/nightly/std/primitive.i8.html
21-
#[derive(Debug, Clone, Copy, Default)] pub struct Tinyint;
10+
primitive_impls!(Tinyint -> (i8, mysql: (Tiny)));
2211

23-
impl ToSql<Tinyint, Mysql> for i8 {
12+
impl ToSql<::types::Tinyint, Mysql> for i8 {
2413
fn to_sql<W: Write>(&self, out: &mut W) -> Result<IsNull, Box<StdError+Send+Sync>> {
2514
out.write_i8(*self)
2615
.map(|_| IsNull::No)
2716
.map_err(|e| Box::new(e) as Box<StdError+Send+Sync>)
2817
}
2918
}
3019

31-
impl FromSql<types::Tinyint, Mysql> for i8 {
20+
impl FromSql<::types::Tinyint, Mysql> for i8 {
3221
fn from_sql(bytes: Option<&[u8]>) -> Result<Self, Box<StdError+Send+Sync>> {
3322
let bytes = not_none!(bytes);
3423
Ok(bytes[0] as i8)
3524
}
3625
}
3726

38-
primitive_impls!(Tinyint -> (i8, mysql: (Tiny)));
39-
4027
impl ToSql<::types::Bool, Mysql> for bool {
4128
fn to_sql<W: Write>(&self, out: &mut W) -> Result<IsNull, Box<StdError+Send+Sync>> {
4229
let int_value = if *self {

diesel/src/types/mod.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ pub mod structs {
3131
//! backend.
3232
#[cfg(feature = "postgres")]
3333
pub use pg::data_types::*;
34-
35-
#[cfg(feature = "mysql")]
36-
pub use mysql::data_types::*;
3734
}
3835
}
3936

@@ -61,6 +58,19 @@ use std::io::Write;
6158
/// [bool]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
6259
#[derive(Debug, Clone, Copy, Default)] pub struct Bool;
6360

61+
/// The tinyint SQL type. This is only available on MySQL.
62+
///
63+
/// ### [`ToSql`](/diesel/types/trait.ToSql.html) impls
64+
///
65+
/// - [`i8`][i8]
66+
///
67+
/// ### [`FromSql`](/diesel/types/trait.FromSql.html) impls
68+
///
69+
/// - [`i8`][i8]
70+
///
71+
/// [i8]: https://doc.rust-lang.org/nightly/std/primitive.i8.html
72+
#[derive(Debug, Clone, Copy, Default)] pub struct Tinyint;
73+
6474
/// The small integer SQL type.
6575
///
6676
/// ### [`ToSql`](/diesel/types/trait.ToSql.html) impls

0 commit comments

Comments
 (0)