Skip to content

Commit

Permalink
fix(mongo): default int native type should be long (#4888)
Browse files Browse the repository at this point in the history
  • Loading branch information
Weakky authored Jun 3, 2024
1 parent d99d360 commit 4f418dd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ crate::native_type_definition! {

static DEFAULT_MAPPING: Lazy<HashMap<ScalarType, MongoDbType>> = Lazy::new(|| {
vec![
(ScalarType::Int, MongoDbType::Int),
(ScalarType::Int, MongoDbType::Long),
(ScalarType::BigInt, MongoDbType::Long),
(ScalarType::Float, MongoDbType::Double),
(ScalarType::Boolean, MongoDbType::Bool),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,25 @@ mod mongodb {

Ok(())
}

fn default_int_type() -> String {
let schema = indoc! {
r#"model Test {
#id(id, String, @id, @default(cuid()))
int Int
}"#
};

schema.to_owned()
}

#[connector_test(schema(default_int_type))]
async fn default_int_type_is_long(runner: Runner) -> TestResult<()> {
insta::assert_snapshot!(
run_query!(&runner, r#"mutation { createOneTest(data: { int: 9223372036854775807 }) { int } }"#),
@r###"{"data":{"createOneTest":{"int":9223372036854775807}}}"###
);

Ok(())
}
}

0 comments on commit 4f418dd

Please sign in to comment.