Wildcard pull requests


#1

This is about datomic cloud.

I’m confused with the fact that pull requests with the wildcard don’t return me a map with keyword keys but instead with keywords wrapped in strings.

With a pull request like this,
(d/pull db ["*"] [:user/uname “myusername”])

I expect
=> {:user/nickname “mynickname”, :user/country :country/US, :user/uname “myusername”}

but instead I get this:
=> {":user/nickname" “mynickname”, “:user/country” :country/US, “:user/uname” “myusername”}

Why?

Without the wildcard, I get a normal map with keywords keys as below.

(d/pull db [:user/nickname :user/country] [:user/uname “myusername”])
=> #:user{:nickname “mynickname”, :country :country/US}


#2

The quotes are coming from your pull specification:

With quotes:

=> (d/pull (d/db conn) '["*"] led-zeppelin)
{":artist/endDay" 25, ":artist/country" {":db/id" 47850746040811801, ":db/ident" :country/GB}, ":artist/type" {":db/id" 70746976177619070, ":db/ident" :artist.type/group}, ":artist/startYear" 1968, ":artist/endYear" 1980, ":artist/endMonth" 9, ":artist/gid" #uuid "678d88b2-87b0-403b-b63d-5da7465aecc3", ":artist/sortName" "Led Zeppelin", ":artist/name" "Led Zeppelin", ":db/id" 2458507999719892}

Without quotes:

=> (d/pull (d/db conn) '[*] led-zeppelin)
{:artist/sortName "Led Zeppelin", :artist/name "Led Zeppelin", :artist/type #:db{:id 70746976177619070, :ident :artist.type/group}, :artist/country #:db{:id 47850746040811801, :ident :country/GB}, :artist/gid #uuid "678d88b2-87b0-403b-b63d-5da7465aecc3", :artist/endDay 25, :artist/startYear 1968, :artist/endMonth 9, :artist/endYear 1980, :db/id 2458507999719892}

#3

I see.

My confusion came from the fact that I’ve had this misunderstanding that we don’t quote selector expressions in pull requests. I’ve been doing

(d/pull (d/db conn) [selector] eid)

instead of

(d/pull (d/db conn) '[selector] eid).

Just as the online documentation does, pull requests work without quoting selectors, except in the wildcard case

(d/pull (d/db conn) [*] eid)

Error!!! Why? I then tried

(d/pull (d/db conn) ["*"] eid)

Success!!! So, I thought I just don’t quote in pull requests.

I’m now reasoning that quoting wasn’t unnecessary in all my pull requests except in the wildcard case because that’s the only case I used a symbol. (By contrast, symbols like e? and ?artist appear in all queries.)

Can you briefly inform me why d/pull and d/db are not written in such a way that quoting is unnecessary? (Technically, it is possible to write macros in such a way, right?)