by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    antoyo
    @antoyo
    quit
    jq-rs
    @jq-rs
    Hi! I'm interested to give a go for the SQlite part of TQL. An example similar to Postgres would be nice to have for the README.
    antoyo
    @antoyo
    Sure. For now, you can take a look at this [test][https://github.com/antoyo/tql/tree/master/tests/sqlite-tests).
    jq-rs
    @jq-rs
    Thanks! I actually did already, but it does not have any connect. Is it so that SQlite does not need any connect at all?
    I guess I would need to anyway be able to define the database file.
    antoyo
    @antoyo
    Yes, indeed. I use an in-memory connection for most SQLite tests.
    Like here.
    You can just use another method of Connection to have a connection to a file.
    jq-rs
    @jq-rs
    OK, thanks! It seems additional rusqlite crate in addition libsqlite3-sys is a must then.
    antoyo
    @antoyo
    Yes. For now, there's no pure Rust SQLite library.
    jq-rs
    @jq-rs
    I ran into some trouble on stable. I tried to cover the example, but seems that it does not compile too well:
    error[E0277]: the trait bound `rusqlite::types::ToSqlOutput<'_>: std::convert::From<&i32>` is not satisfied
      --> src/main.rs:53:23
       |
    53 |          let result = sql!(connection, Model.get(id).update(text = "new-text"));
       |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<&i32>` is not implemented for `rusqlite::types::ToSqlOutput<'_>`
       |
       = help: the following implementations were found:
                 <rusqlite::types::ToSqlOutput<'a> as std::convert::From<T>>
                 <rusqlite::types::ToSqlOutput<'a> as std::convert::From<&'a T>>
       = note: required because of the requirements on the impl of `std::convert::Into<rusqlite::types::ToSqlOutput<'_>>` for `&i32`
       = note: required because of the requirements on the impl of `rusqlite::types::ToSql` for `&i32`
       = note: required for the cast to the object type `rusqlite::types::ToSql`
       = note: this error originates in a macro outside of the current crate
    The connection was missing from README examples, so I added it.
    It does seem to be able to compile the get_connection() part.
    jq-rs
    @jq-rs
    And get the id from first insert.
    After some tuning, at least.
    antoyo
    @antoyo
    It looks like you found a bug. Could be please open an issue or post the complete code somewhere?
    antoyo
    @antoyo
    By the look of it, you're trying to send a &i32 instead of i32, but tql should not output this error.
    antoyo
    @antoyo
    @jq-rs: I cannot reproduce this issue. Could you please open an issue with a complete example project? Thank you.
    jq-rs
    @jq-rs
    Hi! Sorry for the delay. Sure, I'll create an issue about it. Moreover, you should be able to reproduce the problem by just trying to recreate README example config on SQlite.
    jq-rs
    @jq-rs
    I was able to do the README example with minor changes on nightly. Using nigthly is just fine for me. I think the README example is just misleading for 0.1 tql. I'll create an issue about that.
    #30 now done.
    antoyo
    @antoyo
    Thank you.
    Ok, I think I am able to get the same error as you with SQLite.
    jq-rs
    @jq-rs
    Hi! I was able to proceed with nightly, and looks pretty good so far. A couple of questions: How is it possible to point into a Sqlite text field which is also a primary key?
    Then I have a table which looks like this in Sqlite:
    CREATE TABLE aineslista (ateria text not null, aines text not null, maara real not null, mitta text, PRIMARY KEY (ateria, aines))
    I try to access it with this struct:
    #[derive(SqlTable)]
    struct Aineslista {
        ateria: String,
        aines: String,
        maara: f64,
        mitta: String
    }
    jq-rs
    @jq-rs
                let ainekset: Vec<Aineslista> = sql!(connection, Aineslista.filter(ateria == ateria.nimi)).unwrap();
                for aines in ainekset {
                    contents.push_str(&aines.aines);
                    contents.push_str("<br />");
                }
    And for some reason I get: thread 'main' panicked at 'called Result::unwrap() on an Err value: InvalidColumnType(3, Null)'
    Any idea what goes wrong? Maybe real does not match to f64 (I have created the table outside of TQL)? Thanks for your replies in advance!
    antoyo
    @antoyo
    Yes, the fields that do not contain NOT NULL should be Option<…>.
    jq-rs
    @jq-rs
    Alright, thanks a lot!
    jq-rs
    @jq-rs
    Yep, now it works! Thanks!
    antoyo
    @antoyo
    You're welcome.
    Farzeen
    @happycoder97
    Will this work with MySQL/MariaDB?
    Ali kim
    @elastic7327
    Yo
    antoyo
    @antoyo
    @happycoder97 It should be relatively easy to add support for MariaDB, but I'm not maintaining this project anymore, so if you are interested, you can work on it.