Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

Commit

Permalink
Add description of insert, remove information about SQL execution sin…
Browse files Browse the repository at this point in the history
…ce that's in java.jdbc, not this DSL.
  • Loading branch information
seancorfield committed Nov 24, 2013
1 parent 0f78ac8 commit 7d9936f
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions README.md
Expand Up @@ -62,7 +62,7 @@ A *where-clause* is a sequence whose first element is a string containing SQL co

**delete** expects a *table-spec* and a *where-clause* (which is not optional). It returns a sequence whose first element is a string containing a SQL DELETE statement and whose remaining elements are the values to be substituted for parameters (**?**) in that string.

**insert** has yet to be designed.
**insert** expects a *table-spec* and either *column-names* followed by *values* or *value-maps* representing rows.

**join** expects a *table-spec* and a *join-map* which is used to generate the ON clause. It returns a string containing a SQL JOIN/ON clause.

Expand All @@ -80,33 +80,6 @@ All functions that generate SQL may have an optional **:entities** keyword argum

The **entities** macro can be used to apply an identifier naming convention to a DSL expression. It expects a function representing the naming convention and a DSL expression. It post-walks the DSL expression and inserts the **:entities** keyword argument and naming convention at the end of each expression.

The remaining parts of the DSL are the high level parts that will execute SQL and process results. Current thinking is along these lines:
```clojure
(query db sql-params :result-set rs-fn :row row-fn)
;;=> runs a SELECT SQL statement
;; applies row-fn to each row returned (default: identity)
;; applies rs-fn to the whole result set (default: doall)
(query db
(select * :user (where {:email "user@domain.com"})))
;;=> returns all user records that match on email

(execute! db sql-params)
;;=> runs a non-SELECT SQL statement and returns the update counts, if appropriate

(insert! db :table value-maps)
;;=> (insert :table value-maps)
;;=> (["INSERT INTO table (..) VALUES (..)" ..] ["INSERT INTO TABLE (..) VALUES (..)" ..] ..)
(insert! db :table col-seq value-seqs)
;;=> (insert :table col-seq value-seqs)
;;=> ["INSERT INTO table (..) VALUES (..), (..)" ..]

(update! db :table update-map where-clause)
;;=> (execute! db (update :table update-map where-clause))

(delete! db :table where-clause)
;;=> (execute! db (delete :table where-clause)
```

## License

Copyright (c) 2012-2013 Sean Corfield
Expand Down

0 comments on commit 7d9936f

Please sign in to comment.