diff --git a/.gitignore b/.gitignore index 6e24ab4..8357fa3 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ .settings .socket-repl-port .sw* +.vscode *.class *.jar *.swp diff --git a/CHANGELOG.md b/CHANGELOG.md index a84e013..1013985 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changes * 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. * 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. diff --git a/src/honey/sql.cljc b/src/honey/sql.cljc index 3d713e2..66b2e2b 100644 --- a/src/honey/sql.cljc +++ b/src/honey/sql.cljc @@ -870,7 +870,9 @@ :order-by #'format-order-by :limit #'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 :lock #'format-lock-strength :values #'format-values diff --git a/test/honey/sql_test.cljc b/test/honey/sql_test.cljc index d4b635d..75f2197 100644 --- a/test/honey/sql_test.cljc +++ b/test/honey/sql_test.cljc @@ -782,3 +782,8 @@ ORDER BY id = ? DESC :from :bar :join [[{:select :a :from :b :where [:= :id 123]} :x] :y] :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}))))