Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into sync_compat_async
Browse files Browse the repository at this point in the history
  • Loading branch information
Virgiel committed Jan 23, 2023
2 parents 7e42af4 + ae941cd commit 842e577
Show file tree
Hide file tree
Showing 32 changed files with 867 additions and 359 deletions.
465 changes: 342 additions & 123 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio = { version = "1.21.2", features = ["full"] }
tokio = { version = "1.24.2", features = ["full"] }
futures = "0.3.25"
criterion = { version = "0.4.0", features = ["html_reports"] }
postgres = "0.19.4"
Expand Down
2 changes: 1 addition & 1 deletion bench/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn bench(c: &mut Criterion) {
cornucopia::container::setup(false).unwrap();
let client = &mut cornucopia_conn().unwrap();

cornucopia::load_schema(client, vec!["../codegen_test/schema.sql".into()]).unwrap();
cornucopia::load_schema(client, &["../codegen_test/schema.sql"]).unwrap();
c.bench_function("codegen_sync", |b| {
b.iter(|| {
cornucopia::generate_live(
Expand Down
2 changes: 1 addition & 1 deletion bench/usage/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fn bench(c: &mut Criterion) {
let conn =
&mut PgConnection::establish("postgresql://postgres:postgres@127.0.0.1:5435/postgres")
.unwrap();
cornucopia::load_schema(client, vec!["usage/cornucopia_benches/schema.sql".into()]).unwrap();
cornucopia::load_schema(client, &["usage/cornucopia_benches/schema.sql"]).unwrap();
{
let mut group = c.benchmark_group("bench_trivial_query");
for size in QUERY_SIZE {
Expand Down
4 changes: 2 additions & 2 deletions clients/async/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ with-serde_json-1 = ["cornucopia_client_core/with-serde_json-1"]

[dependencies]
tokio-postgres = "0.7.7"
async-trait = "0.1.58"
deadpool-postgres = { version = "0.10.3", optional = true }
async-trait = "0.1.63"
deadpool-postgres = { version = "0.10.4", optional = true }

cornucopia_client_core = { path = "../core", version = "0.4.0" }
4 changes: 2 additions & 2 deletions clients/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ keywords = ["postgresql", "query", "generator", "sql", "tokio-postgres"]
postgres-protocol = "0.6.4"
postgres-types = "0.2.4"
fallible-iterator = "0.2.0"
serde-1 = { version = "1.0.147", package = "serde", optional = true }
serde_json-1 = { version = "1.0.87", package = "serde_json", optional = true }
serde-1 = { version = "1.0.152", package = "serde", optional = true }
serde_json-1 = { version = "1.0.91", package = "serde_json", optional = true }

[features]
with-serde_json-1 = [
Expand Down
2 changes: 1 addition & 1 deletion clients/core/src/array_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<'a, T: FromSql<'a>> FromSql<'a> for ArrayIterator<'a, T> {
) -> Result<ArrayIterator<'a, T>, Box<dyn std::error::Error + Sync + Send>> {
let member_type = match *escape_domain(ty).kind() {
Kind::Array(ref member) => escape_domain(member),
_ => panic!("expected array type got {}", ty),
_ => panic!("expected array type got {ty}"),
};

let array = array_from_sql(raw)?;
Expand Down
2 changes: 1 addition & 1 deletion clients/core/src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub fn escape_domain_to_sql<T: ToSql>(
) -> Result<IsNull, Box<dyn Error + Sync + Send>> {
let member_type = match *ty.kind() {
Kind::Array(ref member) => escape_domain(member),
_ => panic!("expected array type got {}", ty),
_ => panic!("expected array type got {ty}"),
};

let dimension = ArrayDimension {
Expand Down
2 changes: 1 addition & 1 deletion codegen_template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fn gen_disp(s: &mut String, out: &str, ident: &str) {
}

/// Generate code to write interpolation patterns in `scan` into `out`
fn gen_recursive<'a>(scan: &'a mut Scanner, s: &mut String, out: &str) {
fn gen_recursive(scan: &mut Scanner, s: &mut String, out: &str) {
loop {
let (raw, pattern) = parse_next(scan);
if raw.is_empty() && pattern.is_none() {
Expand Down
8 changes: 4 additions & 4 deletions codegen_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ tokio-postgres = { version = "0.7.7", features = [
"with-eui48-1",
] }
postgres-types = { version = "0.2.4", features = ["derive"] }
serde = { version = "1.0.147", features = ["derive"], package = "serde" }
serde_json = { version = "1.0.87", features = ["raw_value"], package = "serde_json" }
serde = { version = "1.0.152", features = ["derive"], package = "serde" }
serde_json = { version = "1.0.91", features = ["raw_value"], package = "serde_json" }
time = { version = "0.3.17", features = ["parsing", "serde"] }
uuid = { version = "1.2.1", features = ["serde"] }
uuid = { version = "1.2.2", features = ["serde"] }
eui48 = { version = "1.1.0", features = ["serde"] }
rust_decimal = { version = "1.26.1", features = ["db-postgres"] }
rust_decimal = { version = "1.28.0", features = ["db-postgres"] }
futures = "0.3.25"

cornucopia_sync = { path = "../clients/sync", features = ["with-serde_json-1"] }
Expand Down
7 changes: 4 additions & 3 deletions codegen_test/queries/named.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ SELECT * FROM named;
SELECT * FROM named WHERE id = :id;

--: named_composite(wow?,such_cool?)
--: "named_composite.with_dot"("this.is.inconceivable"?)

--! new_named_complex NamedComplexParams()
INSERT INTO named_complex (named) VALUES (:named);
--! named_complex
--! new_named_complex NamedComplexParams(named_with_dot?)
INSERT INTO named_complex (named, "named.with_dot") VALUES (:named, :named_with_dot);
--! named_complex: NamedComplex("named.with_dot"?)
SELECT * FROM named_complex;
11 changes: 9 additions & 2 deletions codegen_test/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,15 @@ CREATE TYPE named_composite AS (
such_cool integer
);

CREATE TYPE "enum.with_dot" AS Enum('variant.with_dot');

CREATE TYPE "named_composite.with_dot" AS (
"this.is.inconceivable" "enum.with_dot"
);

CREATE TABLE named_complex (
named named_composite
named named_composite,
"named.with_dot" "named_composite.with_dot"
);

-- Nullity
Expand Down Expand Up @@ -187,7 +194,7 @@ CREATE TABLE nightmare (
CREATE TYPE syntax_composite AS (
async INT
);
CREATE TYPE syntax_enum AS Enum('async', 'box');
CREATE TYPE syntax_enum AS Enum('async', 'box', 'I Love Chocolate');
CREATE TABLE Syntax (
"trick:y" TEXT,
async syntax_composite,
Expand Down
Loading

0 comments on commit 842e577

Please sign in to comment.