Skip to content

Commit

Permalink
Backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1624 committed Apr 30, 2024
1 parent c6aee41 commit 6d0826b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/mysql/writer/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl ColumnInfo {
Type::Binary(str_attr) => {
match str_attr.length {
Some(length) => col_def.binary_len(length),
None => col_def.custom(MySqlType::Blob),
None => col_def.binary_len(255),
};
col_def = self.write_str_attr(col_def, str_attr);
}
Expand Down Expand Up @@ -183,7 +183,7 @@ impl ColumnInfo {
Type::Blob(blob_attr) => {
match blob_attr.length {
Some(length) => col_def.binary_len(length),
None => col_def.custom(MySqlType::Blob),
None => col_def.binary_len(255),
};
}
Type::TinyBlob => {
Expand Down
7 changes: 4 additions & 3 deletions src/sqlite/def/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,22 @@ pub fn parse_type(data_type: &str) -> Result<ColumnType, ParseIntError> {
"text" => ColumnType::Text,
"tinyint" => ColumnType::TinyInteger,
"smallint" => ColumnType::SmallInteger,
"integer" => ColumnType::Integer,
"int" | "integer" => ColumnType::Integer,
"bigint" => ColumnType::BigInteger,
"float" => ColumnType::Float,
"double" => ColumnType::Double,
"real" => ColumnType::Decimal(if parts.len() == 2 {
"decimal" | "real" => ColumnType::Decimal(if parts.len() == 2 {
Some((parts[0], parts[1]))
} else {
None
}),
"datetime_text" => ColumnType::DateTime,
"timestamp_text" => ColumnType::Timestamp,
"timestamp" | "timestamp_text" => ColumnType::Timestamp,
"timestamp_with_timezone_text" => ColumnType::TimestampWithTimeZone,
"time_text" => ColumnType::Time,
"date_text" => ColumnType::Date,
"blob" if parts.len() == 1 => ColumnType::Binary(parts[0]),
"blob" if parts.len() == 0 => ColumnType::Binary(255),
"varbinary_blob" if parts.len() == 1 => {
ColumnType::VarBinary(match parts.into_iter().next() {
Some(length) => StringLen::N(length),
Expand Down

1 comment on commit 6d0826b

@tyt2y3
Copy link
Member

@tyt2y3 tyt2y3 commented on 6d0826b Apr 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, backwards compatibility is really important.

Please sign in to comment.