Bug description
Backslashes in SQL default values are not escaped properly and consequently return an invalid schema when introspecting.
How to reproduce
- Create table with one or more columns containing backslashes in the default value
CREATE TABLE test (
`model_name_space` VARCHAR(255) NOT NULL DEFAULT 'xyz\\Datasource\\Model'
)
- Introspect the database schema (
prisma2 introspect)
- Generate client (
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.
|
Expected behavior
Backslashes in the default value should be escaped.
model test {
model_name_space String @default("xyz\\Datasource\\Model")
}
Prisma information
Environment & setup
- OS: Mac OS
- Database: MySQL
- Prisma version: [email protected]
- Node.js version: v10.16.3
Bug description
Backslashes in SQL default values are not escaped properly and consequently return an invalid schema when introspecting.
How to reproduce
prisma2 introspect)prisma2 generatefails)The generated schema will look like this:
The following error is thrown when generating the client:
Expected behavior
Backslashes in the default value should be escaped.
Prisma information
Environment & setup