diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b7b37d..71f516a 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 * Fix [#280](https://github.com/seancorfield/next-jdbc/issues/280) by allowing `-` as well as `_` in `nav` foreign key names. + * Address [#279](https://github.com/seancorfield/next-jdbc/issues/279) by adding the missing documentation. * Update dev dependencies, including testing against Clojure 1.12 Alpha 11. * 1.3.925 -- 2024-03-15 diff --git a/doc/datafy-nav-and-schema.md b/doc/datafy-nav-and-schema.md index 6f1bf04..4ce9ca2 100644 --- a/doc/datafy-nav-and-schema.md +++ b/doc/datafy-nav-and-schema.md @@ -36,7 +36,18 @@ For `:fk-suffix`, the `_` is still permitted and optional in the column name, so if you specified `:schema-opts {:fk-suffix "fk"}` then `addressfk` and `address_fk` would both be treated as foreign keys into the `address` table. -The `:pk-fn` can +_Note: as of 1.3.next, `-` is permitted in key names (in addition to `_`) so that kebab result set builders work as expected._ + +The `:pk-fn` can use the table name to determine the primary key column name +for exceptions to the `:pk` value. For example, if you have a table `address` +with a primary key column `address_id` instead of `id`, you could use: + +```clojure + :pk-fn (fn [table pk] + (if (= "address" table) + "address_id" + pk)) +``` The default behavior in the example above is equivalent to this `:schema` value: