question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

m:m relationships failing in preview 2.0.0-preview019

See original GitHub issue

Thanks for all the great work guys. Really loving Prisma.

Saving multiple User to the Org members field fails with the error below.

Prisma Schema:

/// Any user with credentials
model User {
	id    						String  	@default(cuid()) @id
	email	     				String	 	@unique
	createdAt  				DateTime 	@default(now())
	updatedAt  				DateTime 	@updatedAt
	role       				Role    	@default(USER)
	firstName   			String?
	lastName    			String?
	// ownedOrganization Org? 	@relation(name: "UserOwnsOrganization")
	organizations 		Org[]    	@relation(name: "UserMemberOfOrganization")
	batches			 			Batch[]
	videos						Video[]
}

/// Organzations aka customers
model Org {
	id    						String  		@default(cuid()) @id
	name							String			@unique
	/// the User that is the account owner for the organization
	// owner       			User?				@relation(name: "UserOwnsOrganization")
	/// any members of the organization with "member" level access privelages
	members						User[]			@relation(name: "UserMemberOfOrganization")
	createdAt	  			DateTime 		@default(now())
	updatedAt   			DateTime 		@updatedAt
	addressLine1			String?
	addressLine2			String?
	city							String?
	state							String?
	country						String?
	zip								String?
	/// The uid in the Stripe payment gateway
	stripeId					String?
	/// Any videos attached to this organization - can be queried
	/// and filtered, e.g. (where: {status: 'live'})
	videos						Video[]
	batches						Batch[]
	subscription			Sub?
}
Error in Photon: 
Error: Reason: Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: None, code: SqlState("42601"), message: "syntax error at or near \"ON\"", detail: None, hint: None, position: Some(Original(75)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("scan.l"), line: Some(1053), routine: Some("scanner_yyerror") }) }

stack backtrace:
   0: backtrace::backtrace::trace
   1: backtrace::capture::Backtrace::new_unresolved
   2: failure::backtrace::internal::InternalBacktrace::new
   3: <failure::backtrace::Backtrace as core::default::Default>::default
   4: quaint::connector::postgres::error::<impl core::convert::From<tokio_postgres::error::Error> for quaint::error::Error>::from
   5: <std::future::GenFuture<T> as core::future::future::Future>::poll
   6: <std::future::GenFuture<T> as core::future::future::Future>::poll
   7: std::future::poll_with_tls_context
   8: <std::future::GenFuture<T> as core::future::future::Future>::poll
   9: query_core::interpreter::query_interpreters::write::execute::{{closure}}
  10: <std::future::GenFuture<T> as core::future::future::Future>::poll
  11: <std::future::GenFuture<T> as core::future::future::Future>::poll
  12: <std::future::GenFuture<T> as core::future::future::Future>::poll
  13: <std::future::GenFuture<T> as core::future::future::Future>::poll
  14: <std::future::GenFuture<T> as core::future::future::Future>::poll
  15: <std::future::GenFuture<T> as core::future::future::Future>::poll
  16: <std::future::GenFuture<T> as core::future::future::Future>::poll
  17: <std::future::GenFuture<T> as core::future::future::Future>::poll
  18: std::future::poll_with_tls_context
  19: <std::future::GenFuture<T> as core::future::future::Future>::poll
  20: <std::future::GenFuture<T> as core::future::future::Future>::poll
  21: std::panicking::try::do_call
  22: __rust_maybe_catch_panic
  23: <std::future::GenFuture<T> as core::future::future::Future>::poll
  24: <std::future::GenFuture<T> as core::future::future::Future>::poll
  25: hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_catch
  26: <hyper::server::conn::spawn_all::NewSvcTask<I,N,S,E,W> as core::future::future::Future>::poll
  27: tokio::task::core::Core<T>::poll
  28: std::panicking::try::do_call
  29: __rust_maybe_catch_panic
  30: tokio::task::harness::Harness<T,S>::poll
  31: tokio::runtime::thread_pool::worker::GenerationGuard::run_task
  32: tokio::runtime::thread_pool::worker::GenerationGuard::run
  33: std::thread::local::LocalKey<T>::with
  34: std::thread::local::LocalKey<T>::with
  35: tokio::runtime::thread_pool::worker::Worker::run
  36: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  37: std::panicking::try::do_call
  38: __rust_maybe_catch_panic
  39: tokio::task::harness::Harness<T,S>::poll
  40: tokio::runtime::blocking::pool::Inner::run2
  41: tokio::time::clock::Clock::enter
  42: tokio::runtime::time::variant::with_default
  43: tokio::runtime::blocking::pool::Inner::run
  44: std::sys_common::backtrace::__rust_begin_short_backtrace
  45: __rust_maybe_catch_panic
  46: core::ops::function::FnOnce::call_once{{vtable.shim}}
  47: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once
  48: std::sys::unix::thread::Thread::new::thread_start
  49: _pthread_start
) })

    at NodeEngine.handleErrors (/Users/huston/.cache/prisma/studio/Users-huston-Projects-midas-api/runtime/index.js:3625:19)
    at currentRequestPromise.then (/Users/huston/.cache/prisma/studio/Users-huston-Projects-midas-api/runtime/index.js:3588:29)
    at process._tickCallback (internal/process/next_tick.js:68:7)

package.json

{
  "name": "midas-api",
  "version": "1.0.0",
  "description": "",
  "main": "graphql.js",
  "scripts": {
    "prisma": "prisma2",
    "prisma lift save": "prisma2 lift save",
    "prisma lift up": "prisma2 lift up",
    "generate": "yarn -s generate:prisma && yarn -s generate:nexus",
    "generate:prisma": "prisma2 generate",
    "generate:nexus": "NODE_ENV=development ts-node --transpile-only src/schema",
    "dev": "serverless offline --dontPrintOutput --port 4000 --stage dev",
    "dev:debug": "node --inspect-brk ./node_modules/.bin/serverless offline --port 4000 --stage dev",
    "dev:db": "prisma2 dev",
    "seed": "ts-node ./prisma/seed/index.ts",
    "seed:debug": "node --inspect-brk -r ts-node/register ./prisma/seed/index.ts",
    "test": "echo \"Error: no test specified\" && exit 1",
    "postinstall": "prisma2 generate"
  },
  "husky": {
    "hooks": {
      "pre-commit": "yarn generate"
    }
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@prisma/photon": "2.0.0-preview019",
    "@types/auth0": "^2.20.0",
    "apollo-server-lambda": "^2.9.13",
    "auth0": "^2.20.0",
    "graphql": "^14.5.8",
    "graphql-shield": "^7.0.6",
    "graphql-yoga": "^1.18.3",
    "mongoose": "^5.8.0",
    "nexus": "^0.12.0-rc.5",
    "nexus-prisma": "^0.6.1",
    "permit": "^0.2.4",
    "prisma-client-lib": "^1.34.10",
    "serverless-dotenv-plugin": "^2.1.1"
  },
  "devDependencies": {
    "@types/node": "^12.12.20",
    "@types/node-fetch": "^2.5.4",
    "dotenv": "^8.2.0",
    "graphql-cli": "^3.0.14",
    "husky": "^3.1.0",
    "npm-run-all": "^4.1.5",
    "prisma2": "2.0.0-preview019",
    "serverless": "^1.59.3",
    "serverless-offline": "^5.12.1",
    "serverless-plugin-typescript": "^1.1.9",
    "sls": "^0.1.0",
    "source-map-support": "^0.5.16",
    "ts-node": "^8.5.4",
    "typescript": "^3.7.3"
  },
  "prettier": {
    "singleQuote": true,
    "semi": false,
    "trailingComma": "all"
  }
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
hdngrcommented, Apr 16, 2020

Problem is long gone. Closing.

0reactions
petlackcommented, Apr 16, 2020

@hdngr What version of PostgreSQL are you using? Prisma is using ON CONFLICT clause which had been added in 9.5.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found