Default function not working
See original GitHub issueI’ve set the default value for a MySQL column to left(uuid(),8).
After using prisma introspect && prisma generate I get the following schema:
model game {
id String @id @default("left(uuid(),8)")
}
Now, when using game.create prisma writes left(uuid(),8) into the id column.
I’ve tried setting id to null or undefined explicitly, but neither worked.
Is there any workaround for this?
Thanks.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
The default function argument does not work - Stack Overflow
If you pass undefined as an argument, the "default value" (if present) is assigned ... function range(start = undefined, stop = undefined, ...
Read more >Defaults function in Power Apps - Microsoft Learn
When you work with a collection or another data source that doesn't support default values, the Defaults function will return an empty record....
Read more >Default parameters - JavaScript - MDN Web Docs
Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed.
Read more >Field default do not work | Odoo
I've been working on a module for interests. What I have to do is to make possible to create an invoice which has...
Read more >Default arguments in member functions do not work in the C++ ...
I tried and default arguments seem to work for non-member functions though. ... This issue is read only, because it has been in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi @baba43 — the syntax you used is for defining string defaults. If you want an expression as a default, you can use
@default(dbgenerated("left(uuid(),8)"). I’d be curious to know if that works for you!@baba43 If you can also share the SQL of this table, that would help in getting a more accurate reproduction.