Sha256: 9a1eed63f0081cb0a7f5bda093949d3eb8faee0e116321fcbff52826dcb1ab31
Contents?: true
Size: 974 Bytes
Versions: 2
Compression:
Stored size: 974 Bytes
Contents
RSpec.describe 'Eager loading' do include_context 'users and tasks' with_adapters do before do conf.relation(:users) do def by_name(name) where(name: name) end end conf.relation(:tasks) do def for_users(users) where(user_id: users.map { |tuple| tuple[:id] }) end end conf.relation(:tags) do def for_tasks(tasks) inner_join(:task_tags, task_id: :id) .where(task_id: tasks.map { |tuple| tuple[:id] }) end end end it 'issues 3 queries for 3.graphd relations' do users = container.relation(:users).by_name('Piotr') tasks = container.relation(:tasks) tags = container.relation(:tags) relation = users.graph(tasks.for_users.graph(tags.for_tasks)) # TODO: figure out a way to assert correct number of issued queries expect(relation.call).to be_instance_of(ROM::Relation::Loaded) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rom-sql-1.3.5 | spec/integration/graph_spec.rb |
rom-sql-1.3.4 | spec/integration/graph_spec.rb |