fsprojects/Rezoom.SQL

Data type/column type: array

Namek opened this issue · 3 comments

Namek commented

PostgreSQL supports arrays as a datatype:
https://www.postgresql.org/docs/9.1/arrays.html

For instance, a table blogposts could contain a column named tags which would be of type text[].

I want to write a migration where a table is created with such field. I couldn't find anything about arrays in Rezoom, is there something I missed or any workaround for it?

EDIT: OK, I just found https://rspeele.gitbooks.io/rezoom-sql/doc/Language/Functions/PostgresFunctions.html noting that arrays are not supported nor planned. Still, I would be glad to see a workaround (by using Postgre's arrays feature).

I think using such database specific feature is out of scope from Rezoom point of view. So just use raw Postgre SQL or traditional relational DB way: N-M relationship between blog posts and tags.

Namek commented

With vendor statements I could do the imagining altering the table by adding a field and separate tables. But then, I don't see a way to properly query (select) for this field among other fields. There are no per-field vendor statements, are there?

Maybe this specific feature is out of the project's scope but some support for custom field types would be nice.

You might be able to finagle this into working by using dynamic SQL, using the unsafe_inject_raw function any time you select the array-typed column or want to call PostGres array-related functions on it. I haven't tried but I think it might come through as a System.Object which you could then cast to string[] in your F# code. It would be very ugly and type-unsafe though.

If your use case is really something like blog post and tags, seriously consider a good-old many-many relationship with tables BlogPosts, Tags, and BlogPostTagMaps.