question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Preview feature feedback: `nativeTypes`

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:25 (15 by maintainers)

github_iconTop GitHub Comments

3reactions
albertoperdomocommented, 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).

3reactions
cyrus-zacommented, 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

// 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
      }
    }
  })
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Prisma Client and Prisma schema preview features
When we release a new Prisma Client or Prisma schema feature, it often starts in preview so that you can test it and...
Read more >
Feedback on Preview Features - Microsoft Power BI Community
Solved: Just wondering how to feedback to developers on preview features. I've found a few things over the years that have't quite behaved ......
Read more >
Manage preview features - Azure DevOps Services
Preview features become available first on Azure DevOps Services and then become standard features with an update to Azure DevOps Server. At ...
Read more >
@prisma/client 2.11.0 on Node.js Yarn
Native database types in the Prisma schema (Preview). We are super excited to share that this release brings you one of the most...
Read more >
Workspace security
Search—flexible search features designed to facilitate document review process. Security settings for the Search object apply to saved searches. Editing, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found