Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,517 changes: 963 additions & 554 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"examples/*",
"clients/*",
Expand Down
2 changes: 1 addition & 1 deletion bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
tokio = { version = "1.21.2", features = ["full"] }
futures = "0.3.25"
criterion = { version = "0.4.0", features = ["html_reports"] }
criterion = { version = "0.5.0", features = ["html_reports"] }
postgres = "0.19.4"
tokio-postgres = "0.7.7"
postgres-types = "0.2.4"
Expand Down
2 changes: 1 addition & 1 deletion bench/usage/cornucopia_benches/generated_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ pub mod queries {
}
}
pub fn select_complex() -> SelectComplexStmt {
SelectComplexStmt(cornucopia_async :: private :: Stmt :: new("SELECT u.id as myuser_id, u.name, u.hair_color, p.id as post_id, p.user_id, p.title, p.body FROM users as u LEFT JOIN posts as p on u.id = p.user_id"))
SelectComplexStmt(cornucopia_async::private::Stmt::new("SELECT u.id as myuser_id, u.name, u.hair_color, p.id as post_id, p.user_id, p.title, p.body FROM users as u LEFT JOIN posts as p on u.id = p.user_id"))
}
pub struct SelectComplexStmt(cornucopia_async::private::Stmt);
impl SelectComplexStmt {
Expand Down
2 changes: 1 addition & 1 deletion bench/usage/cornucopia_benches/generated_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ pub mod queries {
}
}
pub fn select_complex() -> SelectComplexStmt {
SelectComplexStmt(cornucopia_sync :: private :: Stmt :: new("SELECT u.id as myuser_id, u.name, u.hair_color, p.id as post_id, p.user_id, p.title, p.body FROM users as u LEFT JOIN posts as p on u.id = p.user_id"))
SelectComplexStmt(cornucopia_sync::private::Stmt::new("SELECT u.id as myuser_id, u.name, u.hair_color, p.id as post_id, p.user_id, p.title, p.body FROM users as u LEFT JOIN posts as p on u.id = p.user_id"))
}
pub struct SelectComplexStmt(cornucopia_sync::private::Stmt);
impl SelectComplexStmt {
Expand Down
2 changes: 1 addition & 1 deletion clients/async/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ 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 }
deadpool-postgres = { version = "0.14.0", optional = true }

cornucopia_client_core = { path = "../core", version = "0.4.0" }
80 changes: 40 additions & 40 deletions codegen_test/src/cornucopia_async.rs

Large diffs are not rendered by default.

80 changes: 40 additions & 40 deletions codegen_test/src/cornucopia_sync.rs

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions cornucopia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ codegen_template = { path = "../codegen_template", version = "0.1.0" }

postgres = "0.19.4"
postgres-types = "0.2.4"
thiserror = "1.0.37"
miette = { version = "5.4.1", features = ["fancy"] }
thiserror = "2.0.0"
miette = { version = "7.0.0", features = ["fancy"] }
clap = { version = "4.0.19", features = ["derive"] }
heck = "0.4.0"
indexmap = "1.9.1"
chumsky = "0.8.0"
heck = "0.5.0"
indexmap = "2.0.0"
chumsky = "0.9.3"
2 changes: 1 addition & 1 deletion cornucopia/src/load_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub(crate) mod error {
Postgres {
msg: String,
#[source_code]
src: NamedSource,
src: NamedSource<String>,
#[help]
help: Option<String>,
#[label("error occurs near this location")]
Expand Down
2 changes: 1 addition & 1 deletion cornucopia/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ pub(crate) mod error {
#[error("Couldn't parse queries")]
pub struct Error {
#[source_code]
pub src: NamedSource,
pub src: NamedSource<String>,

#[help]
pub help: String,
Expand Down
2 changes: 1 addition & 1 deletion cornucopia/src/prepare_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ pub(crate) mod error {
#[help]
help: Option<String>,
#[source_code]
src: NamedSource,
src: NamedSource<String>,
#[label("error occurs near this location")]
err_span: Option<SourceSpan>,
},
Expand Down
4 changes: 2 additions & 2 deletions cornucopia/src/read_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ pub(crate) struct ModuleInfo {
pub(crate) content: String,
}

impl From<ModuleInfo> for NamedSource {
impl From<ModuleInfo> for NamedSource<String> {
fn from(m: ModuleInfo) -> Self {
Self::new(m.path, m.content)
}
}

impl From<&ModuleInfo> for NamedSource {
impl From<&ModuleInfo> for NamedSource<String> {
fn from(m: &ModuleInfo) -> Self {
Self::new(&m.path, m.content.clone())
}
Expand Down
2 changes: 1 addition & 1 deletion cornucopia/src/type_registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ pub(crate) mod error {
Db(#[from] postgres::Error),
UnsupportedPostgresType {
#[source_code]
src: NamedSource,
src: NamedSource<String>,
#[label("this query contains an unsupported type (name: {col_name}, type: {col_ty})")]
query: SourceSpan,
col_name: String,
Expand Down
22 changes: 11 additions & 11 deletions cornucopia/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ pub mod error {
#[diagnostic(help("disambiguate column names in your SQL using an `AS` clause"))]
DuplicateSqlColName {
#[source_code]
src: NamedSource,
src: NamedSource<String>,
name: String,
#[label("query returns one or more columns with the same name")]
pos: SourceSpan,
Expand All @@ -376,7 +376,7 @@ pub mod error {
#[diagnostic(help("remove one of the two declaration"))]
DuplicateFieldNullity {
#[source_code]
src: NamedSource,
src: NamedSource<String>,
name: String,
#[label("previous nullity declaration")]
first: SourceSpan,
Expand All @@ -387,7 +387,7 @@ pub mod error {
#[diagnostic(help("use a different name for one of those"))]
DuplicateType {
#[source_code]
src: NamedSource,
src: NamedSource<String>,
name: String,
ty: &'static str,
#[label("previous definition here")]
Expand All @@ -399,7 +399,7 @@ pub mod error {
#[diagnostic(help("declare an inline named type using `()`: {name}()"))]
UnknownNamedType {
#[source_code]
src: NamedSource,
src: NamedSource<String>,
name: String,
ty: &'static str,
#[label("unknown named {ty}")]
Expand All @@ -409,7 +409,7 @@ pub mod error {
#[diagnostic(help("use one of those names: {known}"))]
UnknownFieldName {
#[source_code]
src: NamedSource,
src: NamedSource<String>,
#[label("no field with this name was found")]
pos: SourceSpan,
known: String,
Expand All @@ -418,7 +418,7 @@ pub mod error {
#[diagnostic(help("use a different named type for each query"))]
IncompatibleNamedType {
#[source_code]
src: NamedSource,
src: NamedSource<String>,
name: String,
first_label: String,
#[label("{first_label}")]
Expand All @@ -431,7 +431,7 @@ pub mod error {
#[diagnostic(help("remove row declaration"))]
RowOnExecute {
#[source_code]
src: NamedSource,
src: NamedSource<String>,
name: String,
#[label("row declared here")]
row: SourceSpan,
Expand All @@ -442,7 +442,7 @@ pub mod error {
#[diagnostic(help("remove parameter declaration"))]
ParamsOnSimpleQuery {
#[source_code]
src: NamedSource,
src: NamedSource<String>,
name: String,
#[label("parameter declared here")]
param: SourceSpan,
Expand All @@ -453,7 +453,7 @@ pub mod error {
#[diagnostic(help("use a different name for one of those"))]
DuplicateName {
#[source_code]
src: NamedSource,
src: NamedSource<String>,
name: String,
first_ty: &'static str,
#[label("previous definition as {first_ty} here")]
Expand All @@ -466,7 +466,7 @@ pub mod error {
#[diagnostic(help("use a different name"))]
TypeRustKeyword {
#[source_code]
src: NamedSource,
src: NamedSource<String>,
name: &'static str,
#[label("reserved rust keyword")]
pos: SourceSpan,
Expand All @@ -475,7 +475,7 @@ pub mod error {
#[diagnostic(help("use a different name"))]
NameRustKeyword {
#[source_code]
src: NamedSource,
src: NamedSource<String>,
name: &'static str,
ty: &'static str,
#[label("from {ty} declared here")]
Expand Down
2 changes: 1 addition & 1 deletion examples/auto_build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
tokio = { version = "1.21.2", features = ["full"] }
tokio-postgres = "0.7.7"
deadpool-postgres = "0.10.3"
deadpool-postgres = "0.14.0"
futures = "0.3.25"
postgres-types = "0.2.4"

Expand Down
2 changes: 1 addition & 1 deletion examples/basic_async/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version = "0.1.0"

[dependencies]
tokio = { version = "1.21.2", features = ["full"] }
deadpool-postgres = "0.10.3"
deadpool-postgres = "0.14.0"
futures = "0.3.25"
postgres-types = { version = "0.2.4", features = ["derive"] }
tokio-postgres = "0.7.7"
Expand Down
2 changes: 1 addition & 1 deletion examples/basic_async/src/cornucopia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub mod types {
}
}
}
#[derive(Debug, postgres_types :: FromSql, Clone, PartialEq)]
#[derive(Debug, postgres_types::FromSql, Clone, PartialEq)]
#[postgres(name = "voiceactor")]
pub struct Voiceactor {
pub name: String,
Expand Down
2 changes: 1 addition & 1 deletion examples/basic_sync/src/cornucopia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub mod types {
}
}
}
#[derive(Debug, postgres_types :: FromSql, Clone, PartialEq)]
#[derive(Debug, postgres_types::FromSql, Clone, PartialEq)]
#[postgres(name = "voiceactor")]
pub struct Voiceactor {
pub name: String,
Expand Down
4 changes: 2 additions & 2 deletions integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ edition = "2021"

[dependencies]
tempfile = "3.3.0"
toml = "0.5.9"
owo-colors = "3.5.0"
toml = "0.8.0"
owo-colors = "4.0.0"
serde = { version = "1.0.147", features = ["derive"], package = "serde" }
clap = { version = "4.0.19", features = ["derive"] }
cornucopia = { path = "../cornucopia" }
Expand Down
12 changes: 6 additions & 6 deletions integration/fixtures/errors/codegen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SELECT * FROM author;
'''
error = '''
× `SelectBorrowed` is used multiple time
╭─[queries/test.sql:1:1]
╭─[queries/test.sql:1:5]
1 │ --! select
· ───┬──
· ╰── previous definition as borrowed row here
Expand All @@ -30,7 +30,7 @@ SELECT * FROM author;
'''
error = '''
× `NewAuthorParams` is used multiple time
╭─[queries/test.sql:1:1]
╭─[queries/test.sql:1:5]
1 │ --! new_author
· ─────┬────
· ╰── previous definition as params here
Expand All @@ -52,7 +52,7 @@ SELECT * FROM author;
'''
error = '''
× `SelectQuery` is used multiple time
╭─[queries/test.sql:1:1]
╭─[queries/test.sql:1:5]
1 │ --! select
· ───┬──
· ╰── previous definition as query here
Expand All @@ -73,7 +73,7 @@ INSERT INTO Author (id, name) VALUES (:id, :name) RETURNING *;
'''
error = '''
× `AuthorParams` is used multiple time
╭─[queries/test.sql:1:1]
╭─[queries/test.sql:2:5]
1 │ --: AuthorParams()
2 │ --! author: AuthorParams
· ───┬── ──────┬─────
Expand All @@ -91,7 +91,7 @@ INSERT INTO Author (id, name) VALUES (:id, :name) RETURNING *;
'''
error = '''
× `Author` is used multiple time
╭─[queries/test.sql:1:1]
╭─[queries/test.sql:1:12]
1 │ --! author Author(): Author()
· ───┬── ───┬──
· │ ╰── redefined as row here
Expand All @@ -108,7 +108,7 @@ INSERT INTO Author (id, name) VALUES (:id, :name) RETURNING *;
'''
error = '''
× `AuthorParams` is used multiple time
╭─[queries/test.sql:1:1]
╭─[queries/test.sql:1:5]
1 │ --! author: AuthorParams(id?)
· ───┬── ──────┬─────
· │ ╰── redefined as row here
Expand Down
4 changes: 2 additions & 2 deletions integration/fixtures/errors/prepare.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SELECT id, name AS id FROM author;
'''
error = '''
× column `id` appear multiple time
╭─[queries/test.sql:1:1]
╭─[queries/test.sql:1:5]
1 │ --! authors
· ───┬───
· ╰── query returns one or more columns with the same name
Expand All @@ -22,7 +22,7 @@ INSERT INTO Author (id, name) VALUES (:name, :name);
'''
error = '''
× Couldn't prepare query: inconsistent types deduced for parameter $1
╭─[queries/test.sql:1:1]
╭─[queries/test.sql:2:43]
1 │ --! insert_author
2 │ INSERT INTO Author (id, name) VALUES (:name, :name);
· ▲
Expand Down
2 changes: 1 addition & 1 deletion integration/fixtures/errors/schema.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CREATE TABLE syntax {};
'''
error = '''
× Could not execute schema: syntax error at or near "{"
╭─[schema.sql:1:1]
╭─[schema.sql:2:22]
1 │ CREATE TABLE author (id SERIAL, name TEXT);
2 │ CREATE TABLE syntax {};
· ▲
Expand Down
Loading