Backslashes in SQL default values are not escaped properly and consequently return an invalid schema when introspecting.
CREATE TABLE test (
`model_name_space` VARCHAR(255) NOT NULL DEFAULT 'xyz\\Datasource\\Model'
)
prisma2 introspect
)prisma2 generate
fails)The generated schema will look like this:
model test {
model_name_space String @default("xyz\Datasource\Model")
}
The following error is thrown when generating the client:
➜ prisma npx prisma2 generate
Error: Schema parsing
error: Unexpected token. Expected one of: string interpolation start
--> schema.prisma:1552
|
1552 | model_name_space String @default("xyz\Datasource\Model")
| ^ Unexpected token.
|
Backslashes in the default value should be escaped.
model test {
model_name_space String @default("xyz\\Datasource\\Model")
}
We are aware of this and will work on it soon: https://github.com/prisma/prisma-engines/issues/691
I just merged https://github.com/prisma/prisma-engines/pull/738, which should address this issue. The fix should be in alpha 1213 and will for sure be in beta 6. If you have the time, can you confirm that it solves your problem?
Hi @tomhoule, I am still able to reproduce the issue on @prisma/cli 2.0.0-alpha.1213. Backslashes aren't escaped properly. But the error changed and the issue now is harder to identify, as every row of the model containing backslashes in the default value now has an error like this:
Error validating: This line is invalid. It does not start with any known Prisma schema keyword.
Most helpful comment
We are aware of this and will work on it soon: https://github.com/prisma/prisma-engines/issues/691