prisma1 icon indicating copy to clipboard operation
prisma1 copied to clipboard

Multiple pgRelation on connect mutation

Open impowski opened this issue 8 years ago • 8 comments

Describe the bug Cannot run mutation when using multiple connect on relationships pgRelation in one table.

To Reproduce

type User {
  id: Int! @unique
  post: Post @pgRelation(column: "post_id")
  book: Book @pgRelation(column: "book_id")
  stats: Stats @pgRelation(column: "stats_id")
}

Then run this query:

createUser(data: {
  post: { connect: { id: 1 } }
  book: { connect: { id: 1 } }
  stats: { connect: { id: 1 } }
}) {
  id
}

Expected behavior Should return a user and work like it works without existing database.

Logs

Log of Prisma

org.postgresql.util.PSQLException: ERROR: null value in column "user_id" violates not-null constraint
  Detail: Failing row contains (138, null, null, null, 1.0000, 0).
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2433)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2178)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306)
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
        at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:155)
        at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:144)
        at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44)
        at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.execute(HikariProxyPreparedStatement.java)
        at com.prisma.api.connector.jdbc.database.BuilderBase.$anonfun$insertReturningGeneratedKeysToDBIO$1(BuilderBase.scala:59)
        at com.prisma.api.connector.jdbc.database.BuilderBase.$anonfun$jooqToDBIO$1(BuilderBase.scala:82)
        at slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:70)
        at slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:69)
        at slick.basic.BasicBackend$DatabaseDef$$anon$2.liftedTree1$1(BasicBackend.scala:275)
        at slick.basic.BasicBackend$DatabaseDef$$anon$2.run(BasicBackend.scala:275)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

Versions (please complete the following information):

  • OS: Windows 10 Using Docker Container
  • prisma CLI: prisma/1.15.3 (x64) node-v10.9.9
  • Prisma Server: 1.15.3

impowski avatar Sep 08 '18 14:09 impowski

Can you share instructions that create the Postgres database, so I can reproduce this?

marktani avatar Sep 20 '18 14:09 marktani

It's the same thing that happens to me and I reported it here #3319 with an example and everything, I hope you will find a solution soon, thank you.

difagume avatar Oct 19 '18 20:10 difagume

I am also having this issue, along with #3319 .

brunoprela avatar Oct 26 '18 20:10 brunoprela

I have been following this and am experiencing the same issue.

glennrecker01 avatar Oct 26 '18 20:10 glennrecker01

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 10 '18 23:12 stale[bot]

I think this issue should be reopened. I have the same issue still.

mununki avatar Dec 26 '18 10:12 mununki

This is related to this one: https://github.com/prisma/prisma/issues/3319

divyenduz avatar Jan 08 '19 11:01 divyenduz

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Feb 23 '19 06:02 stale[bot]