Skip to content

Commit

Permalink
[Fix] Columns not quoted in returning when using Sqlite (#3174)
Browse files Browse the repository at this point in the history
* Just affects Sqlite I think. Needs to be fixed in quaint. Maybe do a general sweep of column / table rendering

* adjust test

* quaint update

* expand test

* update quaint once more, ignore test on Mongo

* exclude cockroach from test due to not supporting autoincrement on int
  • Loading branch information
do4gr committed Sep 20, 2022
1 parent e0695f7 commit b30d4c4
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
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

0 comments on commit b30d4c4

Please sign in to comment.