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
1e93aa5c
Commit
1e93aa5c
authored
8 years ago
by
Cam Saül
Browse files
Options
Downloads
Patches
Plain Diff
Fix handling dots in identifiers
parent
109e9c3d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/metabase/driver/generic_sql.clj
+8
-7
8 additions, 7 deletions
src/metabase/driver/generic_sql.clj
src/metabase/driver/h2.clj
+3
-2
3 additions, 2 deletions
src/metabase/driver/h2.clj
test/metabase/test/data/generic_sql.clj
+5
-5
5 additions, 5 deletions
test/metabase/test/data/generic_sql.clj
with
16 additions
and
14 deletions
src/metabase/driver/generic_sql.clj
+
8
−
7
View file @
1e93aa5c
...
...
@@ -183,13 +183,14 @@
"Convert HONEYSQL-FORM to a vector of SQL string and params, like you'd pass to JDBC."
[
driver
honeysql-form
]
{
:pre
[(
map?
honeysql-form
)]}
(
try
(
binding
[
hformat/*subquery?*
false
]
(
hsql/format
honeysql-form
:quoting
(
quote-style
driver
)
:allow-dashed-names?
true
))
(
catch
Throwable
e
(
log/error
(
u/format-color
'red
"Invalid HoneySQL form:\n%s"
(
u/pprint-to-str
honeysql-form
)))
(
throw
e
))))
(
let
[[
sql
&
args
]
(
try
(
binding
[
hformat/*subquery?*
false
]
(
hsql/format
honeysql-form
:quoting
(
quote-style
driver
)
:allow-dashed-names?
true
))
(
catch
Throwable
e
(
log/error
(
u/format-color
'red
"Invalid HoneySQL form:\n%s"
(
u/pprint-to-str
honeysql-form
)))
(
throw
e
)))]
(
into
[(
hx/unescape-dots
sql
)]
args
)))
(
defn-
qualify+escape
^
clojure.lang.Keyword
([
table
]
...
...
This diff is collapsed.
Click to expand it.
src/metabase/driver/h2.clj
+
3
−
2
View file @
1e93aa5c
...
...
@@ -104,8 +104,9 @@
"ACCESS_MODE_DATA"
"r"
}))))
(
defn-
connection-details->spec
[
_
details
]
(
dbspec/h2
(
if
db/*allow-potentailly-unsafe-connections*
details
(
update
details
:db
connection-string-set-safe-options
))))
(
dbspec/h2
(
if
db/*allow-potentailly-unsafe-connections*
details
(
update
details
:db
connection-string-set-safe-options
))))
(
defn-
unix-timestamp->timestamp
[
_
expr
seconds-or-milliseconds
]
...
...
This diff is collapsed.
Click to expand it.
test/metabase/test/data/generic_sql.clj
+
5
−
5
View file @
1e93aa5c
...
...
@@ -43,7 +43,7 @@
"*Optional* Return a `CREATE TABLE` statement."
)
(
drop-table-if-exists-sql
^
String
[
this,
^
DatabaseDefinition
dbdef,
^
TableDefinition
tabledef
]
"*Optional* Return a `DROP TABLE IF EXISTS` statement."
)
"*Optional* Return a `DROP TABLE IF EXISTS` statement."
)
(
add-fk-sql
^
String
[
this,
^
DatabaseDefinition
dbdef,
^
TableDefinition
tabledef,
^
FieldDefinition
fielddef
]
"*Optional* Return a `ALTER TABLE ADD CONSTRAINT FOREIGN KEY` statement."
)
...
...
@@ -85,7 +85,7 @@
"*Optional*. Load the rows for a specific table into a DB. `load-data-chunked` is the default implementation."
)
(
execute-sql!
[
driver
^
Keyword
context,
^
DatabaseDefinition
dbdef,
^
String
sql
]
"Execute a string of raw SQL. Context is either `:server` or `:db`."
))
"
*Optional*.
Execute a string of raw SQL. Context is either `:server` or `:db`."
))
(
defn-
default-create-db-sql
[
driver
{
:keys
[
database-name
]}]
...
...
@@ -205,7 +205,7 @@
(
defn-
do-insert!
"Insert ROWS-OR-ROWS into TABLE-NAME for the DRIVER database defined by SPEC."
[
driver
spec
table-name
row-or-rows
]
(
let
[
prepare-key
(
comp
keyword
(
partial
prepare-identifier
driver
)
name
)
(
let
[
prepare-key
(
comp
keyword
(
partial
prepare-identifier
driver
)
hx/escape-dots
name
)
rows
(
if
(
sequential?
row-or-rows
)
row-or-rows
[
row-or-rows
])
...
...
@@ -305,8 +305,8 @@
;; Add the SQL for creating each Table
(
doseq
[
tabledef
table-definitions
]
(
swap!
statements
conj
(
drop-table-if-exists-sql
driver
dbdef
tabledef
)
)
(
swap!
statements
conj
(
create-table-sql
driver
dbdef
tabledef
)))
(
swap!
statements
conj
(
drop-table-if-exists-sql
driver
dbdef
tabledef
)
(
create-table-sql
driver
dbdef
tabledef
)))
;; Add the SQL for adding FK constraints
(
doseq
[{
:keys
[
field-definitions
]
,
:as
tabledef
}
table-definitions
]
...
...
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