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
15f4c278
Unverified
Commit
15f4c278
authored
1 year ago
by
metamben
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Ensure testing select privilege works with and without auto commit (#36062)
parent
1643b157
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/driver/sql_jdbc/sync/describe_database.clj
+2
-1
2 additions, 1 deletion
src/metabase/driver/sql_jdbc/sync/describe_database.clj
test/metabase/driver/sql_jdbc/sync/describe_database_test.clj
+25
-0
25 additions, 0 deletions
.../metabase/driver/sql_jdbc/sync/describe_database_test.clj
with
27 additions
and
1 deletion
src/metabase/driver/sql_jdbc/sync/describe_database.clj
+
2
−
1
View file @
15f4c278
...
...
@@ -95,7 +95,8 @@
true
(
catch
Throwable
e
(
log/trace
e
"Assuming no SELECT privileges: caught exception"
)
(
.rollback
conn
)
(
when-not
(
.getAutoCommit
conn
)
(
.rollback
conn
))
false
))))
(
defn-
db-tables
...
...
This diff is collapsed.
Click to expand it.
test/metabase/driver/sql_jdbc/sync/describe_database_test.clj
+
25
−
0
View file @
15f4c278
...
...
@@ -10,6 +10,7 @@
[
metabase.driver.util
:as
driver.u
]
[
metabase.models
:refer
[
Database
Table
]]
[
metabase.query-processor
:as
qp
]
[
metabase.query-processor.store
:as
qp.store
]
[
metabase.sync
:as
sync
]
[
metabase.test
:as
mt
]
[
metabase.test.data.one-off-dbs
:as
one-off-dbs
]
...
...
@@ -183,3 +184,27 @@
(
fn
[{
schema-name
:schema
}]
(
testing
(
format
"schema name = %s"
(
pr-str
schema-name
))
(
is
(
not=
\v
(
first
schema-name
)))))))))))
(
deftest
have-select-privilege?-test
(
testing
"cheking select privilege works with and without auto commit (#36040)"
(
let
[
default-have-slect-privilege?
#
(
identical?
(
get-method
sql-jdbc.sync.interface/have-select-privilege?
:sql-jdbc
)
(
get-method
sql-jdbc.sync.interface/have-select-privilege?
%
))]
(
mt/test-drivers
(
into
#
{}
(
filter
default-have-slect-privilege?
)
(
descendants
driver/hierarchy
:sql-jdbc
))
(
let
[{
schema
:schema,
table-name
:name
}
(
t2/select-one
:model/Table
(
mt/id
:users
))]
(
qp.store/with-metadata-provider
(
mt/id
)
(
testing
(
sql-jdbc.describe-database/simple-select-probe-query
driver/*driver*
schema
table-name
)
(
doseq
[
auto-commit
[
true
false
]]
(
testing
(
pr-str
{
:auto-commit
auto-commit
:schema
schema
:name
table-name
})
(
sql-jdbc.execute/do-with-connection-with-options
driver/*driver*
(
mt/db
)
nil
(
fn
[
^
java.sql.Connection
conn
]
(
.setAutoCommit
conn
auto-commit
)
(
is
(
false?
(
sql-jdbc.sync.interface/have-select-privilege?
driver/*driver*
conn
schema
(
str
table-name
"_should_not_exist"
))))
(
is
(
true?
(
sql-jdbc.sync.interface/have-select-privilege?
driver/*driver*
conn
schema
table-name
))))))))))))))
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