Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@default(@dbgenerated(...)) generates [object Object]; fails #19

Open
cnjmike opened this issue Dec 7, 2023 · 1 comment
Open

@default(@dbgenerated(...)) generates [object Object]; fails #19

cnjmike opened this issue Dec 7, 2023 · 1 comment

Comments

@cnjmike
Copy link

cnjmike commented Dec 7, 2023

model Example { 
someId Int @default(dbgenerated("(current_setting('app.clinic_id'::text)::integer)"))

generates into fake-data.ts:

someId: [object Object]

which errors out:

 fake-data.ts:210:16 - error TS2552: Cannot find name 'object'. Did you mean 'Object'?

    210     someId: [object Object],
                       ~~~~~~

      node_modules/typescript/lib/lib.es5.d.ts:270:13
        270 declare var Object: ObjectConstructor;
                        ~~~~~~
        'Object' is declared here.

Adding @db.Integer to the prisma schema line has no effect.

I also see an example of a String attribute with @dbgenerated that generates:

someId: '[object Object']

which does not error but is not helpful.

I think the issue is in createMethod.js:37 and :40, where $field.default is returning [object Object]. No handling for dbgenerated inside default?

Thanks

@luisrudge
Copy link
Owner

yeah, it doesn't support dbgenerated as a default value at the moment. In your specific case, the issue is here: https://github.com/luisrudge/prisma-generator-fake-data/blob/main/src/helpers/createMethods.ts#L45-L47

I guess it's closely related to #17 and #12. For unsupported types or values, it'd be great to allow the developer to override the default behaviour and just add FAKE: whatever_you_want_here()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants