Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Georg Semmler
    @weiznich
    Arun Karikalan
    @karikalanarun
    Okay, Thanks. Can i get the date for older nightly release?. I can’t found anywhere.
    Georg Semmler
    @weiznich
    Have a look at the rustup documentation.
    Rotem Yaari
    @vmalloc
    Hi, Is there a way to use an existing schema, but select from a differently named table? Say I have several identical tables that I switch between, and I want to use the schema but replace where I select from...
    Georg Semmler
    @weiznich
    What part exactly do you want to reuse?
    Rotem Yaari
    @vmalloc
    all the column definitions and their associated type-safety features
    ideally I'd want something like:
    schema::mytable.<rename to bla>.filter(schema::mytable::columns::x.eq(2)...)
    The use case is a sharded/rotated table -- the code has to choose what shard it is reading from
    but other than that all the filtering/selecting logic is the same
    Georg Semmler
    @weiznich
    No that's not easily possible. Probably if you use diesel-dynamic-schema, but then you lose the type safety features, because the are build on the assumption that different columns are different types.
    Rotem Yaari
    @vmalloc
    I see.
    Adrián Arroyo Calle
    @aarroyoc
    Hi, latest release of Diesel (1.4.3) is currently broken on Rust nightly.
    error[E0275]: overflow evaluating the requirement <Self as query_dsl::limit_dsl::LimitDsl>::Output
    Georg Semmler
    @weiznich
    Adrián Arroyo Calle
    @aarroyoc
    @weiznich thanks!
    KOKOU AFIDEGNON
    @afidegnum
    how do i structure my diesel applications for about 20 tables with relations?
    do i provide CRUD for a package like /table_name/model.rs and /table_name/lib.rs how will i manage their schema.rs
    do you have other suggestions?
    Georg Semmler
    @weiznich
    That entirely depends on what you are want to do in your application. There are use case where it makes sense to have only specific functionality for certain tables at the point where you actually need them and there are cases where want some kind of API boundary to separate different modules (again how this boundary look like is highly application specific).
    KOKOU AFIDEGNON
    @afidegnum
    well, am building, cli, api, and normal business oriented web application comprised of admin/special_roles and anonymous users. they will have custom accessibility rights
    Georg Semmler
    @weiznich
    So you probably want to put all database related code in a separate crate and provide an API there that fits your use case (That's something only you can answer)
    KOKOU AFIDEGNON
    @afidegnum
    @weiznich means crate dbmodel under ../src ?
    Georg Semmler
    @weiznich
    That entirely depends on your code organization.
    KOKOU AFIDEGNON
    @afidegnum
    ?
    Georg Semmler
    @weiznich
    It's your decision, there is no right or wrong model there.
    KOKOU AFIDEGNON
    @afidegnum
    how do i direct diesel to generate schema.rs to src/models/schema.rs instead of src/schema.rs ?
    Georg Semmler
    @weiznich
    Have a look at the diesel cli guide? It's all explained there…
    Duan Uys
    @duysPES
    Hell! I am having some trouble with implementing a ARRAY in postgres. I have a struct that is defined in the following:
        #[derive(Queryable, Insertable, Debug, AsChangeset, Clone, Serialize, Deserialize)]
        pub struct Account {
            /// unique id for each account
            pub uid: UID,
            /// name of account
            pub name: String,
    
            /// password for account
            pub password: String,
    
            /// email associated with account
            pub email: String,
    
            /// Characters stored as a vector of the character UID numbers
            pub characters: Vec<i64>,
        }
    I am getting an error trying to insert structs like this to postgres saying that:
     ^^^^^^^^^^ the trait `diesel::deserialize::FromSql<diesel::sql_types::Nullable<diesel::sql_types::Array<diesel::sql_types::BigInt>>, diesel::pg::Pg>` is not implemented for `std::vec::Vec<i64>`
    The up.sql file looks like this:
    CREATE TABLE Accounts ( uid BIGINT NOT NULL CHECK (uid > 0), name varchar(64) NOT NULL, password varchar(64) NOT NULL, email varchar(64) NOT NULL, characters BIGINT ARRAY, PRIMARY KEY (uid))
    Georg Semmler
    @weiznich
    Your array is nullable, therefore the corresponding rust type needs to be Option<Vec<i64>>.
    Duan Uys
    @duysPES
    even an empty Vec is null in postgres?
    Georg Semmler
    @weiznich
    Null and empty are different things.
    Duan Uys
    @duysPES
    My argument, excuse my ignorance, when i sent a record to be upserted into the database, the structure requires that I defined all fields. So even characters at the very least would be Vec::new() just an empty list, how would that be nullable?
    Georg Semmler
    @weiznich
    An empty vector is not null. It's an empty vector.
    Duan Uys
    @duysPES
    exactly, so why wouldn't just Vec<i64> work? why would I need to wrap it in an Option?
    Georg Semmler
    @weiznich
    That error is from Queryable not from insert/update. An empty vector is a valid value for inserting into a nullable array column, but a possible nullable array column cannot be deserialized into a vector
    Duan Uys
    @duysPES
    ohh, it's to handle the other way around
    Okay, that makes sense. Thanks @weiznich
    Georg Semmler
    @weiznich
    It's saying FromSql not ToSql :wink:
    Duan Uys
    @duysPES
    Wow, yea that just glazed over my head. I read it, but didn't read it
    lol
    thaks
    Duan Uys
    @duysPES
    when making multiple tables via diesel migration do I declare all sql tables within a single diesel migration generate xx? it seems that if I do multiple generate coupled with migration redo it only redoes the latest one?
    Georg Semmler
    @weiznich
    Yes migration redo will only redo the last migration.
    Duan Uys
    @duysPES
    okay, so I woul have to declare ALL the tables that I need in a single diesel migration generate xxx
    okay, thansk
    Georg Semmler
    @weiznich
    You don't need to do that, it's a matter of personal preferences how you handle that. (I tend to do that because I do not see multiple tables as a separate migration step if I change them at once, but there are other opinions there)
    If you do one migration per table and want to use migration redo you just cannot work on more than one migration at once. (That's in general a good thing :wink:)