You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Omit Columns from SQL statements (e.g uuid columns)
I've added two options for omitting columns from the SQL statements, to avoid having to modify class level `self.ignored_columns` since we've had issues with this affecting other code that runs at the same time. These options work as follows:
`Model.import(values, omit_columns: [:guid])` # Omit the guid column from SQL statement, allowing it to generate
`Model.import(values, omit_columns: -> (model, column_name) { [:guid] if model == Model })` Allow per-model decisions, e.g for recursive imports
`Model.import(values, omit_columns: { Model => [:guid] })` Use a hash instead of a proc
The second option is `:omit_columns_with_default_functions` boolean, to automatically find columns that have a default function declared in the schema, and omit them by default.
fix: Require AR 5.0+
:batch_size | `Integer` | total # of records | Max number of records to insert per import
278
283
:raise_error | `true`/`false` | `false` | Raises an exception at the first invalid record. This means there will not be a result object returned. The `import!` method is a shortcut for this.
279
284
:all_or_none | `true`/`false` | `false` | Will not import any records if there is a record with validation errors.
285
+
:omit_columns | `Array`/`Hash`/`Proc` | `nil` | Array of columns to leave out of SQL statement, e.g `[:guid]`, or Hash of `{ Model => [:column_name] }` or a Proc `-> (model, column_names) { [:guid] }` returning columns to omit
286
+
: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
0 commit comments