Fixes #280 by adding [:escape pattern chars]
This commit is contained in:
parent
ddebda9481
commit
d35d9141bc
4 changed files with 22 additions and 0 deletions
|
|
@ -1,10 +1,14 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
* 2.0.0-alpha3 in progress
|
* 2.0.0-alpha3 in progress
|
||||||
|
* Support much richer range of syntax on `CREATE`/`DROP` statements in general, including columns, `TABLESPACE`, `CASCADE`, `WITH [NO] DATA`, etc.
|
||||||
|
* Fix #306 by supporting `CREATE TABLE .. AS ..`.
|
||||||
* Fix #305 by supporting more complex join clauses.
|
* Fix #305 by supporting more complex join clauses.
|
||||||
|
* Fix #301 by adding support for `CREATE`/`DROP`/`REFRESH` on `MATERIALIZED VIEW`.
|
||||||
* Add tests to confirm #299 does not affect v2.
|
* Add tests to confirm #299 does not affect v2.
|
||||||
* Confirm the whole of the [nilenso/honeysql-postgres](https://github.com/nilenso/honeysql-postgres) is implemented out-of-the-box (#293).
|
* Confirm the whole of the [nilenso/honeysql-postgres](https://github.com/nilenso/honeysql-postgres) is implemented out-of-the-box (#293).
|
||||||
* Reconcile `where` behavior with recent 1.0 changes (porting #283 to v2).
|
* Reconcile `where` behavior with recent 1.0 changes (porting #283 to v2).
|
||||||
|
* Fix #280 by adding `:escape` as special syntax for regular expression patterns.
|
||||||
* Fix #277 by adding `:join-by`/`join-by` so that you can have multiple `JOIN`'s in a specific order.
|
* Fix #277 by adding `:join-by`/`join-by` so that you can have multiple `JOIN`'s in a specific order.
|
||||||
|
|
||||||
* 2.0.0-alpha2 (for early testing)
|
* 2.0.0-alpha2 (for early testing)
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,11 @@ SQL entity. This is intended for use in contexts that would
|
||||||
otherwise produce a sequence of SQL keywords, such as when
|
otherwise produce a sequence of SQL keywords, such as when
|
||||||
constructing DDL statements.
|
constructing DDL statements.
|
||||||
|
|
||||||
|
## escape
|
||||||
|
|
||||||
|
Intended to be used with regular expression patterns to
|
||||||
|
specify the escape characters (if any).
|
||||||
|
|
||||||
## inline
|
## inline
|
||||||
|
|
||||||
Accepts a single argument and tries to render it as a
|
Accepts a single argument and tries to render it as a
|
||||||
|
|
|
||||||
|
|
@ -943,6 +943,13 @@
|
||||||
(fn [_ [& args]]
|
(fn [_ [& args]]
|
||||||
(let [[sqls params] (format-expr-list args)]
|
(let [[sqls params] (format-expr-list args)]
|
||||||
(into [(str "(" (str/join ", " sqls) ")")] params)))
|
(into [(str "(" (str/join ", " sqls) ")")] params)))
|
||||||
|
:escape
|
||||||
|
(fn [_ [pattern escape-chars]]
|
||||||
|
(let [[sql-p & params-p] (format-expr pattern)
|
||||||
|
[sql-e & params-e] (format-expr escape-chars)]
|
||||||
|
(-> [(str sql-p " " (sql-kw :escape) " " sql-e)]
|
||||||
|
(into params-p)
|
||||||
|
(into params-e))))
|
||||||
:inline
|
:inline
|
||||||
(fn [_ [x]]
|
(fn [_ [x]]
|
||||||
(if (sequential? x)
|
(if (sequential? x)
|
||||||
|
|
|
||||||
|
|
@ -294,6 +294,12 @@
|
||||||
[[1 2] [3 4] [5 6]])}]]})
|
[[1 2] [3 4] [5 6]])}]]})
|
||||||
["WITH bar (spam, eggs) AS (VALUES (1, 2), (3, 4), (5, 6)) (SELECT foo FROM bar1) UNION (SELECT foo FROM bar2)"]))))
|
["WITH bar (spam, eggs) AS (VALUES (1, 2), (3, 4), (5, 6)) (SELECT foo FROM bar1) UNION (SELECT foo FROM bar2)"]))))
|
||||||
|
|
||||||
|
(deftest similar-regex-tests
|
||||||
|
(testing "basic similar to"
|
||||||
|
(is (= (format {:select :* :from :foo
|
||||||
|
:where [:similar-to :foo [:escape "bar" [:inline "*"]]]})
|
||||||
|
["SELECT * FROM foo WHERE foo SIMILAR TO ? ESCAPE '*'" "bar"]))))
|
||||||
|
|
||||||
(deftest former-parameterizer-tests-where-and
|
(deftest former-parameterizer-tests-where-and
|
||||||
;; I have no plans for positional parameters -- I just don't see the point
|
;; I have no plans for positional parameters -- I just don't see the point
|
||||||
#_(testing "should ignore a nil predicate -- fail: postgresql parameterizer"
|
#_(testing "should ignore a nil predicate -- fail: postgresql parameterizer"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue