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
The interval type is still not supported in Prisma Client. Currently, the native type annotations don’t change the way that Prisma Client works.
For the interval type to be supported, we’d need to add a representation for it in Prisma Client as we recently did with BigInt and Decimal.
It’d be great if you could open an issue for interval support and add some examples of how you’re using it so that we can better understand your use-case and how to best implement it.
@cyrus-za Check out Unsupported, added in 2.16.0. This gives you the option to have interval type columns in the database, although there won't be support for it in the Client.
we are looking to stabilize this feature ASAP and make this available in Prisma for everyone. For this, we are asking for your help!
Can you please share your feedback (positive or negative) and let us know if there are any issues that we should look into before this can be wrapped up?
@albertoperdomo I'm trying to create a new record in an SQLite table where one of the fields is of type Decimal. If I pass a negative value as String to create function, I get the following error from Prisma:
Argument initialBalance: Got invalid value '-65.7' on prisma.createOneCashBox. Provided String, expected Decimal.
It works if I pass it the same value as Number or Decimal. Positive String values also work without any problems.
@livthomas I think you are expected to use the Decimal class, like this: new Prisma.Decimal(-65.7).
Still, the fact that you can pass a String for positive numbers but not negative numbers is still weird though.
Is there any reason BigInt interface is used instead of bigint literal type? Wouldn't it be more preferable to deal with a primitive type, like in case of number and string (as opposed to Number and String)?
There needs to be better support for unsupported types, such as manually being able to cast or transform it onto a custom field in Prisma. It's unacceptable that there is no possible way to work with unsupported columns through Prisma Client CRUD operations. I'm trying to have a column with the point geometric type, and I would love to be able to cast it to two float fields in the Prisma model manually even if point is not supported. Alas, there is no ability to define custom fields into a Prisma model similarly to Nexus-prisma-plugin where one can define still define a custom field on a generated GraphQL object.
+1 @meirianto
Even if we manually need to send a callback function to parse it from what SQL returns, we still need a way.
Right now for our interval type column we do a separate raw query and convert it in sql and then take that value and merge it in with a prisma query that excludes that column. This is annoying, especially when we fetching a list as we need to loop through each item to add it and also need to make sure both queries are sorted.
Right now we do this
// prisma.ts constprismaInstance=()=>{if(instance)returninstanceinstance=newPrismaClient()returninstance}prismaInstance().$queryRaw(`SET intervalstyle TO iso_8601;`)// Workaround for prisma not supporting PostgreSQL intervals.
// services/timeEntry.tsconstfindAll=async()=>{consttimeEntries=awaitprisma.timeEntry.findMany({orderBy: [{startedAt: 'asc'}],})consttimeEntryIds=timeEntries.map((a)=>a.id)consttimeEntryDurations: {id: number;duration: string}[]=awaitprisma.$queryRaw(oneLine` SELECT id, duration::text FROM "timeEntries" WHERE id IN (${timeEntryIds}); `)constaddDuration=(timeEntry: TimeEntry)=>({
...timeEntry,duration: flow(find({id: timeEntry.id}),get('duration'),moment.duration)(timeEntryDurations),})}
What would be nice is if we could do this instead
constfindAll=async()=>{consttimeEntries=awaitprisma.timeEntry.findMany({orderBy: [{startedAt: 'asc'}],customColumn: {duration: {castTo: 'text'// adds duration::text in postgres query,parse: moment.duration// custom function to parse the output from postgres before returning the promise}}})}
Reacted by Rodrigo G. de Oliveira, Alexey Murz Korepov and M.Lesin
Hey @meirianto and @cyrus-za - this is valuable feedback but outside of the scope of the current nativeTypes preview feature. It would be best if you could create a new issue with your use case so we can properly discuss this with you and possibly later prioritize it. Thanks.
Thanks to everyone that provided feedback!
We are still interested in hearing from you how you would improve the native type capabilities in Prisma through the usual channels (GH issue, #product-feedback on Public Slack).
Activity
cyrus-za commentedon Nov 10, 2020
Does this mean we finally got postgres interval type supported by annotating the schema with @db.interval?
2color commentedon Nov 19, 2020
@cyrus-za
The interval type is still not supported in Prisma Client. Currently, the native type annotations don’t change the way that Prisma Client works.
For the interval type to be supported, we’d need to add a representation for it in Prisma Client as we recently did with BigInt and Decimal.
It’d be great if you could open an issue for interval support and add some examples of how you’re using it so that we can better understand your use-case and how to best implement it.nikolasburk commentedon Nov 19, 2020
There already is an open issue to support the
intervaltype here: https://github.com/prisma/prisma-client-js/issues/917naveen-bharathi commentedon Nov 21, 2020
@nikolasburk When I use prisma migrate with v2.11.0, it results in an error
Error: "nativeTypes" preview feature is not supoorted yet. Remove it from your schema to use Prisma Migrate.OS: macOS 11
pantharshit00 commentedon Nov 23, 2020
@naveen-bharathi Migrate doesn't support native types yet. Right now it is meant to be used via introspection.
Read more details here: https://www.prisma.io/docs/concepts/components/preview-features/native-types#limitations
albertoperdomo commentedon Feb 3, 2021
@naveen-bharathi Migrate supports native types since 2.15.0. Have you been able to test it?
albertoperdomo commentedon Feb 3, 2021
@cyrus-za Check out
Unsupported, added in 2.16.0. This gives you the option to have interval type columns in the database, although there won't be support for it in the Client.naveen-bharathi commentedon Feb 3, 2021
Works very well. 🙂👌🏻
albertoperdomo commentedon Feb 3, 2021
Hello everyone,
we are looking to stabilize this feature ASAP and make this available in Prisma for everyone. For this, we are asking for your help!
Can you please share your feedback (positive or negative) and let us know if there are any issues that we should look into before this can be wrapped up?
livthomas commentedon Feb 4, 2021
@albertoperdomo I'm trying to create a new record in an SQLite table where one of the fields is of type
Decimal. If I pass a negative value asStringtocreatefunction, I get the following error from Prisma:It works if I pass it the same value as
NumberorDecimal. PositiveStringvalues also work without any problems.4 remaining items
tomhoule commentedon Feb 5, 2021
@eddeee888 I opened an issue for the problem you reported: #5493
albertoperdomo commentedon Feb 5, 2021
@livthomas I think you are expected to use the Decimal class, like this:
new Prisma.Decimal(-65.7).Still, the fact that you can pass a String for positive numbers but not negative numbers is still weird though.
Can you please open a bug report for this?
livthomas commentedon Feb 6, 2021
@albertoperdomo Here it is: #5508
naveen-bharathi commentedon Feb 6, 2021
livthomas commentedon Feb 6, 2021
Dremora commentedon Feb 9, 2021
Is there any reason
BigIntinterface is used instead ofbigintliteral type? Wouldn't it be more preferable to deal with a primitive type, like in case ofnumberandstring(as opposed toNumberandString)?meirianto commentedon Feb 11, 2021
There needs to be better support for unsupported types, such as manually being able to cast or transform it onto a custom field in Prisma. It's unacceptable that there is no possible way to work with unsupported columns through Prisma Client CRUD operations. I'm trying to have a column with the
pointgeometric type, and I would love to be able to cast it to two float fields in the Prisma model manually even ifpointis not supported. Alas, there is no ability to define custom fields into a Prisma model similarly to Nexus-prisma-plugin where one can define still define a custom field on a generated GraphQL object.cyrus-za commentedon Feb 11, 2021
+1 @meirianto
Even if we manually need to send a callback function to parse it from what SQL returns, we still need a way.
Right now for our interval type column we do a separate raw query and convert it in sql and then take that value and merge it in with a prisma query that excludes that column. This is annoying, especially when we fetching a list as we need to loop through each item to add it and also need to make sure both queries are sorted.
Right now we do this
What would be nice is if we could do this instead
janpio commentedon Feb 12, 2021
Hey @meirianto and @cyrus-za - this is valuable feedback but outside of the scope of the current
nativeTypespreview feature. It would be best if you could create a new issue with your use case so we can properly discuss this with you and possibly later prioritize it. Thanks.cyrus-za commentedon Feb 16, 2021
Thanks @janpio I created a issue here: #5683
albertoperdomo commentedon Feb 18, 2021
Native types was released in General Availability in 2.17.0. Release notes: https://github.com/prisma/prisma/releases/tag/2.17.0
Thanks to everyone that provided feedback!
We are still interested in hearing from you how you would improve the native type capabilities in Prisma through the usual channels (GH issue, #product-feedback on Public Slack).