You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With Prisma 4.1, new raw query internals were updated. This is mostly useful for languages like JavaScript, so the client can automatically assign the correct runtime type (for example a Date).
Problem
However, this doesn't work in Go, because the type has to be defined at compile time.
The following raw query which used to work will no longer work:
varposts []struct{
IDstring`json:"id"`Viewsint`json:"views"`
}
err:=client.Prisma.QueryRaw(`SELECT * FROM Post`).Exec(ctx, &posts)
However, from Prisma 4.1, the following is returned internally, which needs to be parsed somehow:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
EDIT: THIS IS OUTDATED AND REVERTED!
New Raw Queries
Description
With Prisma 4.1, new raw query internals were updated. This is mostly useful for languages like JavaScript, so the client can automatically assign the correct runtime type (for example a
Date
).Problem
However, this doesn't work in Go, because the type has to be defined at compile time.
The following raw query which used to work will no longer work:
However, from Prisma 4.1, the following is returned internally, which needs to be parsed somehow:
Solution
I thought I could introduce Prisma types such as prisma.RawString, prisma.RawInt, etc. which can marshal these types into an actual string.
You'd need to define the struct as follows:
Note that
RawString
and so on are just native types with a customer (un)marshaler:Thoughts
Let me know your feedback or if anyone has a better idea!
Beta Was this translation helpful? Give feedback.
All reactions