Skip to content

Commit 46b3003

Browse files
committed
Remove eager default evaluation
1 parent f633b1c commit 46b3003

12 files changed

Lines changed: 14 additions & 150 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ mongodb = { version = "3", features = [
8585
] }
8686
mysql_async = { git = "https://github.com/prisma/mysql_async", branch = "vendored-openssl" }
8787
names = { version = "0.11", default-features = false }
88-
nanoid = "0.4"
8988
native-tls = "0.2"
9089
nom = "7"
9190
num_cpus = "1"

query-compiler/core/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ psl.workspace = true
1414
indexmap.workspace = true
1515
itertools.workspace = true
1616
petgraph.workspace = true
17-
query-structure = { workspace = true, features = [
18-
"default_generators",
19-
] }
17+
query-structure.workspace = true
2018
serde.workspace = true
2119
serde_json.workspace = true
2220
smallvec.workspace = true

query-compiler/core/src/query_document/parser.rs

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,18 @@ use bigdecimal::{BigDecimal, ToPrimitive};
44
use chrono::prelude::*;
55
use core::fmt;
66
use indexmap::{IndexMap, IndexSet};
7-
use query_structure::{DefaultKind, PrismaValue, ValueGeneratorFn};
7+
use query_structure::PrismaValue;
88
use std::{borrow::Cow, convert::TryFrom, rc::Rc, str::FromStr};
99
use user_facing_errors::query_engine::validation::ValidationError;
1010
use uuid::Uuid;
1111

12-
pub(crate) enum QueryDocumentParser {
13-
WithEagerDefaultEvaluation {
14-
/// NOW() default value that's reused for all NOW() defaults on a single query
15-
default_now: PrismaValue,
16-
},
17-
WithoutEagerDefaultEvaluation,
18-
}
12+
pub(crate) struct QueryDocumentParser;
1913

2014
type ResolveField<'a, 'b> = &'b dyn Fn(&str) -> Option<OutputField<'a>>;
2115

2216
impl QueryDocumentParser {
23-
pub(crate) fn with_eager_default_evaluation() -> Self {
24-
QueryDocumentParser::WithEagerDefaultEvaluation {
25-
default_now: crate::request_context::get_request_now(),
26-
}
27-
}
28-
29-
pub(crate) fn without_eager_default_evaluation() -> Self {
30-
QueryDocumentParser::WithoutEagerDefaultEvaluation
17+
pub(crate) fn new() -> Self {
18+
Self
3119
}
3220

3321
// Public entry point to parsing the query document (as denoted by `selections`) against the `schema_object`.
@@ -712,20 +700,10 @@ impl QueryDocumentParser {
712700
// If it's not optional and has no default, a required field has not been provided.
713701
match &field.default_value {
714702
Some(default_value) => {
715-
let default_pv = match self {
716-
Self::WithEagerDefaultEvaluation { default_now } => match default_value {
717-
DefaultKind::Expression(expr) if matches!(expr.generator(), ValueGeneratorFn::Now) => {
718-
default_now.clone()
719-
}
720-
_ => default_value.get_evaluated()?,
721-
},
722-
Self::WithoutEagerDefaultEvaluation => default_value.get()?,
723-
};
724-
725703
match self.parse_input_value(
726704
selection_path.clone(),
727705
argument_path,
728-
default_pv.into(),
706+
default_value.get()?.into(),
729707
field.field_types(),
730708
query_schema,
731709
) {

query-compiler/core/src/query_graph_builder/builder.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ static PRISMA_DOT_PATH: LazyLock<Option<String>> = LazyLock::new(|| {
3232

3333
pub struct QueryGraphBuilder<'a> {
3434
query_schema: &'a QuerySchema,
35-
// TODO: remove this mode, it was only used by QE
36-
eager_default_evaluation: bool,
3735
}
3836

3937
impl fmt::Debug for QueryGraphBuilder<'_> {
@@ -44,17 +42,7 @@ impl fmt::Debug for QueryGraphBuilder<'_> {
4442

4543
impl<'a> QueryGraphBuilder<'a> {
4644
pub fn new(query_schema: &'a QuerySchema) -> Self {
47-
Self {
48-
query_schema,
49-
eager_default_evaluation: true,
50-
}
51-
}
52-
53-
/// Disables eager evaluation of default values of columns. Instead of passing through
54-
/// evaluated defaults, they are passed through as reified generator calls.
55-
pub fn without_eager_default_evaluation(mut self) -> Self {
56-
self.eager_default_evaluation = false;
57-
self
45+
Self { query_schema }
5846
}
5947

6048
/// Maps an operation to a query.
@@ -76,11 +64,7 @@ impl<'a> QueryGraphBuilder<'a> {
7664
root_object: ObjectType<'a>, // Either the query or mutation object.
7765
root_object_fields: &dyn Fn(&str) -> Option<OutputField<'a>>,
7866
) -> QueryGraphBuilderResult<QueryGraph> {
79-
let parser = if self.eager_default_evaluation {
80-
QueryDocumentParser::with_eager_default_evaluation()
81-
} else {
82-
QueryDocumentParser::without_eager_default_evaluation()
83-
};
67+
let parser = QueryDocumentParser::new();
8468

8569
let mut parsed_object = parser.parse(
8670
slice::from_ref(&selection),

query-compiler/dmmf/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ serde.workspace = true
1111
serde_json.workspace = true
1212
schema.workspace = true
1313
indexmap = { workspace = true, features = ["serde"] }
14-
query-structure = { workspace = true, features = [
15-
"default_generators",
16-
] }
14+
query-structure.workspace = true
1715

1816
[dev-dependencies]
1917
expect-test.workspace = true

query-compiler/query-builders/sql-query-builder/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ quaint = { workspace = true, features = ["mysql", "mssql", "postgresql", "sqlite
2222

2323
[features]
2424
relation_joins = ["query-builder/relation_joins"]
25-
default_generators = ["query-structure/default_generators"]

query-compiler/query-compiler-playground/src/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ pub fn main() -> anyhow::Result<()> {
7474
anyhow::bail!("expected single query");
7575
};
7676

77-
let graph = QueryGraphBuilder::new(&query_schema)
78-
.without_eager_default_evaluation()
79-
.build(query)?;
77+
let graph = QueryGraphBuilder::new(&query_schema).build(query)?;
8078

8179
println!("{graph}");
8280
render_query_graph(&graph)?;

query-compiler/query-compiler/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ pub fn compile(
3535
connection_info: &ConnectionInfo,
3636
) -> Result<Expression, CompileError> {
3737
let ctx = Context::new(connection_info, None);
38-
let graph = QueryGraphBuilder::new(query_schema)
39-
.without_eager_default_evaluation()
40-
.build(query)?;
38+
let graph = QueryGraphBuilder::new(query_schema).build(query)?;
4139

4240
let res: Result<Expression, TranslateError> = match connection_info.sql_family() {
4341
#[cfg(feature = "postgresql")]

query-compiler/query-compiler/tests/queries.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ fn queries() {
4040
};
4141

4242
let graph = QueryGraphBuilder::new(&query_schema)
43-
.without_eager_default_evaluation()
4443
.build(query)
4544
.map_err(|err| format!("{test_name} failed: {err}"))
4645
.unwrap();

0 commit comments

Comments
 (0)