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

Generalize reference targets for Table define utility methods #183

Merged
merged 8 commits into from
Oct 1, 2024

Conversation

karlcz
Copy link
Contributor

@karlcz karlcz commented Oct 1, 2024

Recently, a Table.define_association utility method was added, including a concept of reference targets to simplify the construction of columns and foreign key constraints. This PR generalizes the reference target concept so that other Table definition utilities can also supply reference targets instead of basic column and foreign key definitions.

… references

- add Table._expand_references() utility method
- refactor Table.define_association implementation
- generalize Table.define column_defs argument
- generalize Table.define_vocabulary column_defs argument
- generalize Table.define_asset column_defs argument
- generalize Table.define_page column_defs argument
- add Table.create_reference(target) method

The generalized methods all accept the target reference inputs
as understood by define_association when mixed into their column_defs
argument list. As with association metadata, these target references
are converted into corresponding Column.define() and ForeignKey.define()
results to add to the table definition.

The Table.create_reference(target) method allows incremental
expansion of one existing table with column(s) and a foreign key
referencing the designated target.
For the refactored internal use, we expect a mutable list instance.
If a non-list is supplied, copy it into a list so the utility works
reliably.
When provide_system=True AND provide_system_fkeys=True, it will
add the foreign keys from RCB and RMB to the ERMrest_Client table
@karlcz karlcz merged commit 67db3e3 into master Oct 1, 2024
@karlcz karlcz deleted the table_define_enhancements branch October 1, 2024 17:52
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.

1 participant