Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow define foreign key relationships in config file #1282

Conversation

chrisngyn
Copy link

What?

I've added support for define relationships in config file. This would allow you to use sqlboiler with platform that does not support foreign keys.
For more background, see #1163

Proposal configs

Here is an example config will be added to config file.

#...
[foreign_keys.jet_pilots_fkey]
table = "jets"
column = "pilot_id"
foreign_table = "pilots"
foreign_column = "id"

[foreign_keys.pilot_language_pilots_fkey]
table = "pilot_languages"
column = "pilot_id"
foreign_table = "pilots"
foreign_column = "id"

[foreign_keys.pilot_language_languages_fkey]
table = "pilot_languages"
column = "language_id"
foreign_table = "languages"
foreign_column = "id"
#...

@stephenafamo
Copy link
Collaborator

Sorry, this is a fairly big change and I haven't had time to review it properly. I will try to find some time over the next few weeks

@chrisngyn
Copy link
Author

I know, the main reason make this PR so big because I've changed drivers.Config from map[string]interface{} to struct. I think that will make the Config be more explicit.
And the interface function will be more shorter.

func TablesConcurrently(c Constructor, config Config) ([]Table, error)

instead of

func TablesConcurrently(c Constructor, schema string, whitelist, blacklist []string, concurrency int, foreignKeys []drivers.ForeignKey) ([]Table, error)

If I'm missing anything or you need me update this PR, feel free to tell me.

@stephenafamo
Copy link
Collaborator

I've changed drivers.Config from map[string]interface{} to struct

The thing is since drivers.Config is exported, this would become a "breaking change" and should only then be included in v5.

I would suggest you undo that for now. While it looks clumsy, it is the price of maintaining backward compatibility.

@chrisngyn chrisngyn force-pushed the feature/define-relationships-in-config branch from 888b109 to 1fbc1c1 Compare July 22, 2023 05:39
@chrisngyn
Copy link
Author

chrisngyn commented Jul 22, 2023

I would suggest you undo that for now

I've already undone that

@stephenafamo stephenafamo merged commit 78d521d into volatiletech:master Jul 23, 2023
@chrisngyn chrisngyn deleted the feature/define-relationships-in-config branch July 24, 2023 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants