Report hasn't been filed before.
What version of drizzle-orm are you using?
1.0.0-beta.20
What version of drizzle-kit are you using?
1.0.0-beta.20
Other packages
No response
Describe the Bug
Description
When defining a filtered unique index with where(isNotNull(...)) for SQL Server, drizzle-kit generates invalid T-SQL.
The generated SQL fully qualifies the column inside the WHERE clause, which SQL Server rejects for a filtered index.
Example schema
export const users = userSchema.table("users", {
id: int().identity().primaryKey(),
employeeId: nvarchar("employee_id", { length: 255 }),
}, (table) => [
uniqueIndex("users_employee_id_idx")
.on(table.employeeId)
.where(isNotNull(table.employeeId)),
]);
Generated Migration
CREATE UNIQUE INDEX [users_employee_id_idx]
ON [user_schema].[users] ([employee_id])
WHERE ([user_schema].[users].[employee_id] is not null);
Expected Migration
CREATE UNIQUE INDEX [users_employee_id_idx]
ON [user_schema].[users] ([employee_id])
WHERE ([employee_id] IS NOT NULL);
This results in the migration failing. When running directly in SSMS the error is:
The multi-part identifier "schemaName.tableName.columnName" could not be bound.
Report hasn't been filed before.
What version of
drizzle-ormare you using?1.0.0-beta.20
What version of
drizzle-kitare you using?1.0.0-beta.20
Other packages
No response
Describe the Bug
Description
When defining a filtered unique index with where(isNotNull(...)) for SQL Server, drizzle-kit generates invalid T-SQL.
The generated SQL fully qualifies the column inside the WHERE clause, which SQL Server rejects for a filtered index.
Example schema
Generated Migration
Expected Migration
This results in the migration failing. When running directly in SSMS the error is:
The multi-part identifier "schemaName.tableName.columnName" could not be bound.