Fix native types tests for CockroachDB
@@ -65,7 +65,7 @@ mod postgres {
}
// "Postgres native decimal types" should "work"
- #[connector_test(schema(schema_decimal))]
+ #[connector_test(schema(schema_decimal), exclude(Cockroach))]
async fn native_decimal_types(runner: Runner) -> TestResult<()> {
insta::assert_snapshot!(
run_query!(&runner, r#"mutation {
@@ -90,6 +90,43 @@ mod postgres {
Ok(())
}
+ fn schema_decimal_cockroach() -> String {
+ let schema = indoc! {
+ r#"model Model {
+ #id(id, String, @id, @default(cuid()))
+ float Float @test.Real
+ dfloat Float @test.DoublePrecision
+ decFloat Decimal @test.Decimal(2, 1)
+ }"#
+ };
+
+ schema.to_owned()
+ }
+
+ // Cockroach does not support money.
+ #[connector_test(schema(schema_decimal_cockroach), only(Cockroach))]
+ async fn native_decimal_types_cockroach(runner: Runner) -> TestResult<()> {
+ insta::assert_snapshot!(
+ run_query!(&runner, r#"mutation {
+ createOneModel(
+ data: {
+ float: 1.1
+ dfloat: 2.2
+ decFloat: 3.1234
+ }
+ ) {
+ float
+ dfloat
+ decFloat
+ }
+ }"#),
+ // decFloat is cut due to precision
+ @r###"{"data":{"createOneModel":{"float":1.1,"dfloat":2.2,"decFloat":"3.1"}}}"###
+ );
+
+ Ok(())
+ }
+
fn schema_string() -> String {
let schema = indoc! {
r#"model Model {
@@ -154,7 +191,7 @@ mod postgres {
}
// "Other Postgres native types" should "work"
- #[connector_test(schema(schema_other_types))]
+ #[connector_test(schema(schema_other_types), exclude(Cockroach))]
async fn native_other_types(runner: Runner) -> TestResult<()> {
insta::assert_snapshot!(
run_query!(&runner, r#"mutation {
@@ -180,6 +217,45 @@ mod postgres {
Ok(())
}
+ fn schema_other_types_cockroach() -> String {
+ let schema = indoc! {
+ r#"model Model {
+ #id(id, String, @id, @default(cuid()))
+ bool Boolean @test.Boolean
+ byteA Bytes @test.ByteA
+ json Json @test.Json
+ jsonb Json @test.JsonB
+ }"#
+ };
+
+ schema.to_owned()
+ }
+
+ // Cockroach does not support XML.
+ #[connector_test(schema(schema_other_types_cockroach), only(Cockroach))]
+ async fn native_other_types_cockroach(runner: Runner) -> TestResult<()> {
+ insta::assert_snapshot!(
+ run_query!(&runner, r#"mutation {
+ createOneModel(
+ data: {
+ bool: true
+ byteA: "dGVzdA=="
+ json: "{}"
+ jsonb: "{\"a\": \"b\"}"
+ }
+ ) {
+ bool
+ byteA
+ json
+ jsonb
+ }
+ }"#),
+ @r###"{"data":{"createOneModel":{"bool":true,"byteA":"dGVzdA==","json":"{}","jsonb":"{\"a\":\"b\"}"}}}"###
+ );
+
+ Ok(())
+ }
+
fn schema_date() -> String {
let schema = indoc! {
r#"model Model {
