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
889df7f7
Commit
889df7f7
authored
8 years ago
by
Cam Saül
Browse files
Options
Downloads
Patches
Plain Diff
A few indentation fixes and other minor cleanup
parent
e72be01a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/driver/generic_sql/query_processor.clj
+17
-15
17 additions, 15 deletions
src/metabase/driver/generic_sql/query_processor.clj
with
17 additions
and
15 deletions
src/metabase/driver/generic_sql/query_processor.clj
+
17
−
15
View file @
889df7f7
...
...
@@ -297,34 +297,36 @@
(
with-out-str
(
jdbc/print-sql-exception-chain
e
))))
(
f
))))
(
defn-
exception->nice-error-message
^
String
[
^
java.sql.SQLException
e
]
(
or
(
->>
(
.getMessage
e
)
; error message comes back like "Error message ... [status-code]" sometimes
(
re-find
#
"(?s)(^.*)\s+\[[\d-]+\]$"
)
; status code isn't useful and makes unit tests hard to write so strip it off
second
)
; (?s) = Pattern.DOTALL - tell regex `.` to match newline characters as well
(
.getMessage
e
)))
(
defn-
do-with-try-catch
[
f
]
(
try
(
f
)
(
catch
java.sql.SQLException
e
(
jdbc/print-sql-exception-chain
e
)
(
let
[
^
String
message
(
or
(
->>
(
.getMessage
e
)
; error message comes back like "Error message ... [status-code]" sometimes
(
re-find
#
"(?s)(^.*)\s+\[[\d-]+\]$"
)
; status code isn't useful and makes unit tests hard to write so strip it off
second
)
; (?s) = Pattern.DOTALL - tell regex `.` to match newline characters as well
(
.getMessage
e
))]
(
throw
(
Exception.
message
))))))
(
throw
(
Exception.
(
exception->nice-error-message
e
))))))
(
defn
build-korma-form
"Build the korma form we will call `k/exec` on."
[
driver
{
inner-query
:query
:as
outer-query
}
entity
]
(
binding
[
*query*
outer-query
]
(
apply-clauses
driver
(
k/select*
entity
)
inner-query
)))
(
apply-clauses
driver
(
k/select*
entity
)
inner-query
)))
(
defn
process-mbql
"Convert QUERY into a korma `select` form, execute it, and annotate the results."
[
driver
{{
:keys
[
source-table
]}
:query,
database
:database,
settings
:settings,
:as
outer-query
}]
(
let
[
timezone
(
:report-timezone
settings
)
entity
((
resolve
'metabase.driver.generic-sql/korma-entity
)
database
source-table
)
korma-form
(
build-korma-form
driver
outer-query
entity
)
f
(
partial
k/exec
korma-form
)
f
(
fn
[]
(
kdb/with-db
(
:db
entity
)
(
if
(
seq
timezone
)
(
do-with-timezone
driver
timezone
f
)
(
f
))))]
(
let
[
timezone
(
:report-timezone
settings
)
entity
((
resolve
'metabase.driver.generic-sql/korma-entity
)
database
source-table
)
korma-form
(
build-korma-form
driver
outer-query
entity
)
f
(
partial
k/exec
korma-form
)
f
(
fn
[]
(
kdb/with-db
(
:db
entity
)
(
if
(
seq
timezone
)
(
do-with-timezone
driver
timezone
f
)
(
f
))))]
(
log-korma-form
korma-form
)
(
do-with-try-catch
f
)))
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