Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't count first when we're doing a real query. #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions src/appengine_magic/services/datastore.clj
Original file line number Diff line number Diff line change
Expand Up @@ -505,23 +505,22 @@
(.prepare (get-datastore-service) query-object))
result-type (if (and (instance? Class kind) (extends? EntityProtocol kind))
kind
entity-record-type)
result-count (.countEntities prepared-query fetch-options-object)]
(cond count-only? result-count
(zero? result-count) (list)
:else (let [results (seq (.asIterable prepared-query fetch-options-object))
model-record (if result-type
;; we know this type; good
(record result-type)
;; unknown type; just use a basic EntityProtocol
(EntityBase.))]
(map #(with-meta
(run-after-load
(merge model-record
(entity->properties (.getProperties %)
(get-clj-properties model-record))))
{:key (.getKey %)})
results)))))
entity-record-type)]
(if count-only?
(.countEntities prepared-query fetch-options-object)
(let [results (seq (.asIterable prepared-query fetch-options-object))
model-record (if result-type
;; we know this type; good
(record result-type)
;; unknown type; just use a basic EntityProtocol
(EntityBase.))]
(map #(with-meta
(run-after-load
(merge model-record
(entity->properties (.getProperties %)
(get-clj-properties model-record))))
{:key (.getKey %)})
results)))))


(defmacro query
Expand Down