Wulf / dsync

Generate rust structs & query functions from diesel schema files
Other
70 stars 13 forks source link

Fix some things that were broken #112

Closed hasezoey closed 11 months ago

hasezoey commented 11 months ago

This PR is a small collection of fixes from #104, but refactored to current state dsync and separate from the other changes and not being based on #103, in more detail:

these things would likely be catched earlier if the tests would actually be compile tested

hasezoey commented 11 months ago

as this pr is a collection of fixes, i added some things i noticed while doing #114, namely:

Wulf commented 11 months ago

I'm going to add a few more commits here which should take care of some of the chnages which weren't included from #104

Wulf commented 11 months ago

ah, I can't seem to do this. Do you mind adding the following changes?

  1. Remove 'tsync' from Cargo.toml

    image
  2. In src/lib.rs, add the following comment above pub connection_type: String,:

    /// For example:
    /// - `diesel::pg::PgConnection` (default)
    /// - `diesel::sqlite::SqliteConnection`
    /// - `diesel::mysql::MysqlConnection`
    /// - or, your custom diesel connection type (struct which implements `diesel::connection::Connection`)
image
  1. In src/lib.rs, add a default for GenerationConfig before impl GenerationConfig<'_> {
impl<'a> Default for GenerationConfig<'a> {
    fn default() -> Self {
        Self {
            table_options: Default::default(),
            default_table_options: Default::default(),
            connection_type: "diesel::pg::PgConnection".into(),
            diesel_backend: "diesel::pg::Pg".into(),
            schema_path: "crate::schema::".into(),
            model_path: "crate::models::".into(),
            once_common_structs: true,
            once_connection_type: true,
        }
    }
}
image

Aaandddd, that should be all! 🙌

If you're not able to do this, no worries, I can add it in after we merge this in. Just let me know!

hasezoey commented 11 months ago

rebased on latest main, and added the 2. for examples, removing the (default) and adding r2d2, also adding that comment to the binary help. i also changed the previous diesel::prelude::PgConnection to diesel::pg::PgConnection (as requested in https://github.com/Wulf/dsync/pull/114#discussion_r1398265444)

as for 1. remove tsync feature default and 3. GenerationConfig default derive, this should likely be done in a separate PR (the tsync attribute is not added by default and would require a argument (--tsync) in addition to having the feature enabled; generation config default derive would likely need some refactoring to make it work with good defaults (like connection_type)