Skip to content
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

[Fix] Columns not quoted in returning when using Sqlite #3174

Merged
merged 7 commits into from Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -371,3 +371,60 @@ mod json_create {
Ok(())
}
}

#[test_suite(schema(schema_map))]
mod mapped_create {
use query_engine_tests::run_query;
fn schema_map() -> String {
let schema = indoc! {
r#"
model GoodModel {
#id(user_id, Int, @id)
txt_space String @map("text space")
}

model AModel {
#id(user_id, Int, @id @default(autoincrement()), @map("user id"))
txt_space String @map("text space")
}

model BModel {
#id(user_id, Int, @id, @map("user id"))
txt_space String @map("text space")
}

model CModel {
#id(user_id, String, @id, @map("user id"))
txt_space String @map("text space")
}
"#
};

schema.to_owned()
}

#[connector_test(exclude(mongodb, cockroachdb))]
async fn mapped_name_with_space_does_not_break_returning(runner: Runner) -> TestResult<()> {
insta::assert_snapshot!(
run_query!(&runner, r#"mutation {createOneGoodModel(data: {user_id: 1, txt_space: "test"}) {user_id, txt_space}}"#),
@r###"{"data":{"createOneGoodModel":{"user_id":1,"txt_space":"test"}}}"###
);

insta::assert_snapshot!(
run_query!(&runner, r#"mutation {createOneAModel(data: {txt_space: "test"}) {user_id, txt_space}}"#),
@r###"{"data":{"createOneAModel":{"user_id":1,"txt_space":"test"}}}"###
);

insta::assert_snapshot!(
run_query!(&runner, r#"mutation {createOneBModel(data: {user_id: 1, txt_space: "test"}) {user_id, txt_space}}"#),
@r###"{"data":{"createOneBModel":{"user_id":1,"txt_space":"test"}}}"###
);

insta::assert_snapshot!(
run_query!(&runner, r#"mutation {createOneCModel(data: {user_id: "one", txt_space: "test"}) {user_id, txt_space}}"#),
@r###"{"data":{"createOneCModel":{"user_id":"one","txt_space":"test"}}}"###
);

Ok(())
}
}
Expand Up @@ -140,7 +140,7 @@ pub async fn create_record(
// All values provided in the write arrghs
(Some(identifier), _, _) if !identifier.misses_autogen_value() => Ok(identifier),

// PostgreSQL with a working RETURNING statement
// with a working RETURNING statement
(_, n, _) if n > 0 => Ok(try_convert(&model.primary_identifier().into(), result_set)?),

// We have an auto-incremented id that we got from MySQL or SQLite
Expand Down