activerecord-import icon indicating copy to clipboard operation
activerecord-import copied to clipboard

Default values not set for non-primary-key uuid columns

Open mpkhr opened this issue 1 year ago • 0 comments

I have a non-PK uuid field some_other_id that is either set by application logic or otherwise defaults to gen_random_uuid on database level (just like the primary id works too). I observed the following bevahior:

  • If some_other_id is nil, I receive a not-null error from the database
  • If I exclude that column through columns = MyModel.column_names - ["some_other_id"] the function seems executed, but then I cannot pass a value (i.e. the non-defaulting case)

With this observation the current behavior seems like a bug to me.

I saw there is an open PR https://github.com/zdennis/activerecord-import/pull/802 which addresses it: :omit_columns_with_default_functions | true/false|false | Automatically omit columns that have a default function defined in the schema, such as non-PK uuid columns. But I'm not sure if it allows to still pass a value.

Can this issue be fixed?

Thank you!

mpkhr avatar Feb 05 '24 11:02 mpkhr