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
5d1fa636
Commit
5d1fa636
authored
10 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Move class->base-type mapping into driver since mongo driver *and*
generic SQL will share it. Add Mongo lib dependency
parent
188adb07
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
project.clj
+1
-0
1 addition, 0 deletions
project.clj
src/metabase/driver.clj
+19
-2
19 additions, 2 deletions
src/metabase/driver.clj
src/metabase/driver/generic_sql/native.clj
+3
-15
3 additions, 15 deletions
src/metabase/driver/generic_sql/native.clj
with
23 additions
and
17 deletions
project.clj
+
1
−
0
View file @
5d1fa636
...
...
@@ -28,6 +28,7 @@
[
com.cemerick/friend
"0.2.1"
]
; auth library
[
com.h2database/h2
"1.4.186"
]
; embedded SQL database
[
com.mattbertolini/liquibase-slf4j
"1.2.1"
]
[
com.novemberain/monger
"2.1.0"
]
; MongoDB Driver
[
compojure
"1.3.3"
]
; HTTP Routing library built on Ring
[
environ
"1.0.0"
]
; easy environment management
[
hiccup
"1.0.5"
]
; HTML templating
...
...
This diff is collapsed.
Click to expand it.
src/metabase/driver.clj
+
19
−
2
View file @
5d1fa636
...
...
@@ -14,6 +14,8 @@
(
declare
-dataset-query
query-fail
query-complete
save-query-execution
)
;; ## Constants
(
def
^
:const
available-drivers
"DB drivers that are available as a dictionary. Each key is a driver with dictionary of attributes.
ex: `:h2 {:id \"h2\" :name \"H2\"}`"
...
...
@@ -22,7 +24,23 @@
:example
"file:[filename]"
}
:postgres
{
:id
"postgres"
:name
"Postgres"
:example
"host=[ip address] port=5432 dbname=examples user=corvus password=******"
}})
:example
"host=[ip address] port=5432 dbname=examples user=corvus password=******"
}
:mongo
{
:id
"mongo"
:name
"MongoDB"
:example
"mongodb://password:username@127.0.0.1:27017/db-name"
}})
(
def
^
:const
class->base-type
"Map of classes returned from DB call to metabase.models.field/base-types"
{
java.lang.Boolean
:BooleanField
java.lang.Double
:FloatField
java.lang.Float
:FloatField
java.lang.Integer
:IntegerField
java.lang.Long
:IntegerField
java.lang.String
:TextField
java.math.BigDecimal
:DecimalField
java.math.BigInteger
:BigIntegerField
java.sql.Date
:DateField
java.sql.Timestamp
:DateTimeField
})
;; ## Driver Lookup
...
...
@@ -208,7 +226,6 @@
(
select-keys
[
:id
:uuid
])
(
merge
query-result
)))
(
defn
save-query-execution
[{
:keys
[
id
]
:as
query-execution
}]
(
if
id
...
...
This diff is collapsed.
Click to expand it.
src/metabase/driver/generic_sql/native.clj
+
3
−
15
View file @
5d1fa636
...
...
@@ -6,22 +6,10 @@
(
korma
[
core
:as
korma
]
db
)
[
metabase.db
:refer
[
sel
]]
[
metabase.driver
:as
driver
]
[
metabase.driver.generic-sql.util
:refer
:all
]
[
metabase.models.database
:refer
[
Database
]]))
(
def
^
:const
class->base-type
"Map of classes returned from DB call to metabase.models.field/base-types"
{
java.lang.Boolean
:BooleanField
java.lang.Double
:FloatField
java.lang.Float
:FloatField
java.lang.Integer
:IntegerField
java.lang.Long
:IntegerField
java.lang.String
:TextField
java.math.BigDecimal
:DecimalField
java.math.BigInteger
:BigIntegerField
java.sql.Date
:DateField
java.sql.Timestamp
:DateTimeField
})
(
def
^
:dynamic
*timezone->set-timezone-sql*
" This function is called whenever `timezone` is specified in a native query, at the beginning of
the DB transaction.
...
...
@@ -38,8 +26,8 @@
"Attempt to match a value we get back from the DB with the corresponding base-type`."
[
v
]
(
if-not
v
:UnknownField
(
or
(
class->base-type
(
type
v
))
(
throw
(
ApiException.
(
int
500
)
(
format
"Missing base type mapping for %s in
metabase.driver.generic-sql.native
/class->base-type. Please add an entry."
(
or
(
driver/
class->base-type
(
type
v
))
(
throw
(
ApiException.
(
int
500
)
(
format
"Missing base type mapping for %s in
driver
/class->base-type. Please add an entry."
(
str
(
type
v
))))))))
(
defn
process-and-run
...
...
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