Skip to content

Commit 5809f86

Browse files
committed
Merge remote-tracking branch 'origin/ab/bigdecimal'
2 parents dfb313f + 33677e8 commit 5809f86

File tree

18 files changed

+624
-30
lines changed

18 files changed

+624
-30
lines changed

.github/workflows/rust.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,25 @@ jobs:
3939

4040
# check w/deny warnings in sqlx-core: async-std
4141
- working-directory: sqlx-core
42-
run: cargo rustc --no-default-features --features 'chrono uuid postgres mysql tls runtime-async-std' -- -D warnings --emit=metadata
42+
run: cargo rustc --no-default-features --features 'bigdecimal_bigint chrono uuid postgres mysql tls runtime-async-std' -- -D warnings --emit=metadata
4343

4444
# check w/deny warnings in sqlx-core: tokio
4545
# `cargo rustc -p sqlx-core` ignores `--no-default-features` and builds with `runtime-async-std` anyway
4646
# https://github.com/rust-lang/cargo/issues/5364
4747
- working-directory: sqlx-core
48-
run: cargo rustc --no-default-features --features 'chrono uuid postgres mysql tls runtime-tokio' -- -D warnings --emit=metadata
48+
run: cargo rustc --no-default-features --features 'bigdecimal_bigint chrono uuid postgres mysql tls runtime-tokio' -- -D warnings --emit=metadata
4949

5050
# check w/deny warnings: async-std
51-
- run: cargo rustc --no-default-features --features 'chrono uuid postgres mysql macros tls runtime-async-std' -- -D warnings --emit=metadata
51+
- run: cargo rustc --no-default-features --features 'bigdecimal chrono uuid postgres mysql macros tls runtime-async-std' -- -D warnings --emit=metadata
5252

5353
# check w/deny warnings: tokio
54-
- run: cargo rustc --no-default-features --features 'chrono uuid postgres mysql macros tls runtime-tokio' -- -D warnings --emit=metadata
54+
- run: cargo rustc --no-default-features --features 'bigdecimal chrono uuid postgres mysql macros tls runtime-tokio' -- -D warnings --emit=metadata
5555

5656
# unit test: async-std
57-
- run: cargo test --manifest-path sqlx-core/Cargo.toml --no-default-features --features 'chrono uuid postgres mysql tls runtime-async-std'
57+
- run: cargo test --manifest-path sqlx-core/Cargo.toml --no-default-features --features 'bigdecimal chrono uuid postgres mysql tls runtime-async-std'
5858

5959
# unit test: tokio
60-
- run: cargo test --manifest-path sqlx-core/Cargo.toml --no-default-features --features 'chrono uuid postgres mysql tls runtime-tokio'
60+
- run: cargo test --manifest-path sqlx-core/Cargo.toml --no-default-features --features 'bigdecimal chrono uuid postgres mysql tls runtime-tokio'
6161

6262
# integration test: sqlite + async-std
6363
- run: cargo test --no-default-features --features 'runtime-async-std sqlite macros uuid chrono tls'
@@ -121,22 +121,22 @@ jobs:
121121
# -----------------------------------------------------
122122

123123
# integration test: async-std
124-
- run: cargo test --no-default-features --features 'runtime-async-std postgres macros uuid chrono tls'
124+
- run: cargo test --no-default-features --features 'runtime-async-std postgres macros uuid chrono bigdecimal tls'
125125
env:
126126
DATABASE_URL: postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres
127127

128128
# integration test: tokio
129-
- run: cargo test --no-default-features --features 'runtime-tokio postgres macros uuid chrono tls'
129+
- run: cargo test --no-default-features --features 'runtime-tokio postgres macros uuid chrono bigdecimal tls'
130130
env:
131131
DATABASE_URL: postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres
132132

133133
# UI feature gate tests: async-std
134-
- run: cargo test --no-default-features --features 'runtime-async-std postgres macros tls'
134+
- run: cargo test --no-default-features --features 'runtime-async-std postgres macros bigdecimal tls'
135135
env:
136136
DATABASE_URL: postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres
137137

138138
# UI feature gate tests: tokio
139-
- run: cargo test --no-default-features --features 'runtime-tokio postgres macros tls'
139+
- run: cargo test --no-default-features --features 'runtime-tokio postgres macros bigdecimal tls'
140140
env:
141141
DATABASE_URL: postgres://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres
142142

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ mysql = [ "sqlx-core/mysql", "sqlx-macros/mysql" ]
4646
sqlite = [ "sqlx-core/sqlite", "sqlx-macros/sqlite" ]
4747

4848
# types
49+
bigdecimal = ["sqlx-core/bigdecimal_bigint", "sqlx-macros/bigdecimal"]
4950
chrono = [ "sqlx-core/chrono", "sqlx-macros/chrono" ]
5051
uuid = [ "sqlx-core/uuid", "sqlx-macros/uuid" ]
5152

sqlx-core/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ authors = [
1515
[features]
1616
default = [ "runtime-async-std" ]
1717
unstable = []
18+
# we need a feature which activates `num-bigint` as well because
19+
# `bigdecimal` uses types from it but does not reexport (tsk tsk)
20+
bigdecimal_bigint = ["bigdecimal", "num-bigint"]
1821
postgres = [ "md-5", "sha2", "base64", "sha-1", "rand", "hmac", "futures-channel/sink", "futures-util/sink" ]
1922
mysql = [ "sha-1", "sha2", "generic-array", "num-bigint", "base64", "digest", "rand" ]
2023
sqlite = [ "libsqlite3-sys" ]
@@ -27,6 +30,7 @@ async-native-tls = { version = "0.3.2", default-features = false, optional = tru
2730
async-std = { version = "1.5.0", features = [ "unstable" ], optional = true }
2831
async-stream = { version = "0.2.1", default-features = false }
2932
base64 = { version = "0.12.0", default-features = false, optional = true, features = [ "std" ] }
33+
bigdecimal = { version = "0.1.0", optional = true }
3034
bitflags = { version = "1.2.1", default-features = false }
3135
byteorder = { version = "1.3.4", default-features = false, features = [ "std" ] }
3236
chrono = { version = "0.4.10", default-features = false, features = [ "clock" ], optional = true }

sqlx-core/src/postgres/protocol/type_id.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
22
pub struct TypeId(pub(crate) u32);
33

4+
// DEVELOPER PRO TIP: find builtin type OIDs easily by grepping this file
5+
// https://github.com/postgres/postgres/blob/master/src/include/catalog/pg_type.dat
6+
//
7+
// If you have Postgres running locally you can also try
8+
// SELECT oid, typarray FROM pg_type where typname = '<type name>'
9+
410
#[allow(dead_code)]
511
impl TypeId {
612
// Scalar
@@ -14,6 +20,8 @@ impl TypeId {
1420
pub(crate) const FLOAT4: TypeId = TypeId(700);
1521
pub(crate) const FLOAT8: TypeId = TypeId(701);
1622

23+
pub(crate) const NUMERIC: TypeId = TypeId(1700);
24+
1725
pub(crate) const TEXT: TypeId = TypeId(25);
1826

1927
pub(crate) const DATE: TypeId = TypeId(1082);
@@ -38,6 +46,8 @@ impl TypeId {
3846

3947
pub(crate) const ARRAY_TEXT: TypeId = TypeId(1009);
4048

49+
pub(crate) const ARRAY_NUMERIC: TypeId = TypeId(1700);
50+
4151
pub(crate) const ARRAY_DATE: TypeId = TypeId(1182);
4252
pub(crate) const ARRAY_TIME: TypeId = TypeId(1183);
4353
pub(crate) const ARRAY_TIMESTAMP: TypeId = TypeId(1115);

0 commit comments

Comments
 (0)