diff --git a/CHANGELOG.md b/CHANGELOG.md index a7a4e44..2289bdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Only accretive/fixative changes will be made from now on. * 1.3.next in progress * Address [#258](https://github.com/seancorfield/next-jdbc/issues/258) by updating all the library (driver) versions in Getting Started to match the latest versions being tested (from `deps.edn`). + * Expand examples for calling `next.jdbc.sql/find-by-keys` to show `LIKE` and `IN` clauses. * Update `tools.build` to 0.9.6 (and get rid of `template/pom.xml` in favor of new `:pom-data` option to `b/write-pom`). * 1.3.894 -- 2023-09-24 diff --git a/build.clj b/build.clj index 8907e16..4989cf0 100644 --- a/build.clj +++ b/build.clj @@ -45,7 +45,7 @@ [:scm [:url "https://github.com/seancorfield/next-jdbc"] [:connection "scm:git:https://github.com/seancorfield/next-jdbc.git"] - [:developerConnection "scm:git:ssh://git@github.com/seancorfield/next-jdbc.git"] + [:developerConnection "scm:git:ssh:git@github.com:seancorfield/next-jdbc.git"] [:tag (str "v" version)]]]) (defn- jar-opts [opts] diff --git a/doc/friendly-sql-functions.md b/doc/friendly-sql-functions.md index 2d69757..0265045 100644 --- a/doc/friendly-sql-functions.md +++ b/doc/friendly-sql-functions.md @@ -168,6 +168,25 @@ Given a table name (as a keyword) and either a hash map of column names and valu "Stella" "stella@artois.beer"]) ``` +While the hash map approach -- "query by example" -- is great for equality +comparisons, sometimes you need other types of comparisons. For example, you +might want to find all the rows where the email address ends in `.beer`: + +```clojure +(sql/find-by-keys ds :address ["email LIKE ?" "%.beer"]) +;; equivalent to +(jdbc/execute! ds ["SELECT * FROM address WHERE email LIKE ?" "%.beer"]) +``` + +Or you may want to find all the rows where the name is one of a specific +set of values: + +```clojure +(sql/find-by-keys ds :address ["name IN (?,?)" "Stella" "Waldo"]) +;; equivalent to +(jdbc/execute! ds ["SELECT * FROM address WHERE name IN (?,?)" "Stella" "Waldo"]) +``` + The default behavior is to return all the columns in each row. You can specify a subset of columns to return using the `:columns` option. It takes a vector and each element of the vector can be: * a simple keyword representing the column name (`:column-fn` will be applied, if provided),