Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Edward Mann
    @mann-ed
    @jamessewell i'm using something like this
    diesel = { version = "1.4.6", features = ["postgres", "uuidv07", "chrono", "r2d2"]}
    diesel_full_text_search = { version = "1.0.1" }
    James Sewell
    @jamessewell
    That uses libpq I think?
    rust-postgres is a pure Rust PG implementation
    I think the answer is no
    Edward Mann
    @mann-ed
    yes libpq is what it uses
    Ten0
    @Ten0_gitlab
    Hello!
    I can't find the helper_type for exists (https://docs.diesel.rs/master/diesel/dsl/fn.exists.html) (diesel master). Is it there somewhere? If not, can I PR adding it?
    2 replies
    hacktor_
    @hktr92
    Hello. I have an old project on which I'm considering usage of Rust to improve performance. The MySQL table has a column named type, so I can't use it in struct since is a reserved keyword. So the column is called kind in Rust. Is there a way to let Diesel consider kind as type? I'm unable to find anything like it in documentation nor anything..
    Georg Semmler
    @weiznich
    @hktr92 In which context?
    hacktor_
    @hktr92

    @hktr92 In which context?

    this would be a rough context:
    mysql table: foo { id: uuid, type: int, ... }
    rust struct: struct Foo { id: uuid, kind: FooType } enum FooType { A, B }

    i only want to know if i can tell diesel to hydrate type value into kind (with From implemented on FooType)

    Georg Semmler
    @weiznich
    That does not really tell me in which context you are looking for this conversion. I mean the corresponding name can appear in more than one location, like the table! macro or some struct using a diesel derive. The answer to that question differs really on the exact use case.
    hacktor_
    @hktr92

    That does not really tell me in which context you are looking for this conversion. I mean the corresponding name can appear in more than one location, like the table! macro or some struct using a diesel derive. The answer to that question differs really on the exact use case.

    thanks for the tip, i found what i was looking for in table macro here: http://docs.diesel.rs/diesel/macro.table.html

    Georg Semmler
    @weiznich
    :+1:
    Sean Klein
    @smklein:matrix.org
    [m]
    Hey all! I was struggling to find this in the docs (although I'm happy to read more) - what's the situation for CTEs ("WITH" expressions) in Diesel?
    I found diesel-rs/diesel#762 from a while back, which implies the space has been explored, but wasn't sure about best practices nowadays
    Georg Semmler
    @weiznich
    @smklein:matrix.org That is something that is not supported in the built-in dsl yet. We are open to design suggestions here. Otherwise it is always possible to implement your own dsl extension to add support for sql constructs not supported by diesel itself.
    CarlyRaeJepsenStan
    @CarlyRaeJepsenStan
    Hey there, I just tried to connect to my PostgreSQL 13 database and got the authentication method 10 not recognized
    Has anyone been able to solve this on Mac?
    I looked for the libpq DLLs and haven't found anything that could indicate it could be updated
    Furthermore, my .conf files already have the authentication method set to md5...
    My code is exactly the same as the diesel.rs getting started guide.
    Georg Semmler
    @weiznich
    @CarlyRaeJepsenStan That's not related to your code, but to your postgres configuration. In fact you will run into the same issue using your database url and psql trying to connect to the database. Checkout postgres documentation about authentication methods for details on how to fix that. In general it's really hard for someone without access to your system to give concrete instructions on such configuration issues.
    Wagner
    @mwnDK1402
    Hello! Is it possible to delete from multiple tables in one query like this? If so, how?
    DELETE T1, T2
    FROM T1
    INNER JOIN T2 ON T1.key = T2.key
    WHERE condition;
    Georg Semmler
    @weiznich
    This is not supported by the built-in dsl.
    Wagner
    @mwnDK1402
    Alright, just gotta do that in multiple queries, then. Thanks.
    Wagner
    @mwnDK1402
    Here's my use case, by the way. If you have link tables, this is very useful. I don't know how I would do this in Diesel, so I'm just writing a prepared statement instead in raw SQL. I hope you consider adding this feature, if possible.
    DELETE exhibition, exhibition_ownership
    FROM exhibition
    INNER JOIN exhibition_ownership
    ON exhibition.id = exhibition_ownership.exhibition_id
    WHERE client_id = ?;
    It seems easier to write all my queries in raw SQL. Is that less performant than using the built-in DSL?
    Georg Semmler
    @weiznich
    Feel free to open a feature request to discuss the design and a followup PR adding the implementation. I'm not opposed in having this feature, it's just that this is something that I myself did not need yet so there is no real motivation for me to add this now, especially as there are other things I consider more important for my own projects.
    Wagner
    @mwnDK1402
    Alright, will do.
    Georg Semmler
    @weiznich

    It seems easier to write all my queries in raw SQL. Is that less performant than using the built-in DSL?

    It really depends on your usecase, but assuming you write the same query using raw SQL (via sql_query) and the built-in DSL, using the DSL should normally generate a more performant variant as we know much more about the query at compile time.

    Wagner
    @mwnDK1402
    Yeah, that's what I thought. Well, that's a shame. I'll use the built-in DSL when I can.
    Georg Semmler
    @weiznich
    There is no way to provide the same guarantees based on a user constructed string than one something that we could check on compile time.
    Jovons
    @Jovons
    Hi, I followed examples in ToSql and FromSql to use MyEnum in model struct. However, MyEnum cannot be used as a look-up criteria, due to : the trait diesel::Expression is not implemented for diesel_demo::models::MyEnum
        let results = posts
            .filter(published.eq(diesel_demo::models::MyEnum::A)) // cannot be used as a look-up criteria
            .limit(5)
            .load::<Post>(&connection)
            .expect("Error loading posts");
    Georg Semmler
    @weiznich
    @Jovons It's impossible to say what exactly is wrong with your implementation without knowing details about the implementation. Either include more details or have a look at the corresponding test case.
    codedmart
    @codedmart:matrix.org
    [m]
    I am not sure I understand how modules work, more specifically with import_types and schema.rs. I have a file db/sql_types.rs that has Citext. I also have a db/mod.rs file that has pub mod sql_types in import_types in my diesel.toml I have ["diesel::sql_types::*", "crate::db::sql_types::*"]
    But I still see not found in scope for Citext in schema.rs
    Georg Semmler
    @weiznich
    It's hard to answer that without any details about the actual error message and maybe some code to reproduce the issue. How does your generated table! call look like for example?
    codedmart
    @codedmart:matrix.org
    [m]
    @weiznich: This was generated for one table: https://gist.github.com/codedmart/636a73fb82ecdbbf4f5a140eca27e77e
    Georg Semmler
    @weiznich
    That sounds like the command you used to generate that file did not pickup the import_types statement.
    Are you sure that you actually regenerated the schema.rs after you added the import_types statement to your diesel.toml
    codedmart
    @codedmart:matrix.org
    [m]
    Oh maybe not.
    codedmart
    @codedmart:matrix.org
    [m]
    @weiznich: Now I get this warning: unused import:crate::db::sql_types::Citext``?
    Georg Semmler
    @weiznich
    Could you clarify what's your question? Also you don't need to ping me every time…
    codedmart
    @codedmart:matrix.org
    [m]
    Oh sorry :).
    https://gist.github.com/codedmart/cc6533aea3b89b254ff159aeb71444b6 I see this now when I build? Can I turn off warn on unused imports for schema.rs?
    What does this guy mean by updating the client software?
    I think I'm just going to downgrade my Postgresql - this isn't an important project in any way that needs better authentication
    Oh well
    codedmart
    @codedmart:matrix.org
    [m]
    Nevermind I see