We should be using schemas as the source of information about dataset names, relation aliases and attributes, because this type of consistency is simpler and we'll reduce the risk of having weird bugs. This is how it works already to some extent, but we're not 100% there yet.
With rom 4.0 we should remove register_as and dataset settings from relation's ClassInterface because it's redundant. Schemas should be responsible for building relation name objects (which means they will include dataset name, relation name and have the ability to alias relations at runtime too).
In code this means:
module Relations
class Users < ROM::Relation[:sql]
# this must go away
register_as :users
dataset :people
# in favor of this (which is already implemented)
schema(:people, as: :users, infer: true)
end
end
TODO
[x] rename dataset do .. end to something...else :) alternatively leave it
[x] deprecate register_as and dataset (without a block) in release-3.0 branch
[x] remove register_as and dataset in master
[x] tweak Schema so that its name is no longer a plain symbol but a Relation::Name instance
[x] replace all references to these settings throughout the codebase (ie relation_class.register_as => relation_class.schema.name.relation, relation_class.dataset => relation_class.schema.name.dataset)
We should be using schemas as the source of information about dataset names, relation aliases and attributes, because this type of consistency is simpler and we'll reduce the risk of having weird bugs. This is how it works already to some extent, but we're not 100% there yet.
With rom 4.0 we should remove
register_as
anddataset
settings from relation'sClassInterface
because it's redundant. Schemas should be responsible for building relation name objects (which means they will include dataset name, relation name and have the ability to alias relations at runtime too).In code this means:
TODO
dataset do .. end
to something...else :) alternatively leave itregister_as
anddataset
(without a block) in release-3.0 branchregister_as
anddataset
in masterSchema
so that its name is no longer a plain symbol but aRelation::Name
instancerelation_class.register_as
=>relation_class.schema.name.relation
,relation_class.dataset
=>relation_class.schema.name.dataset
)