rom-rb / rom-factory

Data generator with support for persistence backends
MIT License
83 stars 42 forks source link

Fix TupleEvaluator#struct_attrs for non-standard output schema #51

Closed AMHOL closed 4 years ago

AMHOL commented 4 years ago

Prior to this, using a non-standard output schema that doesn't reject keys that are not present in the schema (as in rom-http), and with no PK defined on the schema, the TupleEvaluator#struct_attrs method would try to add a sequence value under the PK name, as #primary_key evaluated to nil, the attribute added looked like "nil=>{n}", and the following error would occur (with rom-http output schema):

NoMethodError:
 undefined method `to_sym' for nil:NilClass

The attribute was added in all cases where no PK was present, but was only noticeable when the output schema didn't reject keys that weren't defined in the schema.