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

Support batch insert for pooled sqlite connections and/or make it clear that connection pooling shouldn't be used with SQLite #1822

Open
tahahawa opened this Issue Aug 13, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@tahahawa

tahahawa commented Aug 13, 2018

This was used to help reproduce the issue.

https://gitlab.com/tahahawa/discord-markov-bot/blob/eae22b1744348b70b5ceccbe9db148b34352b41b/src/commands/helper.rs

The code:

let conn = sql_pool.get().unwrap();
let _ = diesel::replace_into(messages::table)
    .values(message_vec)
    .execute(&conn)
    .expect("Error inserting values");

Causes:

error[E0277]: the trait bound `diesel::sqlite::Sqlite: diesel::backend::SupportsDefaultKeyword` is not satisfied
   --> src/commands/helper.rs:184:10
    |
184 |         .execute(&conn)
    |          ^^^^^^^ the trait `diesel::backend::SupportsDefaultKeyword` is not implemented for `diesel::sqlite::Sqlite`
    |
    = note: required because of the requirements on the impl of `diesel::query_builder::QueryFragment<diesel::sqlite::Sqlite>` for `diesel::insertable::BatchInsert<'_, models::InsertableMessage, schema::messages::table>`
    = note: required because of the requirements on the impl of `diesel::query_builder::QueryFragment<diesel::sqlite::Sqlite>` for `diesel::query_builder::InsertStatement<schema::messages::table, diesel::insertable::BatchInsert<'_, models::InsertableMessage, schema::messages::table>, diesel::query_builder::insert_statement::Replace>`
    = note: required because of the requirements on the impl of `diesel::query_dsl::load_dsl::ExecuteDsl<diesel::r2d2::PooledConnection<diesel::r2d2::ConnectionManager<diesel::SqliteConnection>>, diesel::sqlite::Sqlite>` for `diesel::query_builder::InsertStatement<schema::messages::table, diesel::insertable::BatchInsert<'_, models::InsertableMessage, schema::messages::table>, diesel::query_builder::insert_statement::Replace>`

Current fix:
Change &conn to &*conn

Setup

Versions

  • Rust: 1.28.0
  • Diesel: 1.3.2
  • Database: SQLite with R2D2 pooling
  • Operating System Arch Linux

Feature Flags

  • diesel: ["sqlite","r2d2"]

Checklist

  • I have already looked over the issue tracker for similar issues.
  • This issue can be reproduced on Rust's stable channel. (Your issue will be
    closed if this is not the case)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment