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
90104394
Commit
90104394
authored
8 years ago
by
Michael Beer
Browse files
Options
Downloads
Patches
Plain Diff
fixed some code indentation
parent
3502a081
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/crate.clj
+15
-12
15 additions, 12 deletions
src/metabase/driver/crate.clj
src/metabase/util/honeysql_extensions.clj
+4
-4
4 additions, 4 deletions
src/metabase/util/honeysql_extensions.clj
with
19 additions
and
16 deletions
src/metabase/driver/crate.clj
+
15
−
12
View file @
90104394
(
ns
metabase.driver.crate
(
:require
[
clojure.java.jdbc
:as
jdbc
]
[
clojure.tools.logging
:as
log
]
[
honeysql.core
:as
hsql
]
[
metabase.driver
:as
driver
]
[
metabase.driver.crate.util
:as
crate-util
]
[
metabase.driver.generic-sql
:as
sql
]
[
metabase.util
:as
u
]
[
clojure.tools.logging
:as
log
])
[
metabase.util
:as
u
])
(
:import
java.sql.DatabaseMetaData
))
(
def
^
:private
^
:const
column->base-type
...
...
@@ -61,14 +61,16 @@
[
database,
driver,
{
:keys
[
schema
name
]}]
(
let
[
columns
(
jdbc/query
(
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'"
name
schema
)])]
[(
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/*
))})))))
(
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/*
))})))))
(
defn-
add-table-pks
[
^
DatabaseMetaData
metadata,
table
]
...
...
@@ -84,9 +86,10 @@
(
defn-
describe-table
[
driver
database
table
]
(
sql/with-metadata
[
metadata
driver
database
]
(
->>
(
assoc
(
select-keys
table
[
:name
:schema
])
:fields
(
describe-table-fields
database
driver
table
))
;; find PKs and mark them
(
add-table-pks
metadata
))))
(
->>
(
describe-table-fields
database
driver
table
)
(
assoc
(
select-keys
table
[
:name
:schema
])
:fields
)
;; find PKs and mark them
(
add-table-pks
metadata
))))
(
defrecord
CrateDriver
[]
clojure.lang.Named
...
...
This diff is collapsed.
Click to expand it.
src/metabase/util/honeysql_extensions.clj
+
4
−
4
View file @
90104394
...
...
@@ -30,13 +30,13 @@
[
^
CharSequence
s
]
(
let
[
idx
(
s/index-of
s
"["
)]
(
if
(
nil?
idx
)
(
str
\"
s
\"
)
(
str-insert
s
"\""
idx
))))
(
str
\"
s
\"
)
(
str-insert
s
"\""
idx
))))
;; `:crate` quote style that correctly quotes nested column identifiers
(
let
[
quote-fns
@
(
resolve
'honeysql.format/quote-fns
)]
(
intern
'honeysql.format
'quote-fns
(
assoc
quote-fns
:crate
crate-column-identifier
)))
(
->>
(
assoc
quote-fns
:crate
crate-column-identifier
)
(
intern
'honeysql.format
'quote-fns
)))
;; 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