Skip to content

Commit

Permalink
Update bitflags to v2 (#2564)
Browse files Browse the repository at this point in the history
  • Loading branch information
paolobarbolini authored Jun 30, 2023
1 parent 713da5b commit 37fdc20
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 29 deletions.
29 changes: 18 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion sqlx-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ paste = "1.0.6"
ahash = "0.8"
atoi = "2.0"

bitflags = { version = "1.3.2", default-features = false }
bytes = "1.1.0"
byteorder = { version = "1.4.3", default-features = false, features = ["std"] }
chrono = { version = "0.4.19", default-features = false, features = ["clock"], optional = true }
Expand Down
2 changes: 1 addition & 1 deletion sqlx-mysql/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ uuid = { workspace = true, optional = true }
# Misc
atoi = "2.0"
base64 = { version = "0.21.0", default-features = false, features = ["std"] }
bitflags = { version = "1.3.2", default-features = false }
bitflags = { version = "2", default-features = false, features = ["serde"] }
byteorder = { version = "1.4.3", default-features = false, features = ["std"] }
bytes = "1.1.0"
dotenvy = "0.15.5"
Expand Down
1 change: 1 addition & 0 deletions sqlx-mysql/src/protocol/capabilities.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// https://dev.mysql.com/doc/dev/mysql-server/8.0.12/group__group__cs__capabilities__flags.html
// https://mariadb.com/kb/en/library/connection/#capabilities
bitflags::bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Capabilities: u64 {
// [MariaDB] MySQL compatibility
const MYSQL = 1;
Expand Down
1 change: 1 addition & 0 deletions sqlx-mysql/src/protocol/response/status.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// https://dev.mysql.com/doc/dev/mysql-server/8.0.12/mysql__com_8h.html#a1d854e841086925be1883e4d7b4e8cad
// https://mariadb.com/kb/en/library/mariadb-connectorc-types-and-definitions/#server-status
bitflags::bitflags! {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Status: u16 {
// Is raised when a multi-statement transaction has been started, either explicitly,
// by means of BEGIN or COMMIT AND CHAIN, or implicitly, by the first
Expand Down
1 change: 1 addition & 0 deletions sqlx-mysql/src/protocol/text/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::protocol::Capabilities;

bitflags! {
#[cfg_attr(feature = "offline", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub(crate) struct ColumnFlags: u16 {
/// Field can't be `NULL`.
const NOT_NULL = 1;
Expand Down
2 changes: 1 addition & 1 deletion sqlx-postgres/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ uuid = { workspace = true, optional = true }
# Misc
atoi = "2.0"
base64 = { version = "0.21.0", default-features = false, features = ["std"] }
bitflags = { version = "1.3.2", default-features = false }
bitflags = { version = "2", default-features = false }
byteorder = { version = "1.4.3", default-features = false, features = ["std"] }
dotenvy = { workspace = true }
hex = "0.4.3"
Expand Down
3 changes: 2 additions & 1 deletion sqlx-postgres/src/types/lquery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ impl<'r> Decode<'r, Postgres> for PgLQuery {

bitflags! {
/// Modifiers that can be set to non-star labels
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct PgLQueryVariantFlag: u16 {
/// * - Match any label with this prefix, for example foo* matches foobar
const ANY_END = 0x01;
Expand Down Expand Up @@ -263,7 +264,7 @@ impl FromStr for PgLQueryVariant {
fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut label_length = s.len();
let mut rev_iter = s.bytes().rev();
let mut modifiers = PgLQueryVariantFlag { bits: 0 };
let mut modifiers = PgLQueryVariantFlag::empty();

while let Some(b) = rev_iter.next() {
match b {
Expand Down
21 changes: 11 additions & 10 deletions sqlx-postgres/src/types/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ use crate::{PgArgumentBuffer, PgHasArrayType, PgTypeInfo, PgValueFormat, PgValue

// https://github.com/postgres/postgres/blob/2f48ede080f42b97b594fb14102c82ca1001b80c/src/include/utils/rangetypes.h#L35-L44
bitflags! {
struct RangeFlags: u8 {
const EMPTY = 0x01;
const LB_INC = 0x02;
const UB_INC = 0x04;
const LB_INF = 0x08;
const UB_INF = 0x10;
const LB_NULL = 0x20; // not used
const UB_NULL = 0x40; // not used
const CONTAIN_EMPTY = 0x80; // internal
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
struct RangeFlags: u8 {
const EMPTY = 0x01;
const LB_INC = 0x02;
const UB_INC = 0x04;
const LB_INF = 0x08;
const UB_INF = 0x10;
const LB_NULL = 0x20; // not used
const UB_NULL = 0x40; // not used
const CONTAIN_EMPTY = 0x80; // internal
}
}

#[derive(Debug, PartialEq, Eq, Clone)]
Expand Down
4 changes: 1 addition & 3 deletions sqlx-sqlite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ json = ["sqlx-core/json", "serde"]
offline = ["sqlx-core/offline", "serde"]
migrate = ["sqlx-core/migrate"]

chrono = ["dep:chrono", "bitflags"]
chrono = ["dep:chrono"]
regexp = ["dep:regex"]

[dependencies]
Expand All @@ -31,8 +31,6 @@ chrono = { workspace = true, optional = true }
time = { workspace = true, optional = true }
uuid = { workspace = true, optional = true }

bitflags = { version = "1.3.2", optional = true }

url = { version = "2.2.2", default-features = false }
percent-encoding = "2.1.0"

Expand Down
3 changes: 2 additions & 1 deletion sqlx-sqlite/src/types/chrono.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt::Display;

use crate::value::ValueRef;
use crate::{
decode::Decode,
Expand All @@ -7,7 +9,6 @@ use crate::{
types::Type,
Sqlite, SqliteArgumentValue, SqliteTypeInfo, SqliteValueRef,
};
use bitflags::_core::fmt::Display;
use chrono::FixedOffset;
use chrono::{
DateTime, Local, NaiveDate, NaiveDateTime, NaiveTime, Offset, SecondsFormat, TimeZone, Utc,
Expand Down

0 comments on commit 37fdc20

Please sign in to comment.