Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
67eb9b63
Commit
67eb9b63
authored
6 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Test to confirm Postgres propertly handles identifiers with hyphens
[ci postgres]
parent
b4286b2f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/metabase/driver/postgres_test.clj
+27
-2
27 additions, 2 deletions
test/metabase/driver/postgres_test.clj
with
27 additions
and
2 deletions
test/metabase/driver/postgres_test.clj
+
27
−
2
View file @
67eb9b63
...
...
@@ -188,8 +188,8 @@
FROM pg_stat_activity
WHERE pg_stat_activity.datname = ?;"
db-name
])
;; create the DB
(
jdbc/execute!
spec
[(
format
"DROP DATABASE IF EXISTS
%s
;
CREATE DATABASE
%s
;"
(
jdbc/execute!
spec
[(
format
"DROP DATABASE IF EXISTS
\"%s\"
;
CREATE DATABASE
\"%s\"
;"
db-name
db-name
)]
{
:transaction?
false
})))
...
...
@@ -421,3 +421,28 @@
:limit
10
}})
:data
(
select-keys
[
:rows
:native_form
]))))))
;; make sure schema/table/field names with hyphens in them work correctly (#8766)
(
expect-with-driver
:postgres
[[
"Bird Hat"
]]
(
metabase.driver/with-driver
:postgres
[{
:name
"angry_birds"
,
:active
true
}]
(
let
[
details
(
tx/dbdef->connection-details
:postgres
:db
{
:database-name
"hyphen-names-test"
})
spec
(
sql-jdbc.conn/connection-details->spec
:postgres
details
)
exec!
#
(
doseq
[
statement
%
]
(
jdbc/execute!
spec
[
statement
]))]
;; create the postgres DB
(
drop-if-exists-and-create-db!
"hyphen-names-test"
)
;; create the DB object
(
tt/with-temp
Database
[
database
{
:engine
:postgres,
:details
(
assoc
details
:dbname
"hyphen-names-test"
)}]
(
let
[
sync!
#
(
sync/sync-database!
database
)]
;; populate the DB and create a view
(
exec!
[
"CREATE SCHEMA \"x-mas\";"
"CREATE TABLE \"x-mas\".\"presents-and-gifts\" (\"gift-description\" TEXT NOT NULL);"
"INSERT INTO \"x-mas\".\"presents-and-gifts\" (\"gift-description\") VALUES ('Bird Hat');;"
])
(
sync!
)
(
->
(
qp/process-query
{
:database
(
u/get-id
database
)
:type
:query
:query
{
:source-table
(
db/select-one-id
Table
:name
"presents-and-gifts"
)}})
rows
))))))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment