Error when attempting to join relations across different databases

Aperta
#417 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
mysql, ruby, sql
Ambito
databases

Direzione di ricerca

Start by reproducing the ROM.container setup with the two MySQL gateways and the cross-relation join shown in the issue. Trace the join entry point and SQL generation until you can identify where gateway or database qualification is lost; done means the generated SQL qualifies users with default and other_users with legacy as shown.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug help wanted

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
Lingua principale
Ruby
Stelle
220
Fork
97
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rom-rb/rom-sql

Tutte le issue di rom-rb/rom-sql

Issue simili

Altre issue su Ruby

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.