Closed zerg000000 closed 5 years ago
minimum test case
(require '[com.wsscode.pathom.core :as p]) (require '[walkable.sql-query-builder :as sqb]) (def sync-parser (p/parser {::p/plugins [(p/env-plugin {::p/reader ;; walkable's main worker [sqb/pull-entities ;; pathom's entity reader p/map-reader]})]})) (require '[walkable.sql-query-builder.floor-plan :as floor-plan]) (require '[walkable.sql-query-builder.emitter :as emitter]) (def compiled-floor-plan (floor-plan/compile-floor-plan {:idents {:user/by-id :user/id} :columns #{:user/id} :extra-conditions {} :joins {} :cardinality {} :emitter (merge emitter/postgres-emitter {:transform-table-name (fn [table-name] (str "bw_" table-name)) :transform-column-name (fn [column-name] column-name)})})) (require '[clojure.java.jdbc :as jdbc]) (let [my-query [{[:user/by-id 1] [:user/id]}] my-db {:connection-uri "..."} my-run-query (fn [db-spec q] (prn q) (jdbc/query db-spec q))] (sync-parser {::sqb/sql-db my-db ::sqb/run-query my-run-query ::sqb/floor-plan compiled-floor-plan} my-query)) ; ("SELECT \"bw_user\".\"bw_id\" AS \"user/id\" FROM \"bw_user\" WHERE (\"bw_user\".\"bw_id\")=(1)")
minimum test case