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

Array Columns fail under assumption they are relations #500

Open
mbergwall2222 opened this issue May 24, 2023 · 1 comment
Open

Array Columns fail under assumption they are relations #500

mbergwall2222 opened this issue May 24, 2023 · 1 comment

Comments

@mbergwall2222
Copy link

For a model with a column that's an array:

model Example {
  tags String[]
}

This library will assume this is a relation and the requests will fail.

My proposed solution would be to either infer that this is not a relation using the prisma schema, or to access an array of keys in PrismaService that will pass through those keys exactly as given in the PATCH request.

@kepelrs let me know which method you'd prefer and I'll open a PR.

@kepelrs
Copy link
Owner

kepelrs commented May 24, 2023

Yes, that is expected as described in the limitations. I'd hope by now Prisma would have some sort of API that lets us check/traverse a model's relations at run time. But I have yet to find time to look into it.

To answer the question, I'd lean towards the second option. The first approach is cleaner, but it is larger and trickier work.

I believe this work would essentially enable JSON database support, so the new PrismaCrudService property would probably need to be something along the lines of jsonProperties: string[] | 'all', where we'd pass jsonProperties = ['myJsonProp'] when we have a relational database with some json fields, and we'd use jsonProperties = 'all' when our db is something like MongoDB.

Thanks!

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

2 participants