Skip to content

Commit f0b4df2

Browse files
authored
Merge pull request #32 from MaterializeInc/merge-upstream
Merge upstream to pick up new fixes and features
2 parents c4b473b + 8efd8bd commit f0b4df2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+2033
-719
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,90 +17,95 @@ jobs:
1717
name: rustfmt
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v3
21-
- uses: sfackler/actions/rustup@master
22-
- uses: sfackler/actions/rustfmt@master
20+
- uses: actions/checkout@v6
21+
- uses: dtolnay/rust-toolchain@stable
22+
with:
23+
components: rustfmt
24+
- run: cargo fmt --all -- --check
2325

2426
clippy:
2527
name: clippy
2628
runs-on: ubuntu-latest
2729
steps:
28-
- uses: actions/checkout@v3
29-
- uses: sfackler/actions/rustup@master
30+
- uses: actions/checkout@v6
31+
- uses: dtolnay/rust-toolchain@stable
32+
with:
33+
components: clippy
3034
- run: echo "version=$(rustc --version)" >> $GITHUB_OUTPUT
3135
id: rust-version
32-
- uses: actions/cache@v3
36+
- uses: actions/cache@v4
3337
with:
3438
path: ~/.cargo/registry/index
3539
key: index-${{ runner.os }}-${{ github.run_number }}
3640
restore-keys: |
3741
index-${{ runner.os }}-
3842
- run: cargo generate-lockfile
39-
- uses: actions/cache@v3
43+
- uses: actions/cache@v4
4044
with:
4145
path: ~/.cargo/registry/cache
4246
key: registry-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
4347
- run: cargo fetch
44-
- uses: actions/cache@v3
48+
- uses: actions/cache@v4
4549
with:
4650
path: target
47-
key: clippy-target-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}y
51+
key: clippy-target-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
4852
- run: cargo clippy --all --all-targets
4953

5054
check-wasm32:
5155
name: check-wasm32
5256
runs-on: ubuntu-latest
5357
steps:
54-
- uses: actions/checkout@v3
55-
- uses: sfackler/actions/rustup@master
58+
- uses: actions/checkout@v6
59+
- uses: dtolnay/rust-toolchain@stable
60+
with:
61+
targets: wasm32-unknown-unknown
5662
- run: echo "version=$(rustc --version)" >> $GITHUB_OUTPUT
5763
id: rust-version
58-
- run: rustup target add wasm32-unknown-unknown
59-
- uses: actions/cache@v3
64+
- uses: actions/cache@v4
6065
with:
6166
path: ~/.cargo/registry/index
6267
key: index-${{ runner.os }}-${{ github.run_number }}
6368
restore-keys: |
6469
index-${{ runner.os }}-
6570
- run: cargo generate-lockfile
66-
- uses: actions/cache@v3
71+
- uses: actions/cache@v4
6772
with:
6873
path: ~/.cargo/registry/cache
6974
key: registry-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
7075
- run: cargo fetch
71-
- uses: actions/cache@v3
76+
- uses: actions/cache@v4
7277
with:
7378
path: target
7479
key: check-wasm32-target-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
7580
- run: cargo check --target wasm32-unknown-unknown --manifest-path tokio-postgres/Cargo.toml --no-default-features --features js
81+
env:
82+
RUSTFLAGS: --cfg getrandom_backend="wasm_js"
7683

7784
test:
7885
name: test
7986
runs-on: ubuntu-latest
8087
steps:
81-
- uses: actions/checkout@v3
88+
- uses: actions/checkout@v6
8289
- run: docker compose up -d
83-
- uses: sfackler/actions/rustup@master
84-
with:
85-
version: 1.77.0
90+
- uses: dtolnay/rust-toolchain@1.81.0
8691
- run: echo "version=$(rustc --version)" >> $GITHUB_OUTPUT
8792
id: rust-version
88-
- uses: actions/cache@v3
93+
- uses: actions/cache@v4
8994
with:
9095
path: ~/.cargo/registry/index
9196
key: index-${{ runner.os }}-${{ github.run_number }}
9297
restore-keys: |
9398
index-${{ runner.os }}-
9499
- run: cargo generate-lockfile
95-
- uses: actions/cache@v3
100+
- uses: actions/cache@v4
96101
with:
97102
path: ~/.cargo/registry/cache
98103
key: registry-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
99104
- run: cargo fetch
100-
- uses: actions/cache@v3
105+
- uses: actions/cache@v4
101106
with:
102107
path: target
103-
key: test-target-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}y
108+
key: test-target-${{ runner.os }}-${{ steps.rust-version.outputs.version }}-${{ hashFiles('Cargo.lock') }}
104109
- run: cargo test --all
105110
- run: cargo test --manifest-path tokio-postgres/Cargo.toml --no-default-features
106111
- run: cargo test --manifest-path tokio-postgres/Cargo.toml --all-features

codegen/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version = "0.1.0"
44
authors = ["Steven Fackler <sfackler@gmail.com>"]
55

66
[dependencies]
7-
phf_codegen = "0.11"
7+
phf_codegen = "0.13"
88
regex = "1.0"
99
marksman_escape = "0.1"
1010
linked-hash-map = "0.5"

codegen/src/sqlstate.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ fn make_code(codes: &LinkedHashMap<String, Vec<String>>, file: &mut BufWriter<Fi
7272
file,
7373
r#"
7474
Inner::E{code} => "{code}","#,
75-
code = code,
7675
)
7776
.unwrap();
7877
}
@@ -97,8 +96,6 @@ fn make_consts(codes: &LinkedHashMap<String, Vec<String>>, file: &mut BufWriter<
9796
/// {code}
9897
pub const {name}: SqlState = SqlState(Inner::E{code});
9998
"#,
100-
name = name,
101-
code = code,
10299
)
103100
.unwrap();
104101
}
@@ -121,8 +118,7 @@ enum Inner {{"#,
121118
write!(
122119
file,
123120
r#"
124-
E{},"#,
125-
code,
121+
E{code},"#,
126122
)
127123
.unwrap();
128124
}
@@ -139,7 +135,7 @@ enum Inner {{"#,
139135
fn make_map(codes: &LinkedHashMap<String, Vec<String>>, file: &mut BufWriter<File>) {
140136
let mut builder = phf_codegen::Map::new();
141137
for (code, names) in codes {
142-
builder.entry(&**code, &format!("SqlState::{}", &names[0]));
138+
builder.entry(&**code, format!("SqlState::{}", &names[0]));
143139
}
144140
write!(
145141
file,

codegen/src/type_gen.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,18 +237,18 @@ fn parse_types() -> BTreeMap<u32, Type> {
237237
let doc_name = array_re.replace(&name, "$1[]").to_ascii_uppercase();
238238
let mut doc = doc_name.clone();
239239
if let Some(descr) = raw_type.get("descr") {
240-
write!(doc, " - {}", descr).unwrap();
240+
write!(doc, " - {descr}").unwrap();
241241
}
242242
let doc = Escape::new(doc.as_bytes().iter().cloned()).collect();
243243
let doc = String::from_utf8(doc).unwrap();
244244

245245
if let Some(array_type_oid) = raw_type.get("array_type_oid") {
246246
let array_type_oid = array_type_oid.parse::<u32>().unwrap();
247247

248-
let name = format!("_{}", name);
249-
let variant = format!("{}Array", variant);
250-
let doc = format!("{}&#91;&#93;", doc_name);
251-
let ident = format!("{}_ARRAY", ident);
248+
let name = format!("_{name}");
249+
let variant = format!("{variant}Array");
250+
let doc = format!("{doc_name}&#91;&#93;");
251+
let ident = format!("{ident}_ARRAY");
252252

253253
let type_ = Type {
254254
name,

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '2'
22
services:
33
postgres:
4-
image: postgres:14
4+
image: docker.io/postgres:18
55
ports:
66
- 5433:5433
77
volumes:

postgres-derive-test/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "postgres-derive-test"
33
version = "0.1.0"
44
authors = ["Steven Fackler <sfackler@gmail.com>"]
5-
edition = "2018"
5+
edition = "2021"
66

77
[dev-dependencies]
88
trybuild = "1.0"

postgres-derive-test/src/domains.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,36 @@ fn domain_in_composite() {
119119
)],
120120
);
121121
}
122+
123+
#[test]
124+
fn composite_in_domain_in_composite() {
125+
#[derive(FromSql, ToSql, Debug, PartialEq)]
126+
#[postgres(name = "leaf_composite")]
127+
struct LeafComposite {
128+
prim: i32,
129+
}
130+
131+
#[derive(FromSql, ToSql, Debug, PartialEq)]
132+
#[postgres(name = "domain")]
133+
struct Domain(LeafComposite);
134+
135+
#[derive(FromSql, ToSql, Debug, PartialEq)]
136+
#[postgres(name = "root_composite")]
137+
struct RootComposite {
138+
domain: Domain,
139+
}
140+
141+
let mut conn = Client::connect("user=postgres host=localhost port=5433", NoTls).unwrap();
142+
conn.batch_execute("CREATE TYPE leaf_composite AS (prim integer); CREATE DOMAIN domain AS leaf_composite; CREATE TYPE root_composite AS (domain domain);").unwrap();
143+
144+
test_type(
145+
&mut conn,
146+
"root_composite",
147+
&[(
148+
RootComposite {
149+
domain: Domain(LeafComposite { prim: 1 }),
150+
},
151+
"ROW(ROW(1))",
152+
)],
153+
);
154+
}

postgres-derive-test/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ where
2121
let result = conn.query_one(&stmt, &[]).unwrap().get(0);
2222
assert_eq!(val, &result);
2323

24-
let stmt = conn.prepare(&format!("SELECT $1::{}", sql_type)).unwrap();
24+
let stmt = conn.prepare(&format!("SELECT $1::{sql_type}")).unwrap();
2525
let result = conn.query_one(&stmt, &[val]).unwrap().get(0);
2626
assert_eq!(val, &result);
2727
}
@@ -45,7 +45,7 @@ pub fn test_type_asymmetric<T, F, S, C>(
4545
let result: F = conn.query_one(&stmt, &[]).unwrap().get(0);
4646
assert!(cmp(val, &result));
4747

48-
let stmt = conn.prepare(&format!("SELECT $1::{}", sql_type)).unwrap();
48+
let stmt = conn.prepare(&format!("SELECT $1::{sql_type}")).unwrap();
4949
let result: F = conn.query_one(&stmt, &[val]).unwrap().get(0);
5050
assert!(cmp(val, &result));
5151
}

postgres-derive/CHANGELOG.md

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

3+
## v0.4.7 - 2025-09-25
4+
5+
### Added
6+
7+
* Added support for nested domains containing composite types to `FromSql`
8+
9+
### Fixed
10+
11+
* Added `dyn` keyword to boxed trait objects.
12+
13+
### Changed
14+
15+
* Updated repository links to use `rust-postgres` organization.
16+
* Upgraded to Rust 2021 edition.
17+
18+
## v0.4.6 - 2024-09-15
19+
20+
### Changed
21+
22+
* Upgraded `heck`.
23+
324
## v0.4.5 - 2023-08-19
425

526
### Added

postgres-derive/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
[package]
22
name = "postgres-derive"
3-
version = "0.4.5"
3+
version = "0.4.7"
44
authors = ["Steven Fackler <sfackler@palantir.com>"]
55
license = "MIT OR Apache-2.0"
6-
edition = "2018"
6+
edition = "2021"
77
description = "An internal crate used by postgres-types"
8-
repository = "https://github.com/sfackler/rust-postgres"
8+
repository = "https://github.com/rust-postgres/rust-postgres"
9+
rust-version = "1.81"
910

1011
[lib]
1112
proc-macro = true

0 commit comments

Comments
 (0)