|
34 | 34 | :let [thunk (i->thunk i)] |
35 | 35 | (not thunk) not-found |
36 | 36 | :else (thunk))] |
37 | | - (log/tracef :results "=> %s" result) |
| 37 | + (log/tracef "=> %s" result) |
38 | 38 | result)) |
39 | 39 |
|
40 | 40 | (def ^:private ^:dynamic *fetch-all-columns* true) |
|
71 | 71 |
|
72 | 72 | clojure.lang.IPersistentMap |
73 | 73 | (assoc [this k v] |
74 | | - (log/tracef :results ".assoc %s %s" k v) |
| 74 | + (log/tracef ".assoc %s %s" k v) |
75 | 75 | (if @already-realized? |
76 | 76 | (assoc @realized-row k v) |
77 | 77 | (let [^clojure.lang.ITransientMap transient-row' (assoc! transient-row k v)] |
|
99 | 99 |
|
100 | 100 | ;; TODO -- can we `assocEx` the transient row? |
101 | 101 | (assocEx [_this k v] |
102 | | - (log/tracef :results ".assocEx %s %s" k v) |
| 102 | + (log/tracef ".assocEx %s %s" k v) |
103 | 103 | (.assocEx ^clojure.lang.IPersistentMap @realized-row k v)) |
104 | 104 |
|
105 | 105 | (without [this k] |
106 | | - (log/tracef :results ".without %s" k) |
| 106 | + (log/tracef ".without %s" k) |
107 | 107 | (if @already-realized? |
108 | 108 | (dissoc @realized-row k) |
109 | 109 | (let [transient-row' (dissoc! transient-row k)] |
|
127 | 127 | ;; TODO -- not sure if we need/want this |
128 | 128 | java.lang.Iterable |
129 | 129 | (iterator [_this] |
130 | | - (log/tracef :results ".iterator") |
| 130 | + (log/tracef ".iterator") |
131 | 131 | (.iterator ^java.lang.Iterable @realized-row)) |
132 | 132 |
|
133 | 133 | clojure.lang.Associative |
134 | 134 | (containsKey [_this k] |
135 | | - (log/tracef :results ".containsKey %s" k) |
| 135 | + (log/tracef ".containsKey %s" k) |
136 | 136 | (boolean (column-name->index k))) |
137 | 137 |
|
138 | 138 | (entryAt [this k] |
139 | | - (log/tracef :results ".entryAt %s" k) |
| 139 | + (log/tracef ".entryAt %s" k) |
140 | 140 | (let [v (.valAt this k ::not-found)] |
141 | 141 | (when-not (= v ::not-found) |
142 | 142 | (clojure.lang.MapEntry. k v)))) |
143 | 143 |
|
144 | 144 | ;;; TODO -- this should probably also include any extra keys added with `assoc` or whatever |
145 | 145 | clojure.lang.Counted |
146 | 146 | (count [_this] |
147 | | - (log/tracef :results ".count") |
| 147 | + (log/tracef ".count") |
148 | 148 | (let [cols (:cols builder)] |
149 | 149 | (assert (seq cols)) |
150 | 150 | (count cols))) |
151 | 151 |
|
152 | 152 | clojure.lang.IPersistentCollection |
153 | 153 | (cons [this o] |
154 | | - (log/tracef :results ".cons %s" o) |
| 154 | + (log/tracef ".cons %s" o) |
155 | 155 | (cond |
156 | 156 | (map? o) |
157 | 157 | (reduce #(apply assoc %1 %2) this o) |
|
165 | 165 | this))) |
166 | 166 |
|
167 | 167 | (empty [_this] |
168 | | - (log/tracef :results ".empty") |
| 168 | + (log/tracef ".empty") |
169 | 169 | (instance/instance model)) |
170 | 170 |
|
171 | 171 | (equiv [_this obj] |
172 | | - (log/tracef :results ".equiv %s" obj) |
| 172 | + (log/tracef ".equiv %s" obj) |
173 | 173 | (.equiv ^clojure.lang.IPersistentCollection @realized-row obj)) |
174 | 174 |
|
175 | 175 | ;; we support get with a numeric key for array-based builders: |
176 | 176 | clojure.lang.ILookup |
177 | 177 | (valAt [this k] |
178 | | - (log/tracef :results ".valAt %s" k) |
| 178 | + (log/tracef ".valAt %s" k) |
179 | 179 | (.valAt this k nil)) |
180 | 180 |
|
181 | 181 | (valAt [this k not-found] |
182 | | - (log/tracef :results ".valAt %s %s" k not-found) |
| 182 | + (log/tracef ".valAt %s %s" k not-found) |
183 | 183 | (cond |
184 | 184 | @already-realized? |
185 | 185 | (get @realized-row k not-found) |
|
205 | 205 | ;; we support nth for array-based builderset (i is primitive int here!): |
206 | 206 | ;; clojure.lang.Indexed |
207 | 207 | ;; (nth [_this i] |
208 | | - ;; (log/tracef :results ".nth %s" i) |
| 208 | + ;; (log/tracef ".nth %s" i) |
209 | 209 | ;; (try |
210 | 210 | ;; (i->thunk (inc i)) |
211 | 211 | ;; (catch java.sql.SQLException _))) |
212 | 212 | ;; (nth [_this i not-found] |
213 | | - ;; (log/tracef :results ".nth %s %s" i not-found) |
| 213 | + ;; (log/tracef ".nth %s %s" i not-found) |
214 | 214 | ;; (try |
215 | 215 | ;; (i->thunk (inc i)) |
216 | 216 | ;; (catch java.sql.SQLException _ |
217 | 217 | ;; not-found))) |
218 | 218 |
|
219 | 219 | clojure.lang.Seqable |
220 | 220 | (seq [_this] |
221 | | - (log/tracef :results ".seq") |
| 221 | + (log/tracef ".seq") |
222 | 222 | (seq @realized-row)) |
223 | 223 |
|
224 | 224 | ;; calling [[persistent!]] on a transient row will convert it to a persistent object WITHOUT realizing all the columns. |
225 | 225 | clojure.lang.ITransientCollection |
226 | 226 | (persistent [_this] |
227 | | - (log/tracef :results ".persistent") |
| 227 | + (log/tracef ".persistent") |
228 | 228 | (binding [*fetch-all-columns* false] |
229 | 229 | @realized-row)) |
230 | 230 |
|
|
254 | 254 |
|
255 | 255 | protocols/IDeferrableUpdate |
256 | 256 | (deferrable-update [this k f] |
257 | | - (log/tracef :results "Doing deferrable update of %s with %s" k f) |
| 257 | + (log/tracef "Doing deferrable update of %s with %s" k f) |
258 | 258 | (b/cond |
259 | 259 | @already-realized? |
260 | 260 | (update @realized-row k f) |
|
339 | 339 | transient-row))) |
340 | 340 |
|
341 | 341 | (defn- fetch-all-columns! [builder i->thunk transient-row] |
342 | | - (log/tracef :results "Fetching all columns") |
| 342 | + (log/tracef "Fetching all columns") |
343 | 343 | (reduce |
344 | 344 | (partial fetch-column! builder i->thunk) |
345 | 345 | transient-row |
346 | 346 | (range 1 (inc (next.jdbc.rs/column-count builder))))) |
347 | 347 |
|
348 | 348 | (defn- make-realized-row-delay [builder i->thunk transient-row] |
349 | 349 | (delay |
350 | | - (log/tracef :results "Fully realizing row. *fetch-all-columns* = %s" *fetch-all-columns*) |
| 350 | + (log/tracef "Fully realizing row. *fetch-all-columns* = %s" *fetch-all-columns*) |
351 | 351 | (let [row (cond->> transient-row |
352 | 352 | *fetch-all-columns* (fetch-all-columns! builder i->thunk))] |
353 | 353 | (next.jdbc.rs/row! builder row)))) |
|
0 commit comments