From 0af209c86290345b5feef2f161532c78bd008c18 Mon Sep 17 00:00:00 2001 From: Sean Corfield Date: Wed, 22 Jul 2020 16:27:36 -0700 Subject: [PATCH] Add plan example for SQLite bool/bit transform --- doc/tips-and-tricks.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/tips-and-tricks.md b/doc/tips-and-tricks.md index 9cbd79f..b8fd839 100644 --- a/doc/tips-and-tricks.md +++ b/doc/tips-and-tricks.md @@ -371,4 +371,14 @@ You can work around this using a builder that handles reading the column directl i))))}) ``` +If you are using `plan`, you'll most likely be accessing columns by just the label (as a keyword) and avoiding the result set building machinery completely. In such cases, you'll still get `bool` and `bit` columns back as `0` or `1` and you'll need to explicitly convert them on a per-column basis since you should know which columns need converting: + +```clojure +(reduce (fn [acc row] + (conj acc (-> (select-keys row [:name :is_active]) + (update :is_active pos?)))) + [] + (jdbc/plan ds ["select * from some_table"])) +``` + [<: Friendly SQL Functions](/doc/friendly-sql-functions.md) | [Result Set Builders :>](/doc/result-set-builders.md)