sqlboiler icon indicating copy to clipboard operation
sqlboiler copied to clipboard

Feature: Define relationships in config

Open nhuysamen-godaddy opened this issue 1 year ago • 4 comments

This is probably a non-starter, but it would be great (albeit probably error-prone), to be able to specify relationships in config rather than relying on foreign keys. This would allow you to use sqlboiler with platform like PlanetScale that does not support foreign keys.

nhuysamen-godaddy avatar Jul 23 '22 13:07 nhuysamen-godaddy

This sounds interesting. If you can create a PR for this feature, I'll be happy to review it.

stephenafamo avatar Jul 24 '22 21:07 stephenafamo

I was just about to use SQLBoiler with PlanetScale! I had no choice but to try to use it without foreign key constraints (no relations). This is a long awaited feature!

tanaka-takuto avatar Aug 06 '22 00:08 tanaka-takuto

imo this would be a nice feature in dbs with foreign keys as well, as afaict the reverse relationship is auto-derived, and cannot be renamed through a toml config, because the foreign key only exists on one of the tables

Rosswell avatar Aug 17 '22 20:08 Rosswell

@Rosswell I believe it is possible to alias the reverse relationship using the foreign property.

Regardless, I agree that the ability to manually define relationships would be quite useful. If only to create some "convenient" relationships that you don't necessarily need to be enforced by the DB.

stephenafamo avatar Aug 19 '22 09:08 stephenafamo

@stephenafamo Could you review this PR above?

chrisngyn avatar Jun 12 '23 04:06 chrisngyn

Would love to see this as well. Not being able to add non-FK columns to a join table is another limitation this would help to remove.

adsteel avatar Jul 19 '23 18:07 adsteel

Implemented in #1282

stephenafamo avatar Jul 23 '23 18:07 stephenafamo