diff --git a/src/metabase/driver/sql_jdbc/sync/describe_table.clj b/src/metabase/driver/sql_jdbc/sync/describe_table.clj index 94aacee1dae07243fd8e1af6f667c67abdc9c43e..4caef482a127b746d7510af2b7ea5d69da9d35a7 100644 --- a/src/metabase/driver/sql_jdbc/sync/describe_table.clj +++ b/src/metabase/driver/sql_jdbc/sync/describe_table.clj @@ -297,8 +297,10 @@ {java.lang.String :type/Text ;; JSON itself has the single number type, but Java serde of JSON is stricter java.lang.Long :type/Integer + clojure.lang.BigInt :type/BigInteger java.lang.Integer :type/Integer java.lang.Double :type/Float + java.math.BigDecimal :type/Decimal java.lang.Number :type/Number java.lang.Boolean :type/Boolean java.time.LocalDateTime :type/DateTime @@ -312,8 +314,10 @@ although as of writing this is just geared towards Postgres types" {:type/Text "text" :type/Integer "integer" + :type/BigInteger "bigint" :type/Float "double precision" :type/Number "double precision" + :type/Decimal "decimal" :type/Boolean "boolean" :type/DateTime "timestamp" :type/Array "text" diff --git a/test/metabase/driver/postgres_test.clj b/test/metabase/driver/postgres_test.clj index fd46963ea4f5c74cd13eee8f425007e3fee2667e..4b3c758c4b819d60a4d52ca88fda479edfedac54 100644 --- a/test/metabase/driver/postgres_test.clj +++ b/test/metabase/driver/postgres_test.clj @@ -298,6 +298,10 @@ (testing "Give us a boolean cast when the field is boolean" (let [boolean-boop-field {:database_type "boolean" :nfc_path [:bleh "boop" :foobar 1234]}] (is (= ["(boop.bleh#>> ?::text[])::boolean " "{boop,foobar,1234}"] + (hsql/format (#'sql.qp/json-query :postgres boop-identifier boolean-boop-field)))))) + (testing "Give us a bigint cast when the field is bigint (#22732)" + (let [boolean-boop-field {:database_type "bigint" :nfc_path [:bleh "boop" :foobar 1234]}] + (is (= ["(boop.bleh#>> ?::text[])::bigint " "{boop,foobar,1234}"] (hsql/format (#'sql.qp/json-query :postgres boop-identifier boolean-boop-field)))))))) (deftest json-alias-test diff --git a/test/metabase/driver/sql_jdbc/sync/describe_table_test.clj b/test/metabase/driver/sql_jdbc/sync/describe_table_test.clj index 983dc893e44e64e18a27091ff1b4c7823ed5c474..dcc1c291633ce5d6ca1a6b1de42105316c4ac766 100644 --- a/test/metabase/driver/sql_jdbc/sync/describe_table_test.clj +++ b/test/metabase/driver/sql_jdbc/sync/describe_table_test.clj @@ -80,7 +80,12 @@ (let [arr-row {:bob [:bob :cob :dob 123 "blob"]} obj-row {:zlob {"blob" 1323}}] (is (= {} (#'sql-jdbc.describe-table/row->types arr-row))) - (is (= {[:zlob "blob"] java.lang.Long} (#'sql-jdbc.describe-table/row->types obj-row)))))) + (is (= {[:zlob "blob"] java.lang.Long} (#'sql-jdbc.describe-table/row->types obj-row))))) + (testing "JSON row->types handles bigint OK (#21752)" + (let [int-row {:zlob {"blob" 123N}} + float-row {:zlob {"blob" 1234.02M}}] + (is (= {[:zlob "blob"] clojure.lang.BigInt} (#'sql-jdbc.describe-table/row->types int-row))) + (is (= {[:zlob "blob"] java.math.BigDecimal} (#'sql-jdbc.describe-table/row->types float-row)))))) (deftest dont-parse-long-json-xform-test (testing "obnoxiously long json should not even get parsed (#22636)"