rom-rb / rom

Data mapping and persistence toolkit for Ruby
https://rom-rb.org
MIT License
2.08k stars 161 forks source link

Changeset `:create` command with aliased PK #490

Closed joelvh closed 6 years ago

joelvh commented 6 years ago

I've created a relation where the id is aliased to event_id. When I try to create new records by committing the changeset with data that has an event_id value pre-populated, the value is not persisted to the id column (get a SQL null violation exception).

      class Events < ::ROM::Relation[:sql]
        schema(:event_store_events, as: :events, infer: true) do
          attribute :id, ::ROM::Types::String.meta(alias: :event_id)

          primary_key :id
        end
      end

Is it not the expectation that the changeset commands will write to the original attribute name (SQL column)?

Thanks.

joelvh commented 6 years ago

Posted to Discourse: https://discourse.rom-rb.org/t/changeset-create-command-with-aliased-pk-doesnt-seem-to-map-back-to-database-column/225/1