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
96bb2ee6
Unverified
Commit
96bb2ee6
authored
6 years ago
by
Cam Saul
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #9254 from metabase/paychex-binning_ratio_fix
Paychex binning ratio fix
parents
8ddbee2a
7d6c0383
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/util/honeysql_extensions.clj
+6
-0
6 additions, 0 deletions
src/metabase/util/honeysql_extensions.clj
test/metabase/util/honeysql_extensions_test.clj
+9
-2
9 additions, 2 deletions
test/metabase/util/honeysql_extensions_test.clj
with
15 additions
and
2 deletions
src/metabase/util/honeysql_extensions.clj
+
6
−
0
View file @
96bb2ee6
...
...
@@ -45,6 +45,12 @@
java.lang.Number
(
to-sql
[
x
]
(
str
x
)))
;; Ratios are represented as the division of two numbers which may cause order-of-operation issues when dealing with
;; queries. The easiest way around this is to convert them to their decimal representations.
(
extend-protocol
honeysql.format/ToSql
clojure.lang.Ratio
(
to-sql
[
x
]
(
hformat/to-sql
(
double
x
))))
;; HoneySQL automatically assumes that dots within keywords are used to separate schema / table / field / etc. To
;; handle weird situations where people actually put dots *within* a single identifier we'll replace those dots with
;; lozenges, let HoneySQL do its thing, then switch them back at the last second
...
...
This diff is collapsed.
Click to expand it.
test/metabase/util/honeysql_extensions_test.clj
+
9
−
2
View file @
96bb2ee6
(
ns
metabase.util.honeysql-extensions-test
(
:require
[
expectations
:refer
:all
]
[
honeysql.format
:as
hformat
]
[
metabase.util.honeysql-extensions
:as
hsql-ext
])
[
honeysql
[
core
:as
hsql
]
[
format
:as
hformat
]])
(
:import
java.util.Locale
))
;; Basic format test not including a specific quoting option
...
...
@@ -35,3 +36,9 @@
[
"\"SETTING\""
]
(
with-locale
"tr"
(
hformat/format
:setting
:quoting
:h2
)))
;; test ToSql behavior for Ratios (#9246). Should convert to a double rather than leaving it as a division operation.
;; The double itself should get converted to a numeric literal
(
expect
[
"SELECT 0.1 AS one_tenth"
]
(
hsql/format
{
:select
[[(
/
1
10
)
:one_tenth
]]}))
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