Skip to content
Snippets Groups Projects
Unverified Commit b53b62b0 authored by github-automation-metabase's avatar github-automation-metabase Committed by GitHub
Browse files

redshift defines "text" as varchar(255) and we want it to be way longer (#49710) (#49728)

parent 33c6105b
No related branches found
No related tags found
No related merge requests found
......@@ -463,7 +463,7 @@
[_driver upload-type]
(case upload-type
::upload/varchar-255 [[:varchar 255]]
::upload/text [:text]
::upload/text [[:varchar 65535]]
::upload/int [:bigint]
;; identity(1, 1) defines an auto-increment column starting from 1
::upload/auto-incrementing-int-pk [:bigint [:identity 1 1]]
......
......@@ -220,7 +220,12 @@
"Luke Skywalker, 172, -19"
"Darth Vader, 202, -41.9"
;; comma, but blank column
"Sebulba, 112,"]))))))
"Sebulba, 112,"]))))
(testing "Longer text is text"
(is (= {:text text-type}
(detect-schema-with-csv-rows
["Text"
(apply str (repeat 30 "some_text "))]))))))
(deftest ^:parallel detect-schema-dates-test
(mt/test-drivers (mt/normal-drivers-with-feature :uploads)
......@@ -1514,19 +1519,20 @@
(testing (action-testing-str action)
(with-uploads-enabled!
(testing "Append should fail only if there are missing columns in the CSV file"
(doseq [[csv-rows error-message]
{[""]
(trim-lines "The CSV file is missing columns that are in the table:
(let [long-text (apply str (repeat 30 "some_text "))] ; more than 256 chars
(doseq [[csv-rows error-message]
{[""]
(trim-lines "The CSV file is missing columns that are in the table:
- id
- name")
;; Extra columns are fine, as long as none are missing.
["_mb_row_id,id,extra 1, extra 2,name"]
nil
["extra 1, extra 2"]
;; TODO note that the order of the fields is reversed
;; It would be better if they were alphabetical, or matched the order in the database / file.
(trim-lines "The CSV file is missing columns that are in the table:
;; Extra columns are fine, as long as none are missing.
["_mb_row_id,id,extra 1, extra 2,name"]
nil
["extra 1, extra 2"]
;; TODO note that the order of the fields is reversed
;; It would be better if they were alphabetical, or matched the order in the database / file.
(trim-lines "The CSV file is missing columns that are in the table:
- id
- name
......@@ -1534,41 +1540,41 @@
- extra_2
- extra_1")
["_mb_row_id,id, extra 2"]
(if (auto-pk-column?)
(trim-lines "The CSV file is missing columns that are in the table:
["_mb_row_id,id, extra 2"]
(if (auto-pk-column?)
(trim-lines "The CSV file is missing columns that are in the table:
- name
There are new columns in the CSV file that are not in the table:
- extra_2")
(trim-lines "The CSV file is missing columns that are in the table:
(trim-lines "The CSV file is missing columns that are in the table:
- name
There are new columns in the CSV file that are not in the table:
- extra_2
- _mb_row_id"))}]
(with-upload-table!
[table (create-upload-table!
{:col->upload-type (ordered-map/ordered-map
:id int-type
:name vchar-type)
:rows [[1, "some_text"]]})]
(let [file (csv-file-with csv-rows)]
(when error-message
(is (= {:message error-message
:data {:status-code 422}}
(catch-ex-info (update-csv! action {:file file :table-id (:id table)}))))
(testing "Check the data was not uploaded into the table"
(is (= [[1 "some_text"]]
(rows-for-table table)))))
(when-not error-message
(testing "Check the data was uploaded into the table"
;; No exception is thrown - but there were also no rows in the table to check
(update-csv! action {:file file :table-id (:id table)})))
(with-upload-table!
[table (create-upload-table!
{:col->upload-type (ordered-map/ordered-map
:id int-type
:name text-type)
:rows [[1 long-text]]})]
(let [file (csv-file-with csv-rows)]
(when error-message
(is (= {:message error-message
:data {:status-code 422}}
(catch-ex-info (update-csv! action {:file file :table-id (:id table)}))))
(testing "Check the data was not uploaded into the table"
(is (= [[1 long-text]]
(rows-for-table table)))))
(when-not error-message
(testing "Check the data was uploaded into the table"
;; No exception is thrown - but there were also no rows in the table to check
(update-csv! action {:file file :table-id (:id table)})))
(io/delete-file file))))))))))
(io/delete-file file)))))))))))
(deftest update-common-types-test
(mt/test-drivers (mt/normal-drivers-with-feature :uploads)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment