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
089ff02d
Unverified
Commit
089ff02d
authored
8 years ago
by
Cam Saül
Browse files
Options
Downloads
Patches
Plain Diff
Clarify comment about "shameless hack"
parent
4c2f9f74
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/driver/oracle.clj
+6
-5
6 additions, 5 deletions
src/metabase/driver/oracle.clj
with
6 additions
and
5 deletions
src/metabase/driver/oracle.clj
+
6
−
5
View file @
089ff02d
...
...
@@ -111,15 +111,16 @@
:milliseconds
(
hx//
field-or-value
(
hsql/raw
1000
))))))
(
defn-
apply-offset-and-limit
"Append SQL like `OFFSET 20 FETCH
FIRS
T 10 ROWS ONLY` to the query."
"Append SQL like `OFFSET 20
ROWS
FETCH
NEX
T 10 ROWS ONLY` to the
end of the
query."
[
honeysql-query
offset
limit
]
(
assoc
honeysql-query
:offset
(
hsql/raw
(
format
"%d ROWS FETCH NEXT %d ROWS ONLY"
offset
limit
)
)))
:offset
(
hsql/raw
(
format
"%d ROWS FETCH NEXT %d ROWS ONLY"
offset
limit
))))
(
defn-
apply-limit
[
honeysql-query
{
value
:limit
}]
;; Shameless hack! FETCH FIRST ... ROWS ONLY needs to go on the end of the query. Korma doesn't have any built-in
;; way to do this but we can use `k/offset` and set it to 0.
;; OFFSET 0 FETCH FIRST <value> ROWS ONLY
;; HoneySQL doesn't support ANSI SQL "OFFSET <n> ROWS FETCH NEXT <n> ROWS ONLY"
;; The semi-official workaround as suggested by yours truly is just to pass a raw string as the `:offset`
;; which HoneySQL put in the appropriate place
;; see my comment here: https://github.com/jkk/honeysql/issues/58#issuecomment-220450400
(
apply-offset-and-limit
honeysql-query
0
value
))
(
defn-
apply-page
[
honeysql-query
{{
:keys
[
items
page
]}
:page
}]
...
...
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