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

Type convertion errors #34

Open
Tembocs opened this issue May 1, 2018 · 0 comments
Open

Type convertion errors #34

Tembocs opened this issue May 1, 2018 · 0 comments

Comments

@Tembocs
Copy link

Tembocs commented May 1, 2018

I'm trying to compile this simple program from your example:

#![allow(unused)]
#![allow(dead_code)]
extern crate chrono;
extern crate rusqlite;

#[macro_use]
extern crate tql;
#[macro_use]
extern crate tql_macros;
use rusqlite::Connection;
use tql::PrimaryKey;
use chrono::Utc;
use chrono::DateTime;

#[derive(SqlTable)]
struct Model {
    id: PrimaryKey,
    text: String,
    date_added: DateTime<Utc>
}

fn get_connection() -> Connection {
    Connection::open("database.db").unwrap()
}

fn main() {
    let connection = get_connection();
    let _ = sql!(connection, Model.create());

    // Insert a row in the table.
    let text = String::new();
    let date_added = Utc::now();
    let id = sql!(connection, Model.insert(text = text, date_added = date_added)).unwrap();
}

I got the following type conversion error message:

>> cargo run
   Compiling updater_tql v0.1.0 (file:///C:/Users/tembo/Desktop/qnd/updater_tql)
error[E0277]: the trait bound `rusqlite::types::ToSqlOutput<'_>: std::convert::From<&std::string::String>` is not satisfied
  --> src\main.rs:41:14
   |
41 |     let id = sql!(connection, Model.insert(text = text, date_added = date_added)).unwrap();
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<&std::string::String>` is not implemented for `rusqlite::types::ToSqlOutput<'_>`
   |
   = help: the following implementations were found:
             <rusqlite::types::ToSqlOutput<'a> as std::convert::From<&'a T>>
             <rusqlite::types::ToSqlOutput<'a> as std::convert::From<T>>
   = note: required because of the requirements on the impl of `std::convert::Into<rusqlite::types::ToSqlOutput<'_>>` for `&std::string::String`
   = note: required because of the requirements on the impl of `rusqlite::types::ToSql` for `&std::string::String`
   = note: required for the cast to the object type `rusqlite::types::ToSql`
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0277]: the trait bound `rusqlite::types::ToSqlOutput<'_>: std::convert::From<&chrono::DateTime<chrono::Utc>>` is not satisfied
  --> src\main.rs:41:14
   |
41 |     let id = sql!(connection, Model.insert(text = text, date_added = date_added)).unwrap();
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<&chrono::DateTime<chrono::Utc>>` is not implemented for `rusqlite::types::ToSqlOutput<'_>`
   |
   = help: the following implementations were found:
             <rusqlite::types::ToSqlOutput<'a> as std::convert::From<&'a T>>
             <rusqlite::types::ToSqlOutput<'a> as std::convert::From<T>>
   = note: required because of the requirements on the impl of `std::convert::Into<rusqlite::types::ToSqlOutput<'_>>` for `&chrono::DateTime<chrono::Utc>`
   = note: required because of the requirements on the impl of `rusqlite::types::ToSql` for `&chrono::DateTime<chrono::Utc>`
   = note: required for the cast to the object type `rusqlite::types::ToSql`
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0277`.
error: Could not compile `updater_tql`.

To learn more, run the command again with --verbose.

Were you able to run your example without these kind of errors?

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

1 participant