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

Bug: db application code out of sync with migrations - error trait bound is not satisfied. #1339

Open
cameronvoell opened this issue Nov 26, 2024 · 3 comments · May be fixed by #1344
Open
Labels
bug Something isn't working

Comments

@cameronvoell
Copy link
Contributor

cameronvoell commented Nov 26, 2024

Describe the bug

currently on main branch cargo run --bin update-schema --features update-schema from xmtp_mls directory creates the following code diff:

https://github.com/xmtp/libxmtp/compare/cv/test-migration-on-main?expand=1#diff-bd2907561f23f5c88f95cebd28c7a4bb56585017a04c75fbce3eff3997863788

after that change, trying to run any tests in libxmtp results in the errors:


error[E0277]: the trait bound `(Vec<u8>, i64, GroupMembershipState, i64, encrypted_store::group::ConversationType, std::string::String, std::option::Option<i64>, std::option::Option<std::string::String>, i64): FromStaticSqlRow<(diesel::sql_types::Binary, diesel::sql_types::BigInt, diesel::sql_types::Integer, diesel::sql_types::BigInt, diesel::sql_types::Text, diesel::sql_types::Nullable<diesel::sql_types::BigInt>, diesel::sql_types::Nullable<diesel::sql_types::Text>, diesel::sql_types::BigInt, diesel::sql_types::Integer), diesel::sqlite::Sqlite>` is not satisfied
    --> xmtp_mls/src/storage/encrypted_store/group.rs:421:29
     |
421  |                 .get_result(conn)
     |                  ---------- ^^^^ the trait `FromStaticSqlRow<(diesel::sql_types::Binary, diesel::sql_types::BigInt, diesel::sql_types::Integer, diesel::sql_types::BigInt, diesel::sql_types::Text, diesel::sql_types::Nullable<diesel::sql_types::BigInt>, diesel::sql_types::Nullable<diesel::sql_types::Text>, diesel::sql_types::BigInt, diesel::sql_types::Integer), diesel::sqlite::Sqlite>` is not implemented for `(Vec<u8>, i64, GroupMembershipState, i64, encrypted_store::group::ConversationType, std::string::String, std::option::Option<i64>, std::option::Option<std::string::String>, i64)`, which is required by `InsertStatement<encrypted_store::schema::groups::table, diesel::query_builder::upsert::on_conflict_clause::OnConflictValues<diesel::query_builder::insert_statement::ValuesClause<(DefaultableColumnInsertValue<ColumnInsertValue<encrypted_store::schema::groups::columns::id, expression::bound::Bound<diesel::sql_types::Binary, &Vec<u8>>>>, DefaultableColumnInsertValue<ColumnInsertValue<encrypted_store::schema::groups::columns::created_at_ns, expression::bound::Bound<diesel::sql_types::BigInt, &i64>>>, DefaultableColumnInsertValue<ColumnInsertValue<encrypted_store::schema::groups::columns::membership_state, expression::bound::Bound<diesel::sql_types::Integer, &GroupMembershipState>>>, DefaultableColumnInsertValue<ColumnInsertValue<encrypted_store::schema::groups::columns::installations_last_checked, expression::bound::Bound<diesel::sql_types::BigInt, &i64>>>, DefaultableColumnInsertValue<ColumnInsertValue<encrypted_store::schema::groups::columns::conversation_type, expression::bound::Bound<diesel::sql_types::Integer, &encrypted_store::group::ConversationType>>>, DefaultableColumnInsertValue<ColumnInsertValue<encrypted_store::schema::groups::columns::added_by_inbox_id, expression::bound::Bound<diesel::sql_types::Text, &std::string::String>>>, DefaultableColumnInsertValue<ColumnInsertValue<encrypted_store::schema::groups::columns::welcome_id, expression::bound::Bound<diesel::sql_types::Nullable<diesel::sql_types::BigInt>, &i64>>>, DefaultableColumnInsertValue<ColumnInsertValue<encrypted_store::schema::groups::columns::dm_inbox_id, expression::bound::Bound<diesel::sql_types::Nullable<diesel::sql_types::Text>, &std::string::String>>>, DefaultableColumnInsertValue<ColumnInsertValue<encrypted_store::schema::groups::columns::rotated_at_ns, expression::bound::Bound<diesel::sql_types::BigInt, &i64>>>), encrypted_store::schema::groups::table>, diesel::query_builder::upsert::on_conflict_target::NoConflictTarget, diesel::query_builder::upsert::on_conflict_actions::DoNothing<encrypted_store::schema::groups::table>>>: LoadQuery<'_, _, _>`

Expected behavior

No response

Steps to reproduce the bug

No response

@cameronvoell cameronvoell added the bug Something isn't working label Nov 26, 2024
@cameronvoell
Copy link
Contributor Author

I think we never ran the update-schema script in xmtp_mls after this update was made: #1304

@insipx
Copy link
Contributor

insipx commented Nov 26, 2024

I think I ran into this before, it's because 'StoredGroups' or whatever table is trying to derive 'FromRow' has conversation type out of order with the schema table generated

The fix is to just fix the structure and make sure the 'conversation_type' field matches the generated code

Docs: https://docs.rs/diesel/latest/diesel/deserialize/trait.Queryable.html

Can add some derives to check for this a compile time and avoid issue

@cameronvoell cameronvoell linked a pull request Nov 26, 2024 that will close this issue
@codabrink
Copy link
Contributor

Yeah, Naomi ran into this when she did migrations a while ago too. I ran into it recently as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants