Skip to content

Commit 4e6531e

Browse files
authored
fix: add missing MSSQL related stdlib declarations and parameters (#748)
1 parent a5d15a3 commit 4e6531e

File tree

3 files changed

+51
-63
lines changed

3 files changed

+51
-63
lines changed

packages/schema/src/res/stdlib.zmodel

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ attribute @id(map: String?, length: Int?, sort: String?, clustered: Boolean?) @@
189189
/**
190190
* Defines a default value for a field.
191191
*/
192-
attribute @default(_ value: ContextType) @@@prisma
192+
attribute @default(_ value: ContextType, map: String?) @@@prisma
193193

194194
/**
195195
* Defines a unique constraint for this field.
@@ -261,13 +261,17 @@ attribute @@fulltext(_ fields: FieldReference[]) @@@prisma
261261

262262
// String type modifiers
263263

264+
enum MSSQLServerTypes {
265+
Max
266+
}
267+
264268
attribute @db.String(_ x: Int?) @@@targetField([StringField]) @@@prisma
265269
attribute @db.Text() @@@targetField([StringField]) @@@prisma
266270
attribute @db.NText() @@@targetField([StringField]) @@@prisma
267271
attribute @db.Char(_ x: Int) @@@targetField([StringField]) @@@prisma
268272
attribute @db.NChar(_ x: Int) @@@targetField([StringField]) @@@prisma
269-
attribute @db.VarChar(_ x: Int) @@@targetField([StringField]) @@@prisma
270-
attribute @db.NVarChar(_ x: Int) @@@targetField([StringField]) @@@prisma
273+
attribute @db.VarChar(_ x: Any) @@@targetField([StringField]) @@@prisma
274+
attribute @db.NVarChar(_ x: Any) @@@targetField([StringField]) @@@prisma
271275
attribute @db.CatalogSingleChar() @@@targetField([StringField]) @@@prisma
272276
attribute @db.TinyText() @@@targetField([StringField]) @@@prisma
273277
attribute @db.MediumText() @@@targetField([StringField]) @@@prisma

pnpm-lock.yaml

Lines changed: 7 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { loadSchema } from '@zenstackhq/testtools';
2+
3+
describe('Regression: issue 724', () => {
4+
it('regression', async () => {
5+
await loadSchema(
6+
`
7+
generator client {
8+
provider = "prisma-client-js"
9+
}
10+
11+
datasource db {
12+
provider = "sqlserver"
13+
url = env("DATABASE_URL")
14+
}
15+
16+
plugin trpc {
17+
provider = '@zenstackhq/trpc'
18+
output = 'src/server/routers/generated'
19+
}
20+
21+
model LastLocation {
22+
LastLocationID String @id(map: "PK_LastLocation") @db.UniqueIdentifier
23+
UserID String @db.UniqueIdentifier
24+
JobID String? @db.UniqueIdentifier
25+
Timestamp DateTime? @db.DateTime
26+
Latitude String? @db.VarChar(Max)
27+
Longitude String? @db.NVarChar(Max)
28+
MostRecentTimestamp DateTime? @db.DateTime
29+
CreatedDate DateTime @default(now(), map: "DF_Address_CreatedDate") @db.DateTime
30+
31+
@@index([UserID], map: "IX_UserID")
32+
}
33+
`,
34+
{ addPrelude: false, pushDb: false }
35+
);
36+
});
37+
});

0 commit comments

Comments
 (0)