spec/support/helpers.rb in rom-sql-1.3.5 vs spec/support/helpers.rb in rom-sql-2.0.0.beta1

- old
+ new

@@ -1,21 +1,24 @@ module Helpers - def qualified_attribute(*args) - ROM::SQL::QualifiedAttribute[*args] - end - def assoc_name(*args) - ROM::SQL::Association::Name[*args] + ROM::Relation::Name[*args] end - def define_schema(name, attrs) + def define_schema(name, attrs = []) + relation_name = ROM::Relation::Name.new(name) ROM::SQL::Schema.define( - name, - attributes: attrs.map { |key, value| value.meta(name: key, source: ROM::Relation::Name.new(name)) }, + relation_name, + attributes: attrs.map { |key, value| value.meta(name: key, source: relation_name) }, attr_class: ROM::SQL::Attribute ) end def define_type(name, id, **opts) ROM::SQL::Attribute.new(ROM::Types.const_get(id).meta(name: name, **opts)) + end + + def build_assoc(type, *args) + klass = Dry::Core::Inflector.classify(type) + definition = ROM::Associations::Definitions.const_get(klass).new(*args) + ROM::SQL::Associations.const_get(definition.type).new(definition, relations) end end