File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3838; ; single-element list with `first`.
3939(tc-ignore
4040 (defn execute-handler
41- [db sql-and-params]
41+ [db sql-and-params call-options ]
4242 (first (jdbc/execute! db sql-and-params))))
4343
4444(tc-ignore
4545 (defn insert-handler
46- [db [statement & params]]
46+ [db [statement & params] call-options ]
4747 (jdbc/db-do-prepared-return-keys db statement params)))
4848
49+ (tc-ignore
50+ (defn query-handler
51+ [db sql-and-params
52+ {:keys [row-fn result-set-fn]
53+ :or {row-fn identity
54+ result-set-fn doall}
55+ :as call-options}]
56+ (jdbc/query db sql-and-params
57+ :row-fn row-fn
58+ :result-set-fn result-set-fn)))
59+
4960; ; (ann ^:no-check generate-query-fn
5061; ; [yesql.types.Query -> (IFn [Any * -> Any])])
5162
6374 (let [jdbc-fn (cond
6475 (= (take-last 2 name) [\< \!]) insert-handler
6576 (= (last name) \!) execute-handler
66- :else jdbc/ query)
77+ :else query-handler )
6778 required-args (expected-parameter-list statement)
6879 global-connection (:connection query-options)
6980 real-fn (fn [args call-options]
7586 " Check the docs, and supply {:connection ...} as an option to the function call, or globally to the defquery declaration." ])
7687 name))
7788 (jdbc-fn connection
78- (rewrite-query-for-jdbc statement args))))
89+ (rewrite-query-for-jdbc statement args)
90+ call-options)))
7991 [display-args generated-function] (let [named-args (if-let [as-vec (seq (mapv (comp symbol clojure.core/name)
8092 required-args))]
8193 {:keys as-vec}
Original file line number Diff line number Diff line change 3636 :value2 2
3737 :? [0 0 ]}))
3838
39+ ; ;; Processor functions
40+ (expect java.util.Date
41+ (current-time-query {} {:result-set-fn first
42+ :row-fn :time }))
43+
3944; ;; Test Metadata.
4045(expect (more-> " Just selects the current time.\n Nothing fancy." :doc
4146 'current-time-query :name
You can’t perform that action at this time.
0 commit comments