-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Unable to specify a double quote in a string default value #8902
Comments
Another instance of #4167 |
I wrote a test to try to reproduce this problem in prisma/prisma-engines#2260 — additionally, I checked that we do already have a test for migrate that this works, so I'm a bit at a loss about fixing this. Can you still reproduce the issue with a recent (3+) version of Prisma? |
i see, the solution is to upgrade to 3.x? |
I'm not sure this is the fix, since I haven't tried reproducing the issue on 2.29. I'll spend some time doing that. |
Ok I did try with 2.29.1, and
It passes validation. I also created and applied a (sqlite) migration:
which applies cleanly. I then did the same on postgres:
Which also seems to apply cleanly.
Can you still reproduce the problem on 2.29.1? |
i just checked, and it i'm mystified now as to why it wasn't working in the first place... closest i can figure is maybe it was working the whole time but vscode mistakenly showed it as invalid apologies for the wild goose chase, thanks for your help! |
No problem, glad it's working now :) One possible explanation is that you maybe had an old version of the vscode extension. We definitely had problems with string literal escaping in the Prisma Schema Language in the past because they're ill defined (it's a bit of a pet peeve of mine), so it's likely that it didn't work until a few months ago. |
Bug description
I am unable to specify a
"
character in a string default value in the Prisma schema.How to reproduce
@default('"')
is invalid@default("\"")
is invalid@default("""")
is invalidExpected behavior
There should be a way to specify a double quote in a string default value.
Prisma information
No client queries yet because I am unable to write a valid Prisma schema.
This is actually a simplified reproduction of my use case which is a Postgres Jsonb column:
myColumn Json @default("{'1': {}, '2': {}, '3': {}, '4': {}}")
This is valid Prisma, but will result in invalid JSON. It should be
{"1": {}, "2": {}, "3": {}, "4": {}}
but I am unable to specify this in the schema.My current workaround is letting the migrate fail, then hand-editing migration.sql to have the correct default value.
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: