Skip to content

Commit

Permalink
Refactor format-values to do fewer allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-yakushev committed Jan 8, 2025
1 parent 85fe259 commit b2a105d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changes

* 2.6.next in progress
* More performance optimizations via PR [#560](https://github.com/seancorfield/honeysql/pull/560) [@alexander-yakushev](https://github.com/alexander-yakushev).
* More performance optimizations via PRs [#560](https://github.com/seancorfield/honeysql/pull/560) and [#561](https://github.com/seancorfield/honeysql/pull/561) [@alexander-yakushev](https://github.com/alexander-yakushev).
* Fix two broken links to the [HoneySQL web app](https://john.shaffe.rs/honeysql/) via PR [#559](https://github.com/seancorfield/honeysql/pull/559) [@whatacold](https://github.com/whatacold).
* Make SQL Server dialect auto-lift Boolean values to parameters since SQL Server has no `TRUE` / `FALSE` literals.

Expand Down
60 changes: 30 additions & 30 deletions src/honey/sql.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1177,17 +1177,17 @@
x))
xs)))
[sqls params]
(reduce (fn [[sql params] [sqls' params']]
[(conj sql
(if (sequential? sqls')
(str "(" (join ", " sqls') ")")
sqls'))
(into params params')])
(reduce (fn [[sql params] x]
(if (sequential? x)
(let [[sqls' params'] (format-expr-list x)]
[(conj sql
(if (sequential? sqls')
(str "(" (join ", " sqls') ")")
sqls'))
(into* params params')])
[(conj (sql-kw x)) params]))
[[] []]
(map #(if (sequential? %)
(format-expr-list %)
[(sql-kw %)])
xs'))
xs')
sqls (if row-ctr (map #(str "ROW" %) sqls) sqls)]
(into [(str (sql-kw k) " " (join ", " sqls))] params))

Expand All @@ -1199,26 +1199,26 @@
(contains-clause? :replace-into)
(contains-clause? :columns)))
[sqls params]
(reduce (fn [[sql params] [sqls' params']]
[(conj sql
(if (sequential? sqls')
(str "(" (join ", " sqls') ")")
sqls'))
(if params' (into params params') params')])
[[] []]
(map (fn [m]
(if (map? m)
(format-expr-list
(map #(get m
%
;; issue #366: use NULL or DEFAULT
;; for missing column values:
(if (contains? *values-default-columns* %)
[:default]
nil))
cols))
[(sql-kw m)]))
xs))]
(reduce
(fn [[sql params] x]
(if (map? x)
(let [[sqls' params']
(reduce-sql (map #(format-expr
(get x %
;; issue #366: use NULL or DEFAULT
;; for missing column values:
(if (contains? *values-default-columns* %)
[:default]
nil))))
cols)]
[(conj sql
(if (sequential? sqls')
(str "(" (join ", " sqls') ")")
sqls'))
(into* params params')])
[(conj sql (sql-kw x)) params]))
[[] []]
xs)]
(into [(str (when cols-sql
(str cols-sql " "))
(sql-kw k)
Expand Down

0 comments on commit b2a105d

Please sign in to comment.