@map not carried over to `makeEnum`
See original GitHub issueGiven the following enum in schema.prisma
enum Role {
ADMIN @map("admin")
@@map("role")
}
The generated JavaScript contains
exports.Role = makeEnum({
ADMIN: 'ADMIN',
});
The value should be the same as inside the map
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
java - Conveniently map between enum and int / String
No, it doesn't use ordinal. It relies on an explicitly defined int value. That int value is used as the map key (returned...
Read more >Handbook - Enums - TypeScript
In this generated code, an enum is compiled into an object that stores both forward ( name -> value ) and reverse (...
Read more >enum — Support for enumerations — Python 3.11.1 ...
An enumeration: is a set of symbolic names (members) bound to unique values. can be iterated over to return its canonical (i.e. non...
Read more >A Guide to EnumMap - Baeldung
EnumMap is a Map implementation that exclusively takes Enum as its keys. In this tutorial, we'll discuss its properties, common use cases ...
Read more >lloydmeta/enumeratum - Gitter
i'm guessing i should just write a matching function and not depend on ... because overriding that requires redefining the whole map (can't...
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
Hey folks,
I think this issue stems from a misunderstanding of how
@map
works.@map
gives metadata to the Query Engine so that it knows the name of the model/enum field name stored in the database.@map
never leaks into the client, it’s the field name that’s used in the client. eg:Given this datamodel 👇,
The client should expose:
It’s only internally that the Query Engine will use these
@map
annotations to do the mappings. These@map
values aren’t expected to be sent over the wire. They’re roughly used, for instance, to:SELECT user_id AS id, user_role AS role FROM ...
SELECT ... FROM ... WHERE user_role = "admin"
👈"admin"
, not"ADMIN"
here.Hope that makes sense, I’m closing now. Feel free to ask further questions/re-open if you still think that’s wrong.
I can reproduce this with
2.16.0-dev.67
. We should definitely export the correct value.It works when you insert data as we use postgres/mysql enums under the hood.