Back
as-unqualified-modified-maps (clj)
(source)function
(as-unqualified-modified-maps rs opts)
Given a `ResultSet` and options, return a `RowBuilder` / `ResultSetBuilder`
that produces bare vectors of hash map rows, with simple, modified keys.
Requires the `:label-fn` option.
Examples
ReilySiegel/EQLizr
(ns eqlizr.impl.ansi
"Contains the implementation for ANSI (PostgreSQL) database functions."
(:require [eqlizr.database :as database]
[next.jdbc :as jdbc]
[next.jdbc.result-set :as result-set]
[clojure.string :as str]
[honeysql.core :as sql]
[eqlizr.resolvers :as resolvers]
[com.wsscode.pathom.core]
[com.wsscode.pathom.connect :as pc]
[eqlizr.impl.keyword :as k]))
(defmethod database/column-map :ansi [{::jdbc/keys [connectable]}]
(into
{}
(comp
;; As columns with no foreign key have a :foreign-key value of "/"
;; because I don't understand SQL, fix that here.
(map (fn [c] (update c :column/foreign-name (fn [s]
(when (not= s "/") s)))))
;; Make the names of columns keywords.
(map (fn [c] (update c :column/foreign-name keyword)))
(map (fn [c] (update c :column/name keyword)))
;; Convert from a vector of columns to a map of names to columns.
(map (juxt :column/name identity)))
(jdbc/execute! connectable
(sql/format information-schema-query
:allow-namespaced-names? true
:quoting :ansi)
{:builder-fn result-set/as-unqualified-modified-maps
:label-fn #(str/replace % #"_" "-")})))