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

Add support for "unsigned" numeric fields #12

Closed
longsleep opened this issue Jan 24, 2023 · 2 comments
Closed

Add support for "unsigned" numeric fields #12

longsleep opened this issue Jan 24, 2023 · 2 comments

Comments

@longsleep
Copy link
Collaborator

Hi, I just gave this project a try to generate DB models for an existing database. The database uses unsigned integers on may columns. Those get typed (for example) as i32 where it should be u32.

I came accross https://github.com/Wulf/dsync/blob/12979e00998635291ecaf721cf6bc4282d9808ee/src/parser.rs (but there is no panic, or message visible when running dsync.

The resulting problem is, that all models fail to derive Insertable and AsChangeset.

trait bound `i32: diesel::Expression` is not satisfied

For example this table

diesel::table! {
    aliases (id) {
        id -> Unsigned<Integer>,
        aliasname -> Varchar,
        mainname -> Varchar,
    }
}

yields with dsync:

#[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, AsChangeset, Identifiable)]
#[diesel(table_name=aliases, primary_key(id))]
pub struct Aliase {
    pub id: i32,
    pub aliasname: String,
    pub mainname: String,
}

And with https://github.com/abbychau/diesel_cli_ext (where it works):

#[derive(Debug, Serialize, Deserialize, Clone, Queryable, Insertable, AsChangeset, Identifiable)]
#[diesel(table_name = aliases)]
pub struct Aliase {
    pub id: u32,
    pub aliasname: String,
    pub mainname: String,
}
Wulf added a commit that referenced this issue Feb 24, 2023
@Wulf
Copy link
Owner

Wulf commented Feb 24, 2023

hey @longsleep, hope things are well -- thanks for your request and showing examples. Sorry it took so long to get this out.

0.0.10 should have this fixed :-)

@Wulf
Copy link
Owner

Wulf commented Mar 6, 2023

Closing, feel free to reopen if you encounter any issues!

@Wulf Wulf closed this as completed Mar 6, 2023
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

2 participants