Document locking selects
This commit is contained in:
parent
72784452b9
commit
da88383cc0
2 changed files with 16 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
## 0.5.3 In development
|
## 0.5.3 In development
|
||||||
|
|
||||||
|
* Support locking selects (@dball)
|
||||||
* Add sql array type and reader literal (@loganmhb)
|
* Add sql array type and reader literal (@loganmhb)
|
||||||
|
|
||||||
## 0.5.2
|
## 0.5.2
|
||||||
|
|
|
||||||
15
README.md
15
README.md
|
|
@ -215,6 +215,21 @@ To quote identifiers, pass the `:quoting` keyword option to `format`. Valid opti
|
||||||
=> ["SELECT `foo`.`a` FROM `foo` WHERE `foo`.`a` = ?" "baz"]
|
=> ["SELECT `foo`.`a` FROM `foo` WHERE `foo`.`a` = ?" "baz"]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To issue a locking select, add a :lock to the query or use the lock helper. The lock value must be a map with a :mode value. The built-in
|
||||||
|
modes are the standard :update (FOR UPDATE) or the vendor-specific :mysql-share (LOCK IN SHARE MODE) or :postresql-share (FOR SHARE). The
|
||||||
|
lock map may also provide a :wait value, which if false will append the NOWAIT parameter, supported by PostgreSQL.
|
||||||
|
|
||||||
|
```clj
|
||||||
|
(-> (select :foo.a)
|
||||||
|
(from :foo)
|
||||||
|
(where [:= foo.a "baz"])
|
||||||
|
(lock {:mode :update})
|
||||||
|
(sql/format))
|
||||||
|
=> ["SELECT foo.a FROM foo WHERE foo.a = ? FOR UPDATE" "baz"]
|
||||||
|
```
|
||||||
|
|
||||||
|
To support novel lock modes, implement the `format-lock-clause` multimethod.
|
||||||
|
|
||||||
Here's a big, complicated query. Note that Honey SQL makes no attempt to verify that your queries make any sense. It merely renders surface syntax.
|
Here's a big, complicated query. Note that Honey SQL makes no attempt to verify that your queries make any sense. It merely renders surface syntax.
|
||||||
|
|
||||||
```clj
|
```clj
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue