fixes #338 by adding ONLY to :fetch

This commit is contained in:
Sean Corfield 2021-07-17 13:32:43 -07:00
parent 994f166d40
commit 7e84b58463
4 changed files with 10 additions and 1 deletions

1
.gitignore vendored
View file

@ -11,6 +11,7 @@
.settings .settings
.socket-repl-port .socket-repl-port
.sw* .sw*
.vscode
*.class *.class
*.jar *.jar
*.swp *.swp

View file

@ -1,6 +1,7 @@
# Changes # Changes
* 2.0.next in progress (2.x will be VGN only) * 2.0.next in progress (2.x will be VGN only)
* Fix #338 by adding `ONLY` to `:fetch`.
* Fix #337 by switching to `clojure.test` even for ClojureScript. * Fix #337 by switching to `clojure.test` even for ClojureScript.
* Address #330 by improving exception when a non-entity is encountered where an entity is expected. * Address #330 by improving exception when a non-entity is encountered where an entity is expected.
* Fix bug in unrolling nested argument to `with-columns` helper. * Fix bug in unrolling nested argument to `with-columns` helper.

View file

@ -870,7 +870,9 @@
:order-by #'format-order-by :order-by #'format-order-by
:limit #'format-on-expr :limit #'format-on-expr
:offset #'format-on-expr :offset #'format-on-expr
:fetch #'format-on-expr :fetch (fn [_ x]
(let [[sql & params] (format-on-expr :fetch x)]
(into [(str sql " " (sql-kw :only))] params)))
:for #'format-lock-strength :for #'format-lock-strength
:lock #'format-lock-strength :lock #'format-lock-strength
:values #'format-values :values #'format-values

View file

@ -782,3 +782,8 @@ ORDER BY id = ? DESC
:from :bar :from :bar
:join [[{:select :a :from :b :where [:= :id 123]} :x] :y] :join [[{:select :a :from :b :where [:= :id 123]} :x] :y]
:where [:= :id 456]}))))) :where [:= :id 456]})))))
(deftest fetch-offset-issue338
(is (= ["SELECT foo FROM bar OFFSET ? FETCH ? ONLY" 20 10]
(format {:select :foo :from :bar
:fetch 10 :offset 20}))))