Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/schema/src/res/stdlib.zmodel
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function uuid(version: Int?): String {
/**
* Generates a globally unique identifier based on the CUID spec.
*/
function cuid(): String {
function cuid(version: Int?): String {
} @@@expressionContext([DefaultValue])

/**
Expand All @@ -103,6 +103,12 @@ function cuid(): String {
function nanoid(length: Int?): String {
} @@@expressionContext([DefaultValue])

/**
* Generates an identifier based on the ulid spec.
*/
function ulid(): String {
} @@@expressionContext([DefaultValue])

/**
* Creates a sequence of integers in the underlying database and assign the incremented
* values to the ID values of the created records based on the sequence.
Expand Down
6 changes: 6 additions & 0 deletions packages/schema/tests/generator/prisma-generator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ describe('Prisma generator test', () => {
x String @default(nanoid())
y String @default(dbgenerated("gen_random_uuid()"))
z String @default(auth().id)
cuid String @default(cuid())
cuid2 String @default(cuid(2))
ulid String @default(ulid())
}
`);

Expand All @@ -183,6 +186,9 @@ describe('Prisma generator test', () => {
expect(content).toContain('@default(nanoid())');
expect(content).toContain('@default(dbgenerated("gen_random_uuid()"))');
expect(content).not.toContain('@default(auth().id)');
expect(content).toContain('@default(cuid())');
expect(content).toContain('@default(cuid(2))');
expect(content).toContain('@default(ulid())');
});

it('triple slash comments', async () => {
Expand Down
Loading