Skip to content

Commit

Permalink
fix: add missing MSSQL related stdlib declarations and parameters (#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymc9 authored Oct 11, 2023
1 parent a5d15a3 commit 4e6531e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 63 deletions.
10 changes: 7 additions & 3 deletions packages/schema/src/res/stdlib.zmodel
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ attribute @id(map: String?, length: Int?, sort: String?, clustered: Boolean?) @@
/**
* Defines a default value for a field.
*/
attribute @default(_ value: ContextType) @@@prisma
attribute @default(_ value: ContextType, map: String?) @@@prisma

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

// String type modifiers

enum MSSQLServerTypes {
Max
}

attribute @db.String(_ x: Int?) @@@targetField([StringField]) @@@prisma
attribute @db.Text() @@@targetField([StringField]) @@@prisma
attribute @db.NText() @@@targetField([StringField]) @@@prisma
attribute @db.Char(_ x: Int) @@@targetField([StringField]) @@@prisma
attribute @db.NChar(_ x: Int) @@@targetField([StringField]) @@@prisma
attribute @db.VarChar(_ x: Int) @@@targetField([StringField]) @@@prisma
attribute @db.NVarChar(_ x: Int) @@@targetField([StringField]) @@@prisma
attribute @db.VarChar(_ x: Any) @@@targetField([StringField]) @@@prisma
attribute @db.NVarChar(_ x: Any) @@@targetField([StringField]) @@@prisma
attribute @db.CatalogSingleChar() @@@targetField([StringField]) @@@prisma
attribute @db.TinyText() @@@targetField([StringField]) @@@prisma
attribute @db.MediumText() @@@targetField([StringField]) @@@prisma
Expand Down
67 changes: 7 additions & 60 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions tests/integration/tests/regression/issue-724.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { loadSchema } from '@zenstackhq/testtools';

describe('Regression: issue 724', () => {
it('regression', async () => {
await loadSchema(
`
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlserver"
url = env("DATABASE_URL")
}
plugin trpc {
provider = '@zenstackhq/trpc'
output = 'src/server/routers/generated'
}
model LastLocation {
LastLocationID String @id(map: "PK_LastLocation") @db.UniqueIdentifier
UserID String @db.UniqueIdentifier
JobID String? @db.UniqueIdentifier
Timestamp DateTime? @db.DateTime
Latitude String? @db.VarChar(Max)
Longitude String? @db.NVarChar(Max)
MostRecentTimestamp DateTime? @db.DateTime
CreatedDate DateTime @default(now(), map: "DF_Address_CreatedDate") @db.DateTime
@@index([UserID], map: "IX_UserID")
}
`,
{ addPrelude: false, pushDb: false }
);
});
});

0 comments on commit 4e6531e

Please sign in to comment.