Code Monkey home page Code Monkey logo

Comments (5)

TimMensch avatar TimMensch commented on July 19, 2024

Note that a fix for this will also create a proper fix fix for the issue in #24180.

from prisma.

janpio avatar janpio commented on July 19, 2024

If an Unsupported() column is GENERATED ALWAYS (PostgreSQL)

That is generally not the intended use case for Unsupported(), it was originally meant to only contain the name of the unsupported column to be created. That it allows spaces, and hence can be abused to create SQL that is after the column name is an 🥁🥁🥁 unsupported use case.

That being said, that Prisma reacts with removing a DEFAULT on the next migration because there is no @default on the field is weird. Your guess sounds reasonable:

My guess is that the data Prisma is getting from the shadow database indicates that the textSearch column has a default value (it's GENERATED, after all!), which Prisma interprets to mean that it has a DEFAULT clause.

Probably our Introspection does not differentiate for columns that have an explicit DEFAULT which could be dropped, vs. an implicit because of GENERATED ALWAYS AS.

The direct fix for this problem would be to correctly differentiate here and not generate a migration that tries to drop the DEFAULT that does not even exist.

from prisma.

TimMensch avatar TimMensch commented on July 19, 2024

And...it seems that Prisma refuses to add create and createMany to models with Unsupported() columns--at least if the column doesn't have an @default. If we were to add an @default, though, it would be a problem.

So that's another related bug of Unsupported(). No idea why Prisma wouldn't allow that column to be created using a string or a literal of some kind.

from prisma.

janpio avatar janpio commented on July 19, 2024

So that's another related bug of Unsupported(). No idea why Prisma wouldn't allow that column to be created using a string or a literal of some kind.

This is not a bug, this is how Unsupported works. Prisma's Query Engine can not read or write and represent data of some types, so does not allow you to use the types - and Unsupported() at least makes it possible to migrate those columns and use the models for some things.

from prisma.

TimMensch avatar TimMensch commented on July 19, 2024

Well, it kills this as a workaround for me. What I need is a "Custom()" type or similar that acts like I'm using Unsupported() but that allows me to create a column with a custom SQL string, and that just leaves it alone. Trust the developer to know how to use the type, and even to flag to Prisma that the type has an implicit default so that it won't demand that we provide that parameter to .create* calls.

Or alternately, for me, real support for full text search on PostgreSQL. Failing that, I can't use Prisma.

At this point I'm investigating Prisma alternatives. I don't really have a choice.

from prisma.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.