marijnh / Postmodern

A Common Lisp PostgreSQL programming interface
http://marijnhaverbeke.nl/postmodern
Other
400 stars 90 forks source link

Selecting empty PG array produces NIL where it should be empty lisp array instead #311

Closed sirherrbatka closed 2 years ago

sirherrbatka commented 2 years ago

for instance

(postmodern:with-connection pg-connection (postmodern:query "select array[]::integer[]")) will return ((NIL))

Where it should be #()

sabracrolleton commented 2 years ago

We have had a question for a long time whether we should be returning nil or an empty array in this situation and had tentatively decided to return nil. If you change cl-postgres/interpret.lisp line 225 from

nil) 

to

(make-array 0))

and recompile cl-postgres (not just the function read-binary-array-value) does that do what you want?

sirherrbatka commented 2 years ago

Yeah. That would do the trick.

If I could point out why this is an issue for me: I am using cl-postgres to dump content of a database and restore those dumps in others. It was a bit surprising to see that I can't insert what I've just selected from database foo into a database bar with a matching schema.

sabracrolleton commented 2 years ago

Done

sirherrbatka commented 2 years ago

Oh, I managed to convince a developer. That's a new experience for me!

Seriously though, thanks! I really appreciate it.