Skip to content

Commit

Permalink
Removed collation from constants module
Browse files Browse the repository at this point in the history
Removed UTF8 and UTF8MB4 collation from the constants module and used
the collation module instead.
  • Loading branch information
altmannmarcelo committed May 10, 2024
1 parent f15612b commit a5b3530
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
12 changes: 9 additions & 3 deletions src/binlog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ mod tests {

use crate::{
binlog::{events::RowsEventData, value::BinlogValue},
collations::CollationID,
constants::ColumnFlags,
proto::MySerialize,
value::Value,
Expand Down Expand Up @@ -784,9 +785,14 @@ mod tests {
assert_eq!(col.flags(), f);
}

for (col, charset) in columns.iter().zip([0, 45, 45, 63, 0])
{
assert_eq!(col.character_set(), charset);
for (col, charset) in columns.iter().zip([
CollationID::UNKNOWN_COLLATION_ID,
CollationID::UTF8MB4_GENERAL_CI,
CollationID::UTF8MB4_GENERAL_CI,
CollationID::BINARY,
CollationID::UNKNOWN_COLLATION_ID,
]) {
assert_eq!(col.character_set(), charset as u16);
}
}
}
Expand Down
13 changes: 8 additions & 5 deletions src/packets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ use std::{
borrow::Cow, cmp::max, collections::HashMap, convert::TryFrom, fmt, io, marker::PhantomData,
};

use crate::collations::CollationID;
use crate::{
constants::{
CapabilityFlags, ColumnFlags, ColumnType, Command, CursorType, SessionStateType,
StatusFlags, StmtExecuteParamFlags, StmtExecuteParamsFlags, MAX_PAYLOAD_LEN,
UTF8MB4_GENERAL_CI, UTF8_GENERAL_CI,
},
io::{BufMutExt, ParseBuf},
misc::{
Expand Down Expand Up @@ -2030,9 +2030,9 @@ impl<'a> HandshakeResponse<'a> {
Self {
scramble_buf,
collation: if server_version >= (5, 5, 3) {
RawInt::new(UTF8MB4_GENERAL_CI as u8)
RawInt::new(CollationID::UTF8MB4_GENERAL_CI as u8)
} else {
RawInt::new(UTF8_GENERAL_CI as u8)
RawInt::new(CollationID::UTF8MB3_GENERAL_CI as u8)
},
user: user.map(RawBytes::new).unwrap_or_default(),
db_name: db_name.map(RawBytes::new),
Expand Down Expand Up @@ -3414,7 +3414,7 @@ impl<'de> MyDeserialize<'de> for SemiSyncAckPacket<'de> {
mod test {
use super::*;
use crate::{
constants::{CapabilityFlags, ColumnFlags, ColumnType, StatusFlags, UTF8_GENERAL_CI},
constants::{CapabilityFlags, ColumnFlags, ColumnType, StatusFlags},
proto::{MyDeserialize, MySerialize},
};

Expand Down Expand Up @@ -3670,7 +3670,10 @@ mod test {
assert_eq!(column.org_table_str(), "org_table");
assert_eq!(column.name_str(), "name");
assert_eq!(column.org_name_str(), "org_name");
assert_eq!(column.character_set(), UTF8_GENERAL_CI);
assert_eq!(
column.character_set(),
CollationID::UTF8MB3_GENERAL_CI as u16
);
assert_eq!(column.column_length(), 15);
assert_eq!(column.column_type(), ColumnType::MYSQL_TYPE_DECIMAL);
assert_eq!(column.flags(), ColumnFlags::NOT_NULL_FLAG);
Expand Down

0 comments on commit a5b3530

Please sign in to comment.