-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: generic query building #5127
Conversation
#[error("{0}")] | ||
QuaintError(#[from] quaint::error::Error), | ||
#[error("query builder error: {0}")] | ||
QueryBuildFailure(#[source] Box<dyn std::error::Error + Send + Sync>), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made the error dynamic too, it might be odd to use a dynamic query builder with non-dynamic errors, but I'm open to suggestions
|
||
pub use query_arguments_ext::QueryArgumentsExt; | ||
|
||
pub trait QueryBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this trait might need to change, it's pretty low level and makes some assumptions but I think it's an OK start
.collect() | ||
} else { | ||
let partitioned_batches = partition_into_batches(args, ctx); | ||
trace!("Total of {} batches to be executed.", partitioned_batches.len()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed this trace, not sure if we'll need it since this can be introspected pretty easy now that query building is separated, but I can add it back, it'll require depending on tracing
in the builder crate though
CodSpeed Performance ReportMerging #5127 will degrade performances by 5.51%Comparing Summary
Benchmarks breakdown
|
WASM Query Engine file Size
|
@@ -191,49 +167,6 @@ pub(crate) async fn create_record( | |||
} | |||
} | |||
|
|||
/// Returns a set of fields that are used in the arguments for the create operation. | |||
fn collect_affected_fields(args: &[WriteArgs], model: &Model) -> HashSet<ScalarFieldRef> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved this and one other function to the sql builder crate, might wanna sync this with main
@@ -39,6 +39,7 @@ serial_test = "*" | |||
quaint.workspace = true | |||
indoc.workspace = true | |||
indexmap.workspace = true | |||
sql-query-builder = { path = "../query-builders/sql-query-builder" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dev-dependency for the compiler example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move the compiler example to the top-level query-compiler crate when it's ready (not in this PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, we'll probably iterate on the interface as we go but it's a very good start.
Implements a generic
SqlQueryBuilder
for all quaint visitors for theQueryBuilder
trait, and uses theQueryBuilder
trait in the compiler