NyxCode / ormx

bringing orm-like features to sqlx
MIT License
287 stars 32 forks source link

fix update() assigning values to columns marked with `default` #13

Closed nicoulaj closed 1 month ago

nicoulaj commented 3 years ago

This fixes a bug where update() does not exclude generated columns annotated with default attribute, leading to compilation errors when using #[derive(ormx::Table)] with postgres:

error returned from database: column "foo" can only be updated to DEFAULT
NyxCode commented 3 years ago

Hey, thanks for the PR. #[ormx(default)] was intended to be used for columns with a default value. For supporting generated columns, I suggest we introduce an other PG-specific attribute, maybe #[ormx(generated)], which would have the effect you implemented here for #[ormx(default)].

nicoulaj commented 3 years ago

Is it really PG specific though ? Mysql also has generated columns.

NyxCode commented 3 years ago

thats possible, never worked with it though. But as I said, we need to differentiate between default and generated.

NyxCode commented 3 years ago

@nicoulaj Are you still willing to persue this? I think support for #[ormx(generated)] would be super cool.