prisma / studio

🎙️ The easiest way to explore and manipulate your data in all of your Prisma projects.
https://www.prisma.io/studio
1.85k stars 47 forks source link

Saving new row in empty table #1197

Open tallowen opened 7 months ago

tallowen commented 7 months ago

Bug description

It looks like I can't use prisma studio to create the first row in a database since it's trying to query for existing rows but doesn't find any.

  1. Roughly follow https://www.prisma.io/docs/orm/prisma-client/queries/raw-database-access/custom-and-type-safe-queries
  2. Create a new row in the table using the stuido UI

How to reproduce

Start Database: Create a new database: docker run -d --name my_postgis_container -e POSTGRES_USER=$DBUSER -e POSTGRES_PASSWORD=$DBPASSWORD -p 5432:5432 postgis/postgis:15-3.4

Use this schema:

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["postgresqlExtensions"]
}

datasource db {
  provider   = "postgresql"
  url        = env("DATABASE_URL")
  extensions = [postgis]
}

model Gauge {
  name            String
  gaugeProvider   GaugeProvider
  gaugeIdentifier String
  location Unsupported("geography(Point, 4326)")

  @@unique([gaugeProvider, gaugeIdentifier])
}

/// This table contains check constraints and requires additional setup for migrations. Visit https://pris.ly/d/check-constraints for more info.
model spatial_ref_sys {
  srid      Int     @id
  auth_name String? @db.VarChar(256)
  auth_srid Int?
  srtext    String? @db.VarChar(2048)
  proj4text String? @db.VarChar(2048)
}

enum GaugeProvider {
  USGS
  CDEC
}

Expected behavior

When I open prisma studio and add the first row, that data saves. Instead I get an error.

Prisma information

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["postgresqlExtensions"]
}

datasource db {
  provider   = "postgresql"
  url        = env("DATABASE_URL")
  extensions = [postgis]
}

model Gauge {
  name            String
  gaugeProvider   GaugeProvider
  gaugeIdentifier String
  location Unsupported("geography(Point, 4326)")

  @@unique([gaugeProvider, gaugeIdentifier])
}

/// This table contains check constraints and requires additional setup for migrations. Visit https://pris.ly/d/check-constraints for more info.
model spatial_ref_sys {
  srid      Int     @id
  auth_name String? @db.VarChar(256)
  auth_srid Int?
  srtext    String? @db.VarChar(2048)
  proj4text String? @db.VarChar(2048)
}

enum GaugeProvider {
  USGS
  CDEC
}

Environment & setup

Screenshot of page where the problem happened (if applicable)

Screenshot 2024-01-05 at 5 29 06 PM

Prisma logs

None in console where I ran npx prisma studio

janpio commented 2 months ago

I use Prisma Studio for that use case, to create initial data, all the time. Are you sure this was the reason for this error? Can you scroll further down in the "Show Detail" view so we can see the actual error?