prisma1 icon indicating copy to clipboard operation
prisma1 copied to clipboard

Prisma relations fail to work with postgres 9.4

Open stephenkyle-ARM opened this issue 7 years ago • 1 comments

Describe the bug Having a model with a relation (for example foos: [Foo!]! @relation(name: "FoosRelation")) doesn't allow you to create a node with this relation, specifically when you use postgres 9.4. Using express and prisma-client, I see an error like:

Error: Whoops. Looks like an internal server error. Search your server logs for request ID: local:ck11vlli9002907313wwmq4km
    at BatchedGraphQLClient.<anonymous> (XXX/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:77:35)
    at step (XXX/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:40:23)
    at Object.next (XXX/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:21:53)                                                                                                                            
    at fulfilled (XXX/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:12:58)
    at process._tickCallback (internal/process/next_tick.js:68:7)                    

Which looks like this following stack trace in the Prisma server:

prisma_1    | org.postgresql.util.PSQLException: ERROR: syntax error at or near "on"                                 
prisma_1    |   Position: 85                                                                                                             
prisma_1    |   at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2433)
prisma_1    |   at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2178)                                  
prisma_1    |   at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306)   
prisma_1    |   at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)                                                 
prisma_1    |   at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)                                                         
prisma_1    |   at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:155)                                
prisma_1    |   at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:144)                                         
prisma_1    |   at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44)                                 
prisma_1    |   at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.execute(HikariProxyPreparedStatement.java)                        
prisma_1    |   at com.prisma.connector.shared.jdbc.SharedSlickExtensions.$anonfun$insertToDBIO$1(SharedSlickExtensions.scala:37)        
prisma_1    |   at com.prisma.connector.shared.jdbc.SharedSlickExtensions.$anonfun$insertToDBIO$1$adapted(SharedSlickExtensions.scala:37)
prisma_1    |   at com.prisma.connector.shared.jdbc.SharedSlickExtensions.$anonfun$jooqToDBIO$1(SharedSlickExtensions.scala:56)          
prisma_1    |   at slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:70)                               
prisma_1    |   at slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:69)                                                      
prisma_1    |   at slick.basic.BasicBackend$DatabaseDef$$anon$3.liftedTree1$1(BasicBackend.scala:276)                      
prisma_1    |   at slick.basic.BasicBackend$DatabaseDef$$anon$3.run(BasicBackend.scala:276)                                              
prisma_1    |   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)                          
prisma_1    |   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)                                       
prisma_1    |   at java.lang.Thread.run(Thread.java:748)                                                                         

I see this if I create a postgres 9.4 server with my docker-compose file. The issue goes away however, if I switch to version 9.5.

Can you confirm the minimum version of Postgres that prisma supports?

To Reproduce Steps to reproduce the behavior:

  1. Create a prisma 1.34 and postgres 9.4 docker setup.
  2. Create a type with a relation in your datamodel.prisma file.
  3. Run prisma deploy to create the tables.
  4. Attempt to actually create a node that uses this relation. (I confirmed this doesn't work using the HTTP console of Prisma as well, excluding prisma-client.)

Versions (please complete the following information):

  • Connector: postgres (9.4)
  • Prisma Server: 1.34
  • OS: ubuntu 18.04

Thanks.

stephenkyle-ARM avatar Sep 27 '19 08:09 stephenkyle-ARM

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 Nov 11 '19 09:11 stale[bot]