Skip to content

Error when attempting to join relations across different databases #417

@MasanoriOnishi

Description

@MasanoriOnishi

Describe the bug

We can't make the code for joining relations across different databases.

To Reproduce

Provide detailed steps to reproduce, an executable script would be best.

  1. setup the following code.
ROM.container(
  default: [:sql, 'mysql2://localhost/defalut'], # gateway 1 and has users table
  legacy: [:sql, 'mysql2://localhost/legacy']  # gateway 2 and has other_users table
) 
default_relation = rom.relations[:users]
other_relation = container.relations[:other_users]
  
p default_relation.join(other_relation, container.gateways[:default][:users][:id] => container.gateways[:legacy][:other_users][:default_id])
  1. Run the script
SELECT * FROM `users` INNER JOIN `other_users` on (`users`.`id` = `other_users`.`default_id`)

Expected behavior

We want to see the output

SELECT * FROM `default`.`users` INNER JOIN `legacy`.`other_users` on (`default`.`users`.`id` = `legacy`.`other_users`.`default_id`)

My environment

  • Affects my production application: YES
  • Ruby version: ...2.7.7
  • OS: Mac

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions