Fix #213 by add raw/inline explanations to README
This commit is contained in:
parent
83f16780b0
commit
cc9b786602
1 changed files with 10 additions and 8 deletions
10
README.md
10
README.md
|
|
@ -227,23 +227,25 @@ Keywords that begin with `?` are interpreted as bindable parameters:
|
|||
=> ["SELECT id FROM foo WHERE a = ?" "BAZ"]
|
||||
```
|
||||
|
||||
There are helper functions and data literals for SQL function calls, field qualifiers, raw SQL fragments, and named input parameters:
|
||||
There are helper functions and data literals for SQL function calls, field qualifiers, raw SQL fragments, inline values, and named input parameters:
|
||||
|
||||
```clojure
|
||||
(def call-qualify-map
|
||||
(-> (select (sql/call :foo :bar) (sql/qualify :foo :a) (sql/raw "@var := foo.bar"))
|
||||
(from :foo)
|
||||
(where [:= :a (sql/param :baz)])))
|
||||
(where [:= :a (sql/param :baz)] [:= :b (sql/inline 42)])))
|
||||
|
||||
call-qualify-map
|
||||
=> '{:where [:= :a #sql/param :baz]
|
||||
=> '{:where [:and [:= :a #sql/param :baz] [:= :b #sql/inline 42]]
|
||||
:from (:foo)
|
||||
:select (#sql/call [:foo :bar] :foo.a #sql/raw "@var := foo.bar")}
|
||||
|
||||
(sql/format call-qualify-map :params {:baz "BAZ"})
|
||||
=> ["SELECT foo(bar), foo.a, @var := foo.bar FROM foo WHERE a = ?" "BAZ"]
|
||||
=> ["SELECT foo(bar), foo.a, @var := foo.bar FROM foo WHERE (a = ? AND b = 42)" "BAZ"]
|
||||
```
|
||||
|
||||
Raw SQL fragments are treated exactly as-is when rendered into the formatted SQL string (with no parsing or parameterization). Inline values will not be lifted out as parameters, so they end up in the SQL string as-is.
|
||||
|
||||
To quote identifiers, pass the `:quoting` keyword option to `format`. Valid options are `:ansi` (PostgreSQL), `:mysql`, or `:sqlserver`:
|
||||
|
||||
```clojure
|
||||
|
|
|
|||
Loading…
Reference in a new issue