rom-sql icon indicating copy to clipboard operation
rom-sql copied to clipboard

Missing fk-constraint does not map properly for combines

Open chevinbrown opened this issue 6 years ago • 0 comments

Describe the bug

Given a standard one-to-many relationship Posts and Comments, where comments table has a post_id without a foreign-key constraint, the usage of combine will map every relationship to the primary node.

To Reproduce

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

rom.relations[:posts].combine(:comments)

Expected behavior Unsure, but warnings/documentation could help.

  1. Perhaps, warn/error when missing fk?
  2. Require "virtual_foreign_key"?

Your environment

  • Affects my production application: NO
  • Ruby version: 2.6.x, rails 5.2
  • OS: Catalina

chevinbrown avatar Jan 06 '20 15:01 chevinbrown