Skip to content

Commit a2b3a22

Browse files
authored
Merge pull request #501 from mibac138/master
Support uuid v0.8 and update dependencies
2 parents 7a95f6a + 9a83196 commit a2b3a22

File tree

12 files changed

+78
-17
lines changed

12 files changed

+78
-17
lines changed

codegen/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
authors = ["Steven Fackler <[email protected]>"]
55

66
[dependencies]
7-
phf_codegen = "0.7.22"
8-
regex = "0.1"
7+
phf_codegen = "0.8"
8+
regex = "1.3.1"
99
marksman_escape = "0.1"
10-
linked-hash-map = "0.4"
10+
linked-hash-map = "0.5"

codegen/src/sqlstate.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,15 @@ fn make_consts(codes: &LinkedHashMap<String, Vec<String>>, file: &mut BufWriter<
8282
}
8383

8484
fn make_map(codes: &LinkedHashMap<String, Vec<String>>, file: &mut BufWriter<File>) {
85-
write!(
86-
file,
87-
"
88-
#[rustfmt::skip]
89-
static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = "
90-
)
91-
.unwrap();
9285
let mut builder = phf_codegen::Map::new();
9386
for (code, names) in codes {
9487
builder.entry(&**code, &format!("SqlState::{}", &names[0]));
9588
}
96-
builder.build(file).unwrap();
97-
writeln!(file, ";").unwrap();
89+
write!(
90+
file,
91+
"
92+
#[rustfmt::skip]
93+
static SQLSTATE_MAP: phf::Map<&'static str, SqlState> = \n{};\n",
94+
builder.build()
95+
).unwrap();
9896
}

postgres-protocol/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ base64 = "0.10"
1313
byteorder = "1.0"
1414
bytes = "0.4"
1515
fallible-iterator = "0.2"
16-
generic-array = "0.12"
16+
generic-array = "0.13"
1717
hmac = "0.7"
1818
md5 = "0.6"
1919
memchr = "2.0"
20-
rand = "0.6"
20+
rand = "0.7"
2121
sha2 = "0.8"
2222
stringprep = "0.1"

postgres-types/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ with-eui48-0_4 = ["eui48-04"]
1818
with-geo-types-0_4 = ["geo-types-04"]
1919
with-serde_json-1 = ["serde-1", "serde_json-1"]
2020
with-uuid-0_7 = ["uuid-07"]
21+
with-uuid-0_8 = ["uuid-08"]
2122

2223
[dependencies]
2324
bytes = "0.4"
@@ -32,3 +33,4 @@ geo-types-04 = { version = "0.4", package = "geo-types", optional = true }
3233
serde-1 = { version = "1.0", package = "serde", optional = true }
3334
serde_json-1 = { version = "1.0", package = "serde_json", optional = true }
3435
uuid-07 = { version = "0.7", package = "uuid", optional = true }
36+
uuid-08 = { version = "0.8", package = "uuid", optional = true }

postgres-types/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ mod geo_types_04;
200200
mod serde_json_1;
201201
#[cfg(feature = "with-uuid-0_7")]
202202
mod uuid_07;
203+
#[cfg(feature = "with-uuid-0_8")]
204+
mod uuid_08;
203205

204206
#[doc(hidden)]
205207
pub mod private;

postgres-types/src/uuid_08.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use bytes::BytesMut;
2+
use postgres_protocol::types;
3+
use std::error::Error;
4+
use uuid_08::Uuid;
5+
6+
use crate::{FromSql, IsNull, ToSql, Type};
7+
8+
impl<'a> FromSql<'a> for Uuid {
9+
fn from_sql(_: &Type, raw: &[u8]) -> Result<Uuid, Box<dyn Error + Sync + Send>> {
10+
let bytes = types::uuid_from_sql(raw)?;
11+
Ok(Uuid::from_bytes(bytes))
12+
}
13+
14+
accepts!(UUID);
15+
}
16+
17+
impl ToSql for Uuid {
18+
fn to_sql(&self, _: &Type, w: &mut BytesMut) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
19+
types::uuid_to_sql(*self.as_bytes(), w);
20+
Ok(IsNull::No)
21+
}
22+
23+
accepts!(UUID);
24+
to_sql_checked!();
25+
}

postgres/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## Unreleased
4+
5+
### Added
6+
* Added support for converting to and from `uuid` crate v0.8
7+
38
## v0.17.0-alpha.1 - 2019-10-14
49

510
### Changed

postgres/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ with-eui48-0_4 = ["tokio-postgres/with-eui48-0_4"]
2626
with-geo-types-0_4 = ["tokio-postgres/with-geo-types-0_4"]
2727
with-serde_json-1 = ["tokio-postgres/with-serde_json-1"]
2828
with-uuid-0_7 = ["tokio-postgres/with-uuid-0_7"]
29+
with-uuid-0_8 = ["tokio-postgres/with-uuid-0_8"]
2930

3031
[dependencies]
3132
bytes = "0.4"

tokio-postgres/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change Log
22

3+
## Unreleased
4+
5+
### Added
6+
* Added support for converting to and from `uuid` crate v0.8
7+
38
## v0.5.0-alpha.1 - 2019-10-14
49

510
### Changed

tokio-postgres/Cargo.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,24 @@ with-eui48-0_4 = ["postgres-types/with-eui48-0_4"]
3333
with-geo-types-0_4 = ["postgres-types/with-geo-types-0_4"]
3434
with-serde_json-1 = ["postgres-types/with-serde_json-1"]
3535
with-uuid-0_7 = ["postgres-types/with-uuid-0_7"]
36+
with-uuid-0_8 = ["postgres-types/with-uuid-0_8"]
3637

3738
[dependencies]
3839
bytes = "0.4"
3940
fallible-iterator = "0.2"
4041
futures-preview = { version = "=0.3.0-alpha.19", features = ["async-await"] }
4142
log = "0.4"
4243
parking_lot = "0.9"
43-
percent-encoding = "1.0"
44+
percent-encoding = "2.0"
4445
pin-project = "0.4"
45-
phf = "0.7.23"
46+
phf = "0.8"
4647
postgres-protocol = { version = "=0.5.0-alpha.1", path = "../postgres-protocol" }
4748
postgres-types = { version = "=0.1.0-alpha.1", path = "../postgres-types" }
4849
tokio = { version = "=0.2.0-alpha.6", default-features = false, features = ["io", "codec"] }
4950

5051
[dev-dependencies]
5152
tokio = "=0.2.0-alpha.6"
52-
env_logger = "0.5"
53+
env_logger = "0.7"
5354
criterion = "0.3"
5455

5556
bit-vec-06 = { version = "0.6", package = "bit-vec" }
@@ -59,3 +60,5 @@ geo-types-04 = { version = "0.4", package = "geo-types" }
5960
serde-1 = { version = "1.0", package = "serde" }
6061
serde_json-1 = { version = "1.0", package = "serde_json" }
6162
uuid-07 = { version = "0.7", package = "uuid" }
63+
uuid-08 = { version = "0.8", package = "uuid" }
64+

0 commit comments

Comments
 (0)