studio icon indicating copy to clipboard operation
studio copied to clipboard

Saving new row in empty table

Open tallowen opened this issue 2 years ago • 0 comments

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

  • Link to Data Browser instance:
  • OS:
  • Browser:
  • Database:

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

tallowen avatar Jan 06 '24 00:01 tallowen