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

sea-orm-cli --verbose for debugging #153

Closed
fenhl opened this issue Sep 13, 2021 · 4 comments
Closed

sea-orm-cli --verbose for debugging #153

fenhl opened this issue Sep 13, 2021 · 4 comments
Assignees

Comments

@fenhl
Copy link

fenhl commented Sep 13, 2021

I tried running sea-orm-cli generate entity on an existing PostgreSQL database and it panicked at https://github.com/SeaQL/sea-schema/blob/7099a2eaa10efb0eaacb07ff39b34dcb1510057a/src/postgres/parser/table_constraints.rs#L39. Backtrace:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/fenhl/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/sea-schema-0.2.7/src/postgres/parser/table_constraints.rs:39:47
stack backtrace:
   0: rust_begin_unwind
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:50:5
   3: <sea_schema::postgres::parser::table_constraints::TableConstraintsQueryResultParser as core::iter::traits::iterator::Iterator>::next
   4: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
   5: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   6: <futures_util::future::join_all::JoinAll<F> as core::future::future::Future>::poll
   7: sea_orm_cli::run_generate_command::{{closure}}
   8: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
   9: std::thread::local::LocalKey<T>::with
  10: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  11: async_io::driver::block_on
  12: std::thread::local::LocalKey<T>::with
  13: async_std::task::builder::Builder::blocking
  14: sea_orm_cli::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@billy1624
Copy link
Member

billy1624 commented Sep 13, 2021

Hi @fenhl, thank you so much for the issue.

We need more information to debug it. Would you mind...

  1. Cloning the master of sea-schema

  2. Go to sea-schema/tests/writer/postgres directory

  3. Update the connection string at here accordingly

    let connection = PgPool::connect("postgres://<username>:<password>@localhost/<database>")
        .await
        .unwrap();
    
    let schema_discovery = SchemaDiscovery::new(connection, "<schema>");
  4. Finally, run it with cargo run command, you will see similar output as below and perhaps a panic

    TableConstraintsQueryResult { constraint_schema: "public", constraint_name: "2200_41674_1_not_null", table_schema: "public", table_name: "actor", constraint_type: "CHECK", is_deferrable: "NO", initially_deferred: "NO", check_clause: Some("actor_id IS NOT NULL"), column_name: None, ordinal_position: None, position_in_unique_constraint: None, unique_constraint_schema: None, unique_constraint_name: None, match_option: None, update_rule: None, delete_rule: None, referential_key_table_name: None, referential_key_column_name: None }
    TableConstraintsQueryResult { constraint_schema: "public", constraint_name: "2200_41674_2_not_null", table_schema: "public", table_name: "actor", constraint_type: "CHECK", is_deferrable: "NO", initially_deferred: "NO", check_clause: Some("first_name IS NOT NULL"), column_name: None, ordinal_position: None, position_in_unique_constraint: None, unique_constraint_schema: None, unique_constraint_name: None, match_option: None, update_rule: None, delete_rule: None, referential_key_table_name: None, referential_key_column_name: None }
    TableConstraintsQueryResult { constraint_schema: "public", constraint_name: "2200_41674_3_not_null", table_schema: "public", table_name: "actor", constraint_type: "CHECK", is_deferrable: "NO", initially_deferred: "NO", check_clause: Some("last_name IS NOT NULL"), column_name: None, ordinal_position: None, position_in_unique_constraint: None, unique_constraint_schema: None, unique_constraint_name: None, match_option: None, update_rule: None, delete_rule: None, referential_key_table_name: None, referential_key_column_name: None }
    TableConstraintsQueryResult { constraint_schema: "public", constraint_name: "2200_41674_4_not_null", table_schema: "public", table_name: "actor", constraint_type: "CHECK", is_deferrable: "NO", initially_deferred: "NO", check_clause: Some("last_update IS NOT NULL"), column_name: None, ordinal_position: None, position_in_unique_constraint: None, unique_constraint_schema: None, unique_constraint_name: None, match_option: None, update_rule: None, delete_rule: None, referential_key_table_name: None, referential_key_column_name: None }
    TableConstraintsQueryResult { constraint_schema: "public", constraint_name: "actor_pkey", table_schema: "public", table_name: "actor", constraint_type: "PRIMARY KEY", is_deferrable: "NO", initially_deferred: "NO", check_clause: None, column_name: Some("actor_id"), ordinal_position: Some(1), position_in_unique_constraint: None, unique_constraint_schema: None, unique_constraint_name: None, match_option: None, update_rule: None, delete_rule: None, referential_key_table_name: None, referential_key_column_name: None }
    
    Check(Check { name: "2200_41674_1_not_null", expr: "actor_id IS NOT NULL", no_inherit: false })
    Check(Check { name: "2200_41674_2_not_null", expr: "first_name IS NOT NULL", no_inherit: false })
    Check(Check { name: "2200_41674_3_not_null", expr: "last_name IS NOT NULL", no_inherit: false })
    Check(Check { name: "2200_41674_4_not_null", expr: "last_update IS NOT NULL", no_inherit: false })
    
  5. Could you copy the TableConstraintsQueryResult up here so that we can debug it?

Thank you in advance!!

@tyt2y3
Copy link
Member

tyt2y3 commented Sep 15, 2021

We will include a verbose flag in sea-orm-cli to help debugging.

@tyt2y3 tyt2y3 changed the title Option unwrap in CLI sea-orm-cli --verbose Sep 15, 2021
@tyt2y3 tyt2y3 changed the title sea-orm-cli --verbose sea-orm-cli --verbose for debugging Sep 15, 2021
@tyt2y3 tyt2y3 added this to the 0.2.0 milestone Sep 15, 2021
@billy1624 billy1624 self-assigned this Sep 16, 2021
@billy1624 billy1624 mentioned this issue Sep 16, 2021
11 tasks
billy1624 added a commit to SeaQL/seaql.github.io that referenced this issue Sep 17, 2021
@tyt2y3
Copy link
Member

tyt2y3 commented Sep 17, 2021

sea-orm-cli 0.2.2 released

@tyt2y3 tyt2y3 closed this as completed Sep 17, 2021
@fenhl
Copy link
Author

fenhl commented Sep 28, 2021

Should I open a separate issue for my original problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants