Skip to content

[Prisma 2] Upserting User in PostgreSQL causes panick and ConnectorError #3

Closed

Description

@ChristianJacobsen

Describe the bug
Error dump:

Error: Error in Photon: 
[
  {
    "error": "ConnectorError(QueryError(Error { kind: ToSql, cause: Some(WrongType(Type(Text))) }\n\nstack backtrace:\n   0: failure::backtrace::internal::InternalBacktrace::new::h84e0252f893b7b0e (0x560f176c75f0)\n   1: <failure::backtrace::Backtrace as core::default::Default>::default::hd8f6c25d93ae9c26 (0x560f176c77a0)\n   2: <sql_connector::error::SqlError as core::convert::From<tokio_postgres::error::Error>>::from::h01dd77df417c902b (0x560f170fa307)\n   3: sql_connector::database::postgresql::<impl sql_connector::transactional::Transaction for postgres::transaction::Transaction>::write::h85ba92f2a437f0c3 (0x560f170cee33)\n   4: sql_connector::transactional::Transaction::insert::hd87cbd91efa25ae3 (0x560f16dbb674)\n   5: sql_connector::transactional::mutaction_executor::create::execute::h75940cff21c312d7 (0x560f1710e305)\n   6: sql_connector::transactional::mutaction_executor::<impl connector::database_mutaction_executor::DatabaseMutactionExecutor for sql_connector::database::SqlDatabase<T>>::execute::{{closure}}::create::hba6453f84f903c89 (0x560f17144268)\n   7: <sql_connector::database::postgresql::PostgreSql as sql_connector::transactional::Transactional>::with_transaction::ha343e63fe0096da4 (0x560f16e2500e)\n   8: sql_connector::transactional::mutaction_executor::<impl connector::database_mutaction_executor::DatabaseMutactionExecutor for sql_connector::database::SqlDatabase<T>>::execute::h76670b1c1482e4fd (0x560f16d83343)\n   9: core::executor::write::WriteQueryExecutor::exec_one::h81acc6e0a7d1cf87 (0x560f171e2382)\n  10: core::executor::write::WriteQueryExecutor::execute::h4de4034d22720586 (0x560f171e1c5e)\n  11: core::executor::Executor::exec_all::h019661aa466552b2 (0x560f171e2e45)\n  12: <prisma::req_handlers::graphql::GraphQlRequestHandler as prisma::req_handlers::RequestHandler>::handle::hd901880e604ba7f3 (0x560f16dff33f)\n  13: prisma::http_handler::h574a96a3df5ad7b2 (0x560f16e46da9)\n  14: <F as actix_web::with::FnWith<T,R>>::call_with::h8921e8f777cf5423 (0x560f16e521be)\n  15: <actix_web::with::WithHandlerFut<T,S,R> as futures::future::Future>::poll::hd0405f55c326258c (0x560f16e5702e)\n  16: actix_web::pipeline::PipelineState<S,H>::poll::h05fe08bd6589e38c (0x560f16d5afe3)\n  17: <actix_web::pipeline::Pipeline<S,H> as actix_web::server::handler::HttpHandlerTask>::poll_io::hf988cbba155aa2c2 (0x560f16d49770)\n  18: actix_web::server::h1::Http1Dispatcher<T,H>::poll_handler::h0e2de2e2f0e85c3b (0x560f16dd599c)\n  19: actix_web::server::h1::Http1Dispatcher<T,H>::poll::h7c512f9208c70f65 (0x560f16e15361)\n  20: <actix_web::server::channel::HttpChannel<T,H> as futures::future::Future>::poll::h3fda956b624b7067 (0x560f16e14079)\n  21: <actix_web::server::channel::HttpChannel<T,H> as futures::future::Future>::poll::h3fda956b624b7067 (0x560f16e15011)\n  22: <actix_net::service::and_then::AndThenFuture<A,B> as futures::future::Future>::poll::hb1978ee7b706a005 (0x560f16ea638d)\n  23: futures::future::chain::Chain<A,B,C>::poll::h4dcce436324a17dd (0x560f16ea07a9)\n  24: futures::task_impl::std::set::hb6a916396ab13c6e (0x560f16f8d892)\n  25: futures::task_impl::Spawn<T>::poll_future_notify::ha13909c8cd98d4fe (0x560f16fa8296)\n  26: tokio_current_thread::CurrentRunner::set_spawn::hcab1a55dd9f5caaf (0x560f16f885a4)\n  27: tokio_current_thread::scheduler::Scheduler<U>::tick::h1f8b6bf060538e24 (0x560f16f94cfa)\n  28: tokio_current_thread::Entered<P>::block_on::hd80cde5490457c04 (0x560f16f88f5a)\n  29: std::thread::local::LocalKey<T>::with::h66e6fccf026a2b83 (0x560f16f9f768)\n  30: std::thread::local::LocalKey<T>::with::h7b6b9e8e24d2b1ae (0x560f16fa0598)\n  31: std::thread::local::LocalKey<T>::with::h4efe62e0c4ca0fb4 (0x560f16f9ea5f)\n  32: std::thread::local::LocalKey<T>::with::h1aefc504c0a5187d (0x560f16f9de55)\n  33: tokio::runtime::current_thread::runtime::Runtime::block_on::h573894b7abc600ef (0x560f16f8c7b0)\n  34: std::sys_common::backtrace::__rust_begin_short_backtrace::h027e6ea9ab4c2090 (0x560f16fa5cb7)\n  35: std::panicking::try::do_call::hbc22e41bfc445835 (0x560f16f8ad66)\n  36: __rust_maybe_catch_panic (0x560f176fb18a)\n             at src/libpanic_unwind/lib.rs:87\n  37: core::ops::function::FnOnce::call_once{{vtable.shim}}::hf39704692fc5ef53 (0x560f16fa6556)\n  38: call_once<(),FnBox<()>> (0x560f176e15bf)\n             at /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/liballoc/boxed.rs:702\n  39: call_once<(),alloc::boxed::Box<FnBox<()>>> (0x560f176fa5a0)\n             at /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/liballoc/boxed.rs:702\n      start_thread\n             at src/libstd/sys_common/thread.rs:14\n      thread_start\n             at src/libstd/sys/unix/thread.rs:80\n  40: start_thread (0x7fdd3101f57f)\n  41: __clone (0x7fdd30f32f13)\n  42: <unknown> (0x0)))"
  }
]
    at PhotonFetcher._callee$ (/home/jenkins/code/misc/prisma2_test/generated/photon/index.js:35:23)
    at tryCatch (/home/jenkins/code/misc/prisma2_test/node_modules/regenerator-runtime/runtime.js:45:40)
    at Generator.invoke [as _invoke] (/home/jenkins/code/misc/prisma2_test/node_modules/regenerator-runtime/runtime.js:271:22)
    at Generator.prototype.(anonymous function) [as throw] (/home/jenkins/code/misc/prisma2_test/node_modules/regenerator-runtime/runtime.js:97:21)
    at rejected (/home/jenkins/code/misc/prisma2_test/generated/photon/index.js:5:47)
    at processTicksAndRejections (internal/process/task_queues.js:86:5)

To Reproduce
Steps to reproduce the behavior:

  1. Create a basic Prisma 2 project using prisma2 init and configure with PostgreSQL credentials
  2. Create this datamodel:
datasource db {
  provider = "postgres"
  url      = "postgresql://test:test@localhost:5432/test?schema=public"
}

generator js {
  provider = "photonjs"
  output    = "./generated/photon"
}

model User {
  id    String @default(uuid()) @id
  email String @unique
  name  String
}
  1. Run initial deployment of schema / migration
  2. Attempt to query photon.users() - works fine (so we are connected)
  3. Attempt to create User
ctx.photon.users.upsert({
    create: {
        email: '[email protected]',
        name: 'Test Testersson'
    },
    update: {
        name: 'Test Terstersson'
    },
    where: {
        email: '[email protected]'
    }
});
  1. This should cause the provided error mentioned above

Expected behavior
I should be able to upsert a user

Versions (please complete the following information):

  • Connector: Postgres
  • Prisma Server: No server
  • prisma2 CLI: prisma2/0.0.87 (Linux x86_64) node-v11.15.0
  • OS: Arch Linux w/Linux v5.1.9

Activity

  1. transferred this issue fromprisma/prisma1on Jun 25, 2019
  2. added this to the milestone on Jun 26, 2019
  3. pantharshit00 commented on Jul 16, 2019

    @pantharshit00
    Contributor

    Hi @ChristianJacobsen

    Thanks for reporting this. I can confirm this.

    Right now we have a similar issue that covers a more variety of crud operations that are failing in postgres.

    So I am closing this issue in favour of #166

  4. ChristianJacobsen commented on Jul 16, 2019

    @ChristianJacobsen
    ContributorAuthor
  5. added a commit that references this issue on Aug 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions