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

Data type/column type: array #48

Open
Namek opened this issue Jul 3, 2019 · 3 comments
Open

Data type/column type: array #48

Namek opened this issue Jul 3, 2019 · 3 comments

Comments

@Namek
Copy link

Namek commented Jul 3, 2019

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).

@Risord
Copy link

Risord commented Jul 3, 2019

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
Copy link
Author

Namek commented Jul 6, 2019

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.

@rspeele
Copy link
Collaborator

rspeele commented Jul 7, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants