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
86bcda1a
Commit
86bcda1a
authored
7 years ago
by
Cam Saül
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #4761 from metabase/minor-cleanup
Minor code cleanup for #3858
parents
dfe3e963
7ce16a34
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/driver/crate.clj
+7
-7
7 additions, 7 deletions
src/metabase/driver/crate.clj
src/metabase/util/honeysql_extensions.clj
+7
-5
7 additions, 5 deletions
src/metabase/util/honeysql_extensions.clj
with
14 additions
and
12 deletions
src/metabase/driver/crate.clj
+
7
−
7
View file @
86bcda1a
...
...
@@ -60,17 +60,17 @@
(
defn-
describe-table-fields
[
database,
driver,
{
:keys
[
schema
name
]}]
(
let
[
columns
(
jdbc/query
(
sql/db->jdbc-connection-spec
database
)
[(
format
"select column_name, data_type as type_name
(
sql/db->jdbc-connection-spec
database
)
[(
format
"select column_name, data_type as type_name
from information_schema.columns
where table_name like '%s' and table_schema like '%s'
and data_type != 'object_array'"
name
schema
)])]
; clojure jdbc can't handle fields of type "object_array" atm
(
set
(
for
[{
:keys
[
column_name
type_name
]}
columns
]
(
merge
{
:name
column_name
:custom
{
:column-type
type_name
}
:base-type
(
or
(
column->base-type
(
keyword
type_name
))
(
do
(
log/warn
(
format
"Don't know how to map column type '%s' to a Field base_type, falling back to :type/*."
type_name
))
:type/*
))}))))
)
{
:name
column_name
:custom
{
:column-type
type_name
}
:base-type
(
or
(
column->base-type
(
keyword
type_name
))
(
do
(
log/warn
(
format
"Don't know how to map column type '%s' to a Field base_type, falling back to :type/*."
type_name
))
:type/*
))}))))
(
defn-
add-table-pks
[
^
DatabaseMetaData
metadata,
table
]
...
...
This diff is collapsed.
Click to expand it.
src/metabase/util/honeysql_extensions.clj
+
7
−
5
View file @
86bcda1a
...
...
@@ -21,8 +21,10 @@
(
intern
'honeysql.format
'quote-fns
(
assoc
quote-fns
:h2
(
comp
s/upper-case
ansi-quote-fn
))))
;; `:crate` quote style that correctly quotes nested column identifiers
(
defn-
str-insert
"Insert
c
in string
s
at index
i
."
"Insert
C
in string
S
at index
I
."
[
s
c
i
]
(
str
c
(
subs
s
0
i
)
c
(
subs
s
i
)))
...
...
@@ -33,10 +35,10 @@
(
str
\"
s
\"
)
(
str-insert
s
"\""
idx
))))
;; `:crate` quote style that correctly quotes nested column identifiers
(
let
[
quote-fns
@
(
resolve
'honeysql.format
/
quote-fns
)]
(
->>
(
assoc
quote-fns
:crate
crate-column-identifier
)
(
intern
'honeysql.format
'quote-fns
)))
(
let
[
quote-fns
@
(
resolve
'honeysql.format/quote-fns
)]
(
intern
'honeysql.format
'
quote-fns
(
assoc
quote-fns
:crate
crate-column-identifier
)
))
;; register the `extract` function with HoneySQL
;; (hsql/format (hsql/call :extract :a :b)) -> "extract(a from b)"
...
...
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