Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/binary field schemas #8

Merged
merged 2 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/test-db
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def start_container(name):
proc = subprocess.run(START_COMMAND, shell=True)
if proc.returncode != 0:
sys.exit("Exited with code: {}, the docker process failed to start.".format(proc.returncode))
print("Process started successfully, connect on localhost port 1433")
print("Process started successfully, connect on localhost port {}".format(os.getenv('STITCH_TAP_MSSQL_TEST_DATABASE_PORT', 1433)))

def stop_container(name):
STOP_COMMAND = "sudo docker stop {0} && sudo docker rm {0}"
Expand Down
6 changes: 2 additions & 4 deletions src/tap_mssql/catalog.clj
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,8 @@
"maxLength" (:column_size column)}
"nvarchar" {"type" ["string"]
"maxLength" (:column_size column)}
"binary" {"type" ["string"]
"maxLength" (:column_size column)}
"varbinary" {"type" ["string"]
"maxLength" (:column_size column)}
"binary" {"type" ["string"]}
"varbinary" {"type" ["string"]}
"uniqueidentifier" {"type" ["string"]
;; a string constant in the form
;; xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, in which
Expand Down
20 changes: 8 additions & 12 deletions test/tap_mssql/discover_populated_catalog_datatyping_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -344,28 +344,24 @@
["streams" "datatyping_dbo_character_strings" "schema" "properties" "varchar_max"]))))

(deftest ^:integration verify-binary-strings
(is (= {"type" ["string" "null"]
"maxLength" 1}
;; NB: Because we convert binary strings to hex, max_length is not accurate from the DB
;; - Thus, it should not be included in the schemas
(is (= {"type" ["string" "null"]}
(get-in (catalog/discover test-db-config)
["streams" "datatyping_dbo_binary_strings" "schema" "properties" "binary"])))
(is (= {"type" ["string" "null"]
"maxLength" 1}
(is (= {"type" ["string" "null"]}
(get-in (catalog/discover test-db-config)
["streams" "datatyping_dbo_binary_strings" "schema" "properties" "binary_one"])))
(is (= {"type" ["string" "null"]
"maxLength" 10}
(is (= {"type" ["string" "null"]}
(get-in (catalog/discover test-db-config)
["streams" "datatyping_dbo_binary_strings" "schema" "properties" "binary_10"])))
(is (= {"type" ["string" "null"]
"maxLength" 1}
(is (= {"type" ["string" "null"]}
(get-in (catalog/discover test-db-config)
["streams" "datatyping_dbo_binary_strings" "schema" "properties" "varbinary"])))
(is (= {"type" ["string" "null"]
"maxLength" 1}
(is (= {"type" ["string" "null"]}
(get-in (catalog/discover test-db-config)
["streams" "datatyping_dbo_binary_strings" "schema" "properties" "varbinary_one"])))
(is (= {"type" ["string" "null"]
"maxLength" 2147483647}
(is (= {"type" ["string" "null"]}
(get-in (catalog/discover test-db-config)
["streams" "datatyping_dbo_binary_strings" "schema" "properties" "varbinary_max"]))))

Expand Down