Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db pull fail with particular enum default value in column #17047

Closed
Killian-G opened this issue Dec 28, 2022 · 2 comments · Fixed by prisma/prisma-engines#3761
Closed

db pull fail with particular enum default value in column #17047

Killian-G opened this issue Dec 28, 2022 · 2 comments · Fixed by prisma/prisma-engines#3761
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. topic: introspection topic: mysql topic: prisma db pull CLI: prisma db pull
Milestone

Comments

@Killian-G
Copy link

Bug description

Hi, I have some problems with the introspection engine when I run the command db pull when I have a table with a column that contains an enum with an apostrophe and if this enum value is the default, I got a Rust error:

✖ Introspecting based on datasource defined in prisma-db/schema.prisma

Oops, an unexpected error occurred!
[introspection-engine/connectors/sql-introspection-connector/src/pair/default.rs:76:22] called `Option::unwrap()` on a `None` value

With DEBUG= "*" i have this

prisma:introspectionEngine:stderr  {"is_panic":true,"message":"[introspection-engine/connectors/sql-introspection-connector/src/pair/default.rs:76:22] called `Option::unwrap()` on a `None` value","backtrace":"   0: user_facing_errors::panic_hook::set_panic_hook::{{closure}}\n   1: std::panicking::rust_panic_with_hook\n             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:702:17\n   2: std::panicking::begin_panic_handler::{{closure}}\n             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:586:13\n   3: std::sys_common::backtrace::__rust_end_short_backtrace\n             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/sys_common/backtrace.rs:138:18\n   4: rust_begin_unwind\n             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:584:5\n   5: core::panicking::panic_fmt\n             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:142:14\n   6: core::panicking::panic\n             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:48:5\n   7: sql_introspection_connector::rendering::models::render_model\n   8: sql_introspection_connector::datamodel_calculator::calculate\n   9: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll\n  10: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll\n  11: <futures_util::future::either::Either<A,B> as core::future::future::Future>::poll\n  12: <futures_util::future::future::Then<Fut1,Fut2,F> as core::future::future::Future>::poll\n  13: tokio::runtime::task::core::CoreStage<T>::poll\n  14: tokio::runtime::task::raw::poll\n  15: tokio::runtime::scheduler::multi_thread::worker::Context::run_task\n  16: tokio::runtime::task::raw::poll\n  17: tokio::runtime::task::UnownedTask<S>::run\n  18: std::sys_common::backtrace::__rust_begin_short_backtrace\n  19: core::ops::function::FnOnce::call_once{{vtable.shim}}\n  20: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once\n             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/alloc/src/boxed.rs:1935:9\n      <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once\n             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/alloc/src/boxed.rs:1935:9\n      std::sys::unix::thread::Thread::new::thread_start\n             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/sys/unix/thread.rs:108:17\n  21: start_thread\n             at ./nptl/./nptl/pthread_create.c:442:8\n  22: clone3\n             at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81\n"}
✖ Introspecting based on datasource defined in prisma-db/schema.prisma

Oops, an unexpected error occurred!
[introspection-engine/connectors/sql-introspection-connector/src/pair/default.rs:76:22] called `Option::unwrap()` on a `None` value

How to reproduce

To reproduce this error, you need just a database with this table:

CREATE TABLE table_with_enum
(
    enum_column ENUM('don''t know') DEFAULT 'don''t know' NOT NULL
);

and run db pull on this database to get the error

Expected behavior

The expected behavior is to get the schema generated by the command

Prisma information

generator client {
  provider        = "prisma-client-js"
}

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

Environment & setup

  • OS: Ubuntu 22.04
  • Database: MySQL
  • Node.js version: v16.15.1

Prisma Version

prisma                  : 4.8.0
@prisma/client          : 4.8.0
Current platform        : debian-openssl-3.0.x
Query Engine (Node-API) : libquery-engine d6e67a83f971b175a593ccc12e15c4a757f93ffe (at ../../.nvm/versions/node/v16.15.1/lib/node_modules/prisma/node_modules/@prisma/engines/libquery_engine-debian-openssl-3.0.x.so.node)
Migration Engine        : migration-engine-cli d6e67a83f971b175a593ccc12e15c4a757f93ffe (at ../../.nvm/versions/node/v16.15.1/lib/node_modules/prisma/node_modules/@prisma/engines/migration-engine-debian-openssl-3.0.x)
Introspection Engine    : introspection-core d6e67a83f971b175a593ccc12e15c4a757f93ffe (at ../../.nvm/versions/node/v16.15.1/lib/node_modules/prisma/node_modules/@prisma/engines/introspection-engine-debian-openssl-3.0.x)
Format Binary           : prisma-fmt d6e67a83f971b175a593ccc12e15c4a757f93ffe (at ../../.nvm/versions/node/v16.15.1/lib/node_modules/prisma/node_modules/@prisma/engines/prisma-fmt-debian-openssl-3.0.x)
Format Wasm             : @prisma/prisma-fmt-wasm 4.8.0-61.d6e67a83f971b175a593ccc12e15c4a757f93ffe
Default Engines Hash    : d6e67a83f971b175a593ccc12e15c4a757f93ffe
Studio                  : 0.479.0
@Killian-G Killian-G added the kind/bug A reported bug. label Dec 28, 2022
@jkomyno jkomyno added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. team/schema Issue for team Schema. labels Dec 29, 2022
@pimeys pimeys self-assigned this Mar 3, 2023
@pimeys pimeys added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Mar 3, 2023
@pimeys
Copy link
Contributor

pimeys commented Mar 3, 2023

Yup. Breaks.

@pimeys
Copy link
Contributor

pimeys commented Mar 3, 2023

This bug is about different escape character handling. When we fetch the variants, we load the default as don't know and the variant as don''t know. Then we try to find the variant with the default value, cannot do that, panic and go nuts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/schema Issue for team Schema. topic: introspection topic: mysql topic: prisma db pull CLI: prisma db pull
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants