r0man / sqlingvo

A Clojure & ClojureScript DSL for SQL
Eclipse Public License 1.0
210 stars 23 forks source link

Better array cast syntax? #69

Closed deepxg closed 6 years ago

deepxg commented 7 years ago

Right now to cast an array to another type (or any type at all in the cast of empty arrays, which was my issue), you need to write: `(cast ~array (keyword "int[]")). This is slightly non-obvious, given all Postgres error messages will point you towards just appending ::integer[] which doesn't seem possible in sqlingvo.

Is there any merit to having an explicit array-cast function that gets around this, and the issue of ugly keywords with invalid characters? This way you could say `(array-cast ~array :int) which seems slightly nicer. Either way, it would be great to have at least a note in the readme or a test to show how it's done.

Apologies if I'm missing an existing way to do this more cleanly!

r0man commented 7 years ago

@deepxg No, there's no other way to do this at the moment. Patch with tests and docs welcome!

r0man commented 6 years ago

This works now since a couple of releases. See: https://github.com/r0man/sqlingvo/blob/master/test/sqlingvo/select_test.cljc#L1018