prisma: Regression: Mapped `enum` throws error (collation `cp1250_czech_cs` or similar)
Bug description
C:\Users\akxe\Documents\Programming\rita\node_modules\@prisma\client\runtime\library.js:124
`)}var So=({clientMethod:e,activeProvider:t,activeProviderFlavour:r})=>n=>{r!==void 0&&(t=r);let i="",o;if(Array.isArray(n)){let[s,...a]=n;i=s,o={values:jr(a||[]),__prismaRawParameters__:!0}}else switch(t){case"sqlite":case"mysql":{i=n.sql,o={values:jr(n.values),__prismaRawParameters__:!0};break}case"cockroachdb":case"postgresql":case"postgres":{i=n.text,o={values:jr(n.values),__prismaRawParameters__:!0};break}case"sqlserver":{i=ql(n),o={values:jr(n.values),__prismaRawParameters__:!0};break}default:throw new Error(`The ${t} provider does not support ${e}`)}return o?.values?Ul(`prisma.${e}(${i}, ${o.values})`):Ul(`prisma.${e}(${i})`),{query:i,parameters:o}},Kl={requestArgsToMiddlewareArgs(e){return[e.strings,...e.values]},middlewareArgsToRequestArgs(e){let[t,...r]=e;return new me(t,r)}},Ql={requestArgsToMiddlewareArgs(e){return[e]},middlewareArgsToRequestArgs(e){return e[0]}};function ko(e){return function(r){let n,i=(o=e)=>{try{return o===void 0||o?.kind==="itx"?n??(n=Gl(r(o))):Gl(r(o))}catch(s){return Promise.reject(s)}};return{then(o,s){return i().then(o,s)},catch(o){return i().catch(o)},finally(o){return i().finally(o)},requestTransaction(o){let s=i(o);return s.requestTransaction?s.requestTransaction(o):s},[Symbol.toStringTag]:"PrismaPromise"}}}function Gl(e){return typeof e.then=="function"?e:Promise.resolve(e)}var Jl={isEnabled(){return!1},getTraceParent(){return"00-10-10-00"},async createEngineSpan(){},getActiveContext(){},runInChildSpan(e,t){return t()}},Io=class{isEnabled(){return this.getGlobalTracingHelper().isEnabled()}getTraceParent(t){return this.getGlobalTracingHelper().getTraceParent(t)}createEngineSpan(t){return this.getGlobalTracingHelper().createEngineSpan(t)}getActiveContext(){return this.getGlobalTracingHelper().getActiveContext()}runInChildSpan(t,r){return this.getGlobalTracingHelper().runInChildSpan(t,r)}getGlobalTracingHelper(){return globalThis.PRISMA_INSTRUMENTATION?.helper??Jl}};function Hl(e){return e.includes("tracing")?new Io:Jl}function Wl(e,t=()=>{}){let r,n=new Promise(i=>r=i);return{then(i){return--e===0&&r(t()),i?.(n)}}}var uf=["$connect","$disconnect","$on","$transaction","$use","$extends"],Fo=uf;function zl(e){return typeof e=="string"?e:e.reduce((t,r)=>{let n=typeof r=="string"?r:r.level;return n==="query"?t:t&&(r==="info"||t==="info")?"info":n},void 0)}var Xn=class{constructor(){this._middlewares=[]}use(t){this._middlewares.push(t)}get(t){return this._middlewares[t]}has(t){return!!this._middlewares[t]}length(){return this._middlewares.length}};var Zl=I(ji());function ei(e){return typeof e.batchRequestIdx=="number"}function ti(e){return e===null?e:Array.isArray(e)?e.map(ti):typeof e=="object"?cf(e)?pf(e):It(e,ti):e}function cf(e){return e!==null&&typeof e=="object"&&typeof e.$type=="string"}function pf({$type:e,value:t}){switch(e){case"BigInt":return BigInt(t);case"Bytes":return Buffer.from(t,"base64");case"DateTime":return new Date(t);case"Decimal":return new Oe(t);case"Json":return JSON.parse(t);default:ft(t,"Unknown tagged value")}}function Yl(e){if(e.action!=="findUnique"&&e.action!=="findUniqueOrThrow")return;let t=[];return e.modelName&&t.push(e.modelName),e.query.arguments&&t.push(Do(e.query.arguments)),t.push(Do(e.query.selection)),t.join("")}function Do(e){return`(${Object.keys(e).sort().map(r=>{let n=e[r];return typeof n=="object"&&n!==null?`(${r} ${Do(n)})`:r}).join(" ")})`}var df={aggregate:!1,aggregateRaw:!1,createMany:!0,createOne:!0,deleteMany:!0,deleteOne:!0,executeRaw:!0,findFirst:!1,findFirstOrThrow:!1,findMany:!1,findRaw:!1,findUnique:!1,findUniqueOrThrow:!1,groupBy:!1,queryRaw:!1,runCommandRaw:!0,updateMany:!0,updateOne:!0,upsertOne:!0};function Oo(e){return df[e]}var ri=class{constructor(t){this.options=t;this.tickActive=!1;this.batches={}}request(t){let r=this.options.batchBy(t);return r?(this.batches[r]||(this.batches[r]=[],this.tickActive||(this.tickActive=!0,process.nextTick(()=>{this.dispatchBatches(),this.tickActive=!1}))),new Promise((n,i)=>{this.batches[r].push({request:t,resolve:n,reject:i})})):this.options.singleLoader(t)}dispatchBatches(){for(let t in this.batches){let r=this.batches[t];delete this.batches[t],r.length===1?this.options.singleLoader(r[0].request).then(n=>{n instanceof Error?r[0].reject(n):r[0].resolve(n)}).catch(n=>{r[0].reject(n)}):(r.sort((n,i)=>this.options.batchOrder(n.request,i.request)),this.options.batchLoader(r.map(n=>n.request)).then(n=>{if(n instanceof Error)for(let i=0;i<r.length;i++)r[i].reject(n);else for(let i=0;i<r.length;i++){let o=n[i];o instanceof Error?r[i].reject(o):r[i].resolve(o)}}).catch(n=>{for(let i=0;i<r.length;i++)r[i].reject(n)}))}}get[Symbol.toStringTag](){return"DataLoader"}};var mf=L("prisma:client:request_handler"),ni=class{constructor(t,r){this.logEmitter=r,this.client=t,this.dataloader=new ri({batchLoader:Ua(async({requests:n,customDataProxyFetch:i})=>{let{transaction:o,otelParentCtx:s}=n[0],a=n.map(p=>p.protocolQuery),l=this.client._tracingHelper.getTraceParent(s),u=n.some(p=>Oo(p.protocolQuery.action));return(await this.client._engine.requestBatch(a,{traceparent:l,transaction:ff(o),containsWrite:u,customDataProxyFetch:i})).map((p,d)=>{if(p instanceof Error)return p;try{return this.mapQueryEngineResult(n[d],p)}catch(f){return f}})}),singleLoader:async n=>{let i=n.transaction?.kind==="itx"?Xl(n.transaction):void 0,o=await this.client._engine.request(n.protocolQuery,{traceparent:this.client._tracingHelper.getTraceParent(),interactiveTransaction:i,isWrite:Oo(n.protocolQuery.action),customDataProxyFetch:n.customDataProxyFetch});return this.mapQueryEngineResult(n,o)},batchBy:n=>n.transaction?.id?`transaction-${n.transaction.id}`:Yl(n.protocolQuery),batchOrder(n,i){return n.transaction?.kind==="batch"&&i.transaction?.kind==="batch"?n.transaction.index-i.transaction.index:0}})}async request(t){try{return await this.dataloader.request(t)}catch(r){let{clientMethod:n,callsite:i,transaction:o,args:s}=t;this.handleAndLogRequestError({error:r,clientMethod:n,callsite:i,transaction:o,args:s})}}mapQueryEngineResult({dataPath:t,unpacker:r},n){let i=n?.data,o=n?.elapsed,s=this.unpack(i,t,r);return process.env.PRISMA_CLIENT_GET_TIME?{data:s,elapsed:o}:s}handleAndLogRequestError(t){try{this.handleRequestError(t)}catch(r){throw this.logEmitter&&this.logEmitter.emit("error",{message:r.message,target:t.clientMethod,timestamp:new Date}),r}}handleRequestError({error:t,clientMethod:r,callsite:n,transaction:i,args:o}){if(mf(t),gf(t,i)||t instanceof Ve)throw t;if(t instanceof W&&yf(t)){let a=eu(t.meta);Zn({args:o,errors:[a],callsite:n,errorFormat:this.client._errorFormat,originalMethod:r,clientVersion:this.client._clientVersion})}let s=t.message;throw n&&(s=Ut({callsite:n,originalMethod:r,isPanic:t.isPanic,showColors:this.client._errorFormat==="pretty",message:s})),s=this.sanitizeMessage(s),t.code?new W(s,{code:t.code,clientVersion:this.client._clientVersion,meta:t.meta,batchRequestIdx:t.batchRequestIdx}):t.isPanic?new he(s,this.client._clientVersion):t instanceof z?new z(s,{clientVersion:this.client._clientVersion,batchRequestIdx:t.batchRequestIdx}):t instanceof k?new k(s,this.client._clientVersion):t instanceof he?new he(s,this.client._clientVersion):(t.clientVersion=this.client._clientVersion,t)}sanitizeMessage(t){return this.client._errorFormat&&this.client._errorFormat!=="pretty"?(0,Zl.default)(t):t}unpack(t,r,n){if(!t||(t.data&&(t=t.data),!t))return t;let i=Object.values(t)[0],o=r.filter(a=>a!=="select"&&a!=="include"),s=ti(so(i,o));return n?n(s):s}get[Symbol.toStringTag](){return"RequestHandler"}};function ff(e){if(e){if(e.kind==="batch")return{kind:"batch",options:{isolationLevel:e.isolationLevel}};if(e.kind==="itx")return{kind:"itx",options:Xl(e)};ft(e,"Unknown transaction kind")}}function Xl(e){return{id:e.id,payload:e.payload}}function gf(e,t){return ei(e)&&t?.kind==="batch"&&e.batchRequestIdx!==t.index}function yf(e){return e.code==="P2009"||e.code==="P2012"}function eu(e){if(e.kind==="Union")return{kind:"Union",errors:e.errors.map(eu)};if(Array.isArray(e.selectionPath)){let[,...t]=e.selectionPath;return{...e,selectionPath:t}}return e}var tu="5.6.0";var ru=tu;function nu(e){return e.map(t=>{let r={};for(let n of Object.keys(t))r[n]=iu(t[n]);return r})}function iu({prisma__type:e,prisma__value:t}){switch(e){case"bigint":return BigInt(t);case"bytes":return Buffer.from(t,"base64");case"decimal":return new Oe(t);case"datetime":case"date":return new Date(t);case"time":return new Date(`1970-01-01T${t}Z`);case"array":return t.map(iu);default:return t}}var lu=I(_o());var B=class extends Error{constructor(t){super(t+`
PrismaClientUnknownRequestError:
Invalid `prisma.company.findMany()` invocation in
C:\Users\akxe\Documents\Programming\rita\apps\server\src\api\rita-int\companies\get-all.ts:12:42
9 getCompaniesEndpoint,
10 [new RitaStrategy(getCompaniesEndpoint)],
11 async (_, res) => {
→ 12 const companies = await prisma.company.findMany(
Value 'plátce' not found in enum 'VATType'
at ni.handleRequestError (C:\Users\akxe\Documents\Programming\rita\node_modules\@prisma\client\runtime\library.js:124:6989)
at ni.handleAndLogRequestError (C:\Users\akxe\Documents\Programming\rita\node_modules\@prisma\client\runtime\library.js:124:6206)
at ni.request (C:\Users\akxe\Documents\Programming\rita\node_modules\@prisma\client\runtime\library.js:124:5926)
at l (C:\Users\akxe\Documents\Programming\rita\node_modules\@prisma\client\runtime\library.js:129:10023)
at C:\Users\akxe\Documents\Programming\rita\apps\server\src\api\rita-int\companies\get-all.ts:12:21
How to reproduce
- Create a table with an enum
- Rename enum columns in
schema.prisma npm run prisma generate- Query given table
Expected behavior
Expected to work
Prisma information
model Company {
companyID Int @id @default(autoincrement()) @map("idFirmy") @db.UnsignedSmallInt
VATType VATType? @map("typDPH")
}
enum VATType {
nonPayer @map("neplátce")
payer @map("plátce")
passthrough @map("přenesená daňová povinnost")
@@map("firmy_typDPH")
}
prisma.company.findMany({})
Environment & setup
- OS: Windows
- Database: MySQL
- Node.js version: v18.16.0, v20.x.x
Prisma Version
All versions above 5.6.x (including 5.7.x and 5.8.x)
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 17 (15 by maintainers)
Commits related to this issue
- test(client): Add test for mapped enum with non-ascii characters Issue itself was fixed in 5.10.0. Close #21967 — committed to prisma/prisma by SevInf 4 months ago
- test(client): Add test for mapped enum with non-ascii characters Issue itself was fixed in 5.10.0. Close #21967 — committed to prisma/prisma by SevInf 4 months ago
- test(client): Add test for mapped enum with non-ascii characters (#23241) Issue itself was fixed in 5.10.0. Close #21967 — committed to prisma/prisma by SevInf 4 months ago
There it is 😃 repo steps in readme
https://github.com/Akxe/prisma-debug/tree/main
@millsp
@janpio did sign the NDA before, I have restored his access to the project.
I have tested with Prisma@5.7.0 and the error is still there. It might be, that the problem is when the mapped enum value originally contains Czech characters
ěščřžýáíé(and a few more). I will try to make a repo just for you.