zdennis/activerecord-import

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

mpkhr opened this issue · 0 comments

mpkhr commented

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 #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!