Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion libs/driver-adapters/src/conversion/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ mod test {
for (val, expected) in test_cases {
let actual = value_to_js_arg(&val.clone().into_value()).unwrap();
if actual != expected {
errors.push(format!("transforming: {:?}, expected: {:?}, actual: {:?}", &val, expected, actual));
errors.push(format!("transforming: {:?}, expected: {:?}, actual: {:?}", val, expected, actual));
}
}
assert_eq!(errors.len(), 0, "{}", errors.join("\n"));
Expand Down
2 changes: 1 addition & 1 deletion libs/driver-adapters/src/conversion/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ mod test {
for (val, expected) in test_cases {
let actual = value_to_js_arg(&val).unwrap();
if actual != expected {
errors.push(format!("transforming: {:?}, expected: {:?}, actual: {:?}", &val, expected, actual));
errors.push(format!("transforming: {:?}, expected: {:?}, actual: {:?}", val, expected, actual));
}
}
assert_eq!(errors.len(), 0, "{}", errors.join("\n"));
Expand Down
2 changes: 1 addition & 1 deletion libs/driver-adapters/src/conversion/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ mod test {
for (val, expected) in test_cases {
let actual = value_to_js_arg(&val.clone().into_value()).unwrap();
if actual != expected {
errors.push(format!("transforming: {:?}, expected: {:?}, actual: {:?}", &val, expected, actual));
errors.push(format!("transforming: {:?}, expected: {:?}, actual: {:?}", val, expected, actual));
}
}
assert_eq!(errors.len(), 0, "{}", errors.join("\n"));
Expand Down
6 changes: 3 additions & 3 deletions libs/user-facing-errors/src/query_engine/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,15 @@ impl ValidationError {
let err_msg = err.to_string();
let message = format!(
"Invalid argument value. `{}` is not a valid `{}`. Underlying error: {}",
value, expected_argument_type, &err_msg
value, expected_argument_type, err_msg
);
let argument = ArgumentDescription::new(*argument_name, vec![Cow::Borrowed(expected_argument_type)]);
let meta = json!({"argumentPath": argument_path, "argument": argument, "selectionPath": selection_path, "underlyingError": &err_msg});
(message, Some(meta))
} else {
let message = format!(
"Invalid argument value. `{}` is not a valid `{}`",
value, &expected_argument_type
value, expected_argument_type
);
let argument = ArgumentDescription::new(*argument_name, vec![Cow::Borrowed(expected_argument_type)]);
let meta = json!({"argumentPath": argument_path, "argument": argument, "selectionPath": selection_path, "underlyingError": serde_json::Value::Null});
Expand Down Expand Up @@ -469,7 +469,7 @@ impl ValidationError {
/// }
/// }
pub fn selection_set_on_scalar(field_name: String, selection_path: Vec<&str>) -> Self {
let message = format!("Cannot select over scalar field '{}'", &field_name);
let message = format!("Cannot select over scalar field '{}'", field_name);
ValidationError {
kind: ValidationErrorKind::SelectionSetOnScalar,
message,
Expand Down
6 changes: 3 additions & 3 deletions libs/user-facing-errors/src/schema_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl crate::UserFacingError for MigrationDoesNotApplyCleanly {
message: _,
meta: _,
error_code,
}) => format!("Error code: {}\n", &error_code),
}) => format!("Error code: {}\n", error_code),
crate::ErrorType::Unknown(_) => String::new(),
};

Expand Down Expand Up @@ -170,7 +170,7 @@ impl crate::UserFacingError for ShadowDbCreationError {
message: _,
meta: _,
error_code,
}) => format!("Error code: {}\n", &error_code),
}) => format!("Error code: {}\n", error_code),
crate::ErrorType::Unknown(_) => String::new(),
};

Expand Down Expand Up @@ -205,7 +205,7 @@ impl crate::UserFacingError for SoftResetFailed {
message: _,
meta: _,
error_code,
}) => format!("Error code: {}\n", &error_code),
}) => format!("Error code: {}\n", error_code),
crate::ErrorType::Unknown(_) => String::new(),
};

Expand Down
2 changes: 1 addition & 1 deletion psl/parser-database/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ fn visit_relation_field_attributes(rfid: RelationFieldId, ctx: &mut Context<'_>)
if ctx.visit_optional_single_attr("id") {
let msg = format!(
"The field `{}` is a relation field and cannot be marked with `@id`. Only scalar fields can be declared as id.",
&ast_field.name(),
ast_field.name(),
);
ctx.push_attribute_validation_error(&msg);
ctx.discard_arguments();
Expand Down
2 changes: 1 addition & 1 deletion psl/psl-core/src/datamodel_connector/native_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl NativeTypeArguments for (u32, u32) {

fn from_parts(parts: &[String]) -> Option<Self> {
match parts {
[a, b] => a.parse().ok().and_then(|a| b.parse().ok().map(|b| (a, b))),
[a, b] => a.parse().ok().zip(b.parse().ok()),
_ => None,
}
}
Expand Down
2 changes: 1 addition & 1 deletion psl/psl-core/src/validate/datasource_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ fn lift_datasource(
return None;
}

schemas.sort_by(|(a, _), (b, _)| a.cmp(b));
schemas.sort_by_key(|(a, _)| *a);

for pair in schemas.windows(2) {
if pair[0].0 == pair[1].0 {
Expand Down
28 changes: 14 additions & 14 deletions psl/psl-core/src/validate/validation_pipeline/validations/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,20 +295,20 @@ pub(super) fn validate_scalar_field_connector_specific(field: ScalarFieldWalker<
}
}

ScalarFieldType::BuiltInScalar(ScalarType::Decimal) => {
if !ctx.has_capability(ConnectorCapability::DecimalType) {
ctx.push_error(DatamodelError::new_field_validation_error(
&format!(
"Field `{}` in {container} `{}` can't be of type Decimal. The current connector does not support the Decimal type.",
field.name(),
field.model().name(),
),
container,
field.model().name(),
ScalarFieldType::BuiltInScalar(ScalarType::Decimal)
if !ctx.has_capability(ConnectorCapability::DecimalType) =>
{
ctx.push_error(DatamodelError::new_field_validation_error(
&format!(
"Field `{}` in {container} `{}` can't be of type Decimal. The current connector does not support the Decimal type.",
field.name(),
field.ast_field().span(),
));
}
field.model().name(),
),
container,
field.model().name(),
field.name(),
field.ast_field().span(),
));
}

_ => (),
Expand Down Expand Up @@ -368,7 +368,7 @@ pub(super) fn validate_unsupported_field_type(field: ScalarFieldWalker<'_>, ctx:
unsupported_lit,
field.name(),
prisma_type.display(ctx.db),
&source.name,
source.name,
connector.native_type_to_string(&native_type)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ pub(crate) fn validate_singular_id(relation: ImplicitManyToManyRelationWalker<'_

let message = format!(
"The relation field `{}` on {container} `{}` references `{}` which does not have an `@id` field. Models without `@id` cannot be part of a many to many relation. Use an explicit intermediate Model to represent this relationship.",
&relation_field.name(),
&relation_field.model().name(),
&relation_field.related_model().name(),
relation_field.name(),
relation_field.model().name(),
relation_field.related_model().name(),
);

ctx.push_error(DatamodelError::new_field_validation_error(
Expand All @@ -34,7 +34,7 @@ pub(crate) fn validate_singular_id(relation: ImplicitManyToManyRelationWalker<'_
ctx.push_error(DatamodelError::new_validation_error(
&format!(
"Implicit many-to-many relations must always reference the id field of the related model. Change the argument `references` to use the id field of the related model `{}`. But it is referencing the following fields that are not the id: {}",
&relation_field.related_model().name(),
relation_field.related_model().name(),
relation_field.referenced_fields().into_iter().flatten().map(|f| f.name()).collect::<Vec<_>>().join(", ")
),
relation_field.ast_field().span())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ pub(crate) fn both_sides_are_defined(relation: InlineRelationWalker<'_>, ctx: &m

let message = format!(
"The relation field `{}` on {container} `{}` is missing an opposite relation field on the model `{}`. Either run `prisma format` or add it manually.",
&relation_field.name(),
&relation_field.model().name(),
&relation_field.related_model().name(),
relation_field.name(),
relation_field.model().name(),
relation_field.related_model().name(),
);

ctx.push_error(DatamodelError::new_field_validation_error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub(crate) fn fields_and_references_are_defined(relation: InlineRelationWalker<'
forward.name(),
forward.model().name(),
back.name(),
&back.model().name(),
back.model().name(),
RELATION_ATTRIBUTE_NAME
);

Expand Down
6 changes: 3 additions & 3 deletions psl/psl/tests/common/asserts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ impl WarningAsserts for Vec<DatamodelWarning> {
self.len(),
1,
"Expected exactly one validation warning. Warnings are: {:?}",
&self
self
);
assert_eq!(self[0], warning);
self
Expand Down Expand Up @@ -696,7 +696,7 @@ impl DefaultValueAssert for ast::Expression {
panic!("Expected a numeric value for the `cuid()` version.");
}
} else {
panic!("Expected `cuid()` to be a function, got {}", &self);
panic!("Expected `cuid()` to be a function, got {}", self);
}

self
Expand All @@ -720,7 +720,7 @@ impl DefaultValueAssert for ast::Expression {
panic!("Expected a numeric value for the `uuid()` version.");
}
} else {
panic!("Expected `cuid()` to be a function, got {}", &self);
panic!("Expected `cuid()` to be a function, got {}", self);
}

self
Expand Down
5 changes: 1 addition & 4 deletions quaint/src/ast/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1476,10 +1476,7 @@ impl<'a> Values<'a> {
let mut result = Row::with_capacity(self.len());

for mut row in self.rows.into_iter() {
match row.pop() {
Some(value) => result.push(value),
None => return None,
}
result.push(row.pop()?);
}

Some(result)
Expand Down
4 changes: 2 additions & 2 deletions quaint/src/tests/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1683,11 +1683,11 @@ async fn op_test_div_one_level(api: &mut dyn TestApi) -> crate::Result<()> {
#[test_each_connector(tags("postgresql"))]
async fn enum_values(api: &mut dyn TestApi) -> crate::Result<()> {
let type_name = api.get_name();
let create_type = format!("CREATE TYPE {} AS ENUM ('A', 'B')", &type_name);
let create_type = format!("CREATE TYPE {} AS ENUM ('A', 'B')", type_name);
api.conn().raw_cmd(&create_type).await?;

let table = api
.create_temp_table(&format!("id SERIAL PRIMARY KEY, value {}", &type_name))
.create_temp_table(&format!("id SERIAL PRIMARY KEY, value {}", type_name))
.await?;

api.conn()
Expand Down
10 changes: 5 additions & 5 deletions quaint/src/tests/query/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ async fn foreign_key_constraint_violation(api: &mut dyn TestApi) -> crate::Resul
let parent = api.create_temp_table("id smallint not null primary key").await?;
let foreign_key = api.foreign_key(&parent, "id", "parent_id");
let child = api
.create_temp_table(&format!("parent_id smallint not null, {}", &foreign_key))
.create_temp_table(&format!("parent_id smallint not null, {}", foreign_key))
.await?;

let insert = Insert::single_into(&child).value("parent_id", 10);
Expand Down Expand Up @@ -271,7 +271,7 @@ async fn ms_my_foreign_key_constraint_violation(api: &mut dyn TestApi) -> crate:
parent_id smallint not null,
CONSTRAINT {} FOREIGN KEY (parent_id) REFERENCES {}(id))
"#,
&child_table, &constraint, &parent_table
child_table, constraint, parent_table
);

api.conn().raw_cmd(&create_table).await?;
Expand All @@ -284,8 +284,8 @@ async fn ms_my_foreign_key_constraint_violation(api: &mut dyn TestApi) -> crate:
let err = result.unwrap_err();
assert!(matches!(err.kind(), ErrorKind::ForeignKeyConstraintViolation { .. }));

api.conn().raw_cmd(&format!("DROP TABLE {}", &child_table)).await?;
api.conn().raw_cmd(&format!("DROP TABLE {}", &parent_table)).await?;
api.conn().raw_cmd(&format!("DROP TABLE {}", child_table)).await?;
api.conn().raw_cmd(&format!("DROP TABLE {}", parent_table)).await?;

Ok(())
}
Expand Down Expand Up @@ -407,7 +407,7 @@ async fn unsupported_column_type(api: &mut dyn TestApi) -> crate::Result<()> {
.query_raw(
&format!(
r#"INSERT INTO {} ("point", "points") VALUES (Point(1,2), '{{"(1, 2)", "(2, 3)"}}')"#,
&table
table
),
&[],
)
Expand Down
2 changes: 1 addition & 1 deletion quaint/src/tests/test_api/mssql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl TestApi for MsSql<'_> {

format!(
"CONSTRAINT {} FOREIGN KEY ({}) REFERENCES {}({})",
&name, child_column, parent_table, parent_column
name, child_column, parent_table, parent_column
)
}

Expand Down
2 changes: 1 addition & 1 deletion quaint/src/tests/test_api/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl TestApi for MySql<'_> {

format!(
"CONSTRAINT {} FOREIGN KEY ({}) REFERENCES {}({})",
&name, child_column, parent_table, parent_column
name, child_column, parent_table, parent_column
)
}

Expand Down
2 changes: 1 addition & 1 deletion quaint/src/tests/test_api/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl TestApi for PostgreSql<'_> {

format!(
"CONSTRAINT {} FOREIGN KEY ({}) REFERENCES {}({})",
&name, child_column, parent_table, parent_column
name, child_column, parent_table, parent_column
)
}

Expand Down
8 changes: 4 additions & 4 deletions quaint/src/tests/types/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async fn test_type_text_datetime_rfc3339(api: &mut dyn TestApi) -> crate::Result

api.conn()
.execute_raw(
&format!("INSERT INTO {} (value) VALUES (?)", &table),
&format!("INSERT INTO {} (value) VALUES (?)", table),
&[Value::text(dt.to_rfc3339())],
)
.await?;
Expand All @@ -149,7 +149,7 @@ async fn test_type_text_datetime_rfc2822(api: &mut dyn TestApi) -> crate::Result

api.conn()
.execute_raw(
&format!("INSERT INTO {} (value) VALUES (?)", &table),
&format!("INSERT INTO {} (value) VALUES (?)", table),
&[Value::text(dt.to_rfc2822())],
)
.await?;
Expand All @@ -170,7 +170,7 @@ async fn test_type_text_datetime_custom(api: &mut dyn TestApi) -> crate::Result<

api.conn()
.execute_raw(
&format!("INSERT INTO {} (value) VALUES (?)", &table),
&format!("INSERT INTO {} (value) VALUES (?)", table),
&[Value::text("2020-04-20 16:20:00")],
)
.await?;
Expand All @@ -194,7 +194,7 @@ async fn test_get_int64_from_int32_field_fails(api: &mut dyn TestApi) -> crate::

api.conn()
.execute_raw(
&format!("INSERT INTO {} (value) VALUES (9223372036854775807)", &table),
&format!("INSERT INTO {} (value) VALUES (9223372036854775807)", table),
&[],
)
.await?;
Expand Down
2 changes: 1 addition & 1 deletion quaint/src/visitor/mssql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ impl<'a> Visitor<'a> for Mssql<'a> {
self.surround_with("(", ")", |this| {
for (i, row) in right.into_iter().enumerate() {
this.surround_with("(", ")", |se| {
let row_and_vals = left.values.clone().into_iter().zip(row.values.into_iter());
let row_and_vals = left.values.clone().into_iter().zip(row.values);

for (j, (expr, val)) in row_and_vals.enumerate() {
se.visit_expression(expr)?;
Expand Down
6 changes: 1 addition & 5 deletions query-compiler/core/src/query_document/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,7 @@ impl QuerySingle {
let mut result = QuerySingle(key.clone(), vec![value.clone()]);

for filters in query_filters.iter().skip(1) {
if let Some(single) = QuerySingle::push(result, filters) {
result = single;
} else {
return None;
}
result = QuerySingle::push(result, filters)?;
}

Some(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ impl<'a> ScalarFilterParser<'a> {
None => Err(QueryGraphBuilderError::InputError(format!(
"The referenced scalar field {}.{} does not exist.",
field.container().name(),
&field_ref_name
field_ref_name
))),
}
}
Expand Down Expand Up @@ -531,7 +531,7 @@ impl<'a> ScalarFilterParser<'a> {
_ => Err(QueryGraphBuilderError::InputError(format!(
"The referenced scalar list field {}.{} does not exist.",
field.container().name(),
&field_ref_name
field_ref_name
))),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub(crate) fn compute_aggr_join(
previous_join: Option<&str>,
ctx: &Context<'_>,
) -> AliasedJoin {
let join_alias = format!("{}_{}", join_alias, &rf.related_model().name());
let join_alias = format!("{}_{}", join_alias, rf.related_model().name());

if rf.relation().is_many_to_many() {
compute_aggr_join_m2m(
Expand Down
Loading
Loading