reform icon indicating copy to clipboard operation
reform copied to clipboard

Skip trying to insert generated fields

Open mikestefanello opened this issue 2 years ago • 1 comments

Describe the bug Some of my PG tables have generated fields. Trying to insert records for those models will fail, even if you omit the field because the query will still try to insert nil rather than nothing at all.

To Reproduce Steps to reproduce the behavior:

  1. Generate a model for a table in PG that has a generated field
  2. Try to insert a model record for that table
  3. The insert will fail, ie pq: cannot insert into column "the_generated_field_name"

Expected behavior Insert/update queries should automatically exclude any generated fields.

mikestefanello avatar Feb 02 '22 17:02 mikestefanello

Some background on why nil/NULL is being added to the query: https://github.com/go-reform/reform/issues/146#issuecomment-359029463

See also #100.

AlekSi avatar Feb 02 '22 18:02 AlekSi