Skip to content

Preview feature feedback: nativeTypes #4045

Closed

Description

@nikolasburk

Please share your feedback about the preview feature nativeTypes that was released in v2.11.0 in this issue.

  • If you encounter a bug, please open a bug report in this repo.
  • If the feature is working well for you, please share this in a comment below or leave a 👍 on this issue.

If you have any questions, don't hesitate to ask them in the #prisma2 channel in the Prisma Slack.

Activity

  1. cyrus-za commented on Nov 10, 2020

    @cyrus-za

    Does this mean we finally got postgres interval type supported by annotating the schema with @db.interval?

  2. 2color commented on Nov 19, 2020

    @2color
    Contributor

    @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.

  3. nikolasburk commented on Nov 19, 2020

    @nikolasburk
    ContributorAuthor
  4. naveen-bharathi commented on Nov 21, 2020

    @naveen-bharathi

    @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

  5. pantharshit00 commented on Nov 23, 2020

    @pantharshit00
    Contributor

    @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

  6. albertoperdomo commented on Feb 3, 2021

    @albertoperdomo
    Contributor

    @naveen-bharathi Migrate supports native types since 2.15.0. Have you been able to test it?

  7. albertoperdomo commented on Feb 3, 2021

    @albertoperdomo
    Contributor

    @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.

  8. naveen-bharathi commented on Feb 3, 2021

    @naveen-bharathi

    @naveen-bharathi Migrate supports native types since 2.15.0. Have you been able to test it?

    Works very well. 🙂👌🏻

  9. albertoperdomo commented on Feb 3, 2021

    @albertoperdomo
    Contributor

    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?

  10. livthomas commented on Feb 4, 2021

    @livthomas

    @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.

  11. 4 remaining items

  12. tomhoule commented on Feb 5, 2021

    @tomhoule
    Contributor

    @eddeee888 I opened an issue for the problem you reported: #5493

  13. albertoperdomo commented on Feb 5, 2021

    @albertoperdomo
    Contributor

    @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?

  14. livthomas commented on Feb 6, 2021

    @livthomas
  15. naveen-bharathi commented on Feb 6, 2021

    @naveen-bharathi
  16. livthomas commented on Feb 6, 2021

    @livthomas
  17. pinned this issue on Feb 8, 2021
  18. Dremora commented on Feb 9, 2021

    @Dremora

    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)?

  19. meirianto commented on Feb 11, 2021

    @meirianto

    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.

  20. cyrus-za commented on Feb 11, 2021

    @cyrus-za

    +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 
    const prismaInstance = () => {
      if (instance) return instance
      instance = new PrismaClient()
      return instance
    }
    prismaInstance().$queryRaw(`SET intervalstyle TO iso_8601;`) // Workaround for prisma not supporting PostgreSQL intervals.
    // services/timeEntry.ts
    
    const findAll = async () => {
     const timeEntries = await prisma.timeEntry.findMany({
        orderBy: [{ startedAt: 'asc' }],
      })
    
      const timeEntryIds = timeEntries.map((a) => a.id)
    
      const timeEntryDurations: { id: number; duration: string }[] = await prisma.$queryRaw(oneLine`
          SELECT id, duration::text FROM "timeEntries"
          WHERE id IN (${timeEntryIds});
      `)
    
      const addDuration = (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

    const findAll = async () => {
     const timeEntries = await prisma.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
          }
        }
      })
    }
  21. janpio commented on Feb 12, 2021

    @janpio
    Contributor

    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.

  22. cyrus-za commented on Feb 16, 2021

    @cyrus-za

    Thanks @janpio I created a issue here: #5683

  23. unpinned this issue on Feb 16, 2021
  24. albertoperdomo commented on Feb 18, 2021

    @albertoperdomo
    Contributor

    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).

  25. removed their assignment
    on May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: native database typestopic: previewFeatures

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions