Changeset `:create` command with aliased PK doesn't seem to map back to database column

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.

Hey Joel!

There’s no auto-mapping in the changesets, so at the moment you’d have to define mapping manually. For simple attr-aliasing we could introduce a changeset plugin that could infer the mapping from schemas. Changeset plugins, in general, are scheduled for rom 5.0.0.

Hi @solnic! Thanks for the clarification. I would have assumed that the schema would manage the mapping for the changeset.

I have made many observations about the changeset functionality and look forward to seeing where it goes to improve things.