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

"Silently drop tables with no PKs rather than failing (bad idea??)" #1

Open
JordanReiter opened this issue Apr 10, 2018 · 3 comments
Open

Comments

@JordanReiter
Copy link

JordanReiter commented Apr 10, 2018

I'd like to put in a vote that says this is a terrible idea. I think a good use case for this library will be making data from an older, legacy database available. Bookrest should definitely not alter the schema of databases in any way.

Specifically excluding rather than altering databases without PKs is a much better idea.

In fact, I think you should add configuration variables that let you either exclude or specifically whitelist tables to expose to the API.

Logic would be:

tables = self.get_tables()
if hasattr(settings, 'BOOKREST_TABLES'):
    tables = [table for table in tables if table in settings.BOOKREST_TABLES]
elif hasattr(settings, 'BOOKREST_EXCLUDE'):
    tables = [table for table in tables if table not in settings.BOOKREST_EXCLUDE]
tables = [table for table in tables if has_primary_key(table)] # exercise for reader
return [self.get_model(table.name) for table in tables]
@ztroop
Copy link

ztroop commented Apr 10, 2018

I agree with @JordanReiter completely! The module should not alter the schema in any way.
It would be more ideal to include or exclude certain tables from the API.

@shabda
Copy link
Member

shabda commented Apr 11, 2018

haha, I think I need to get better at expressing my ideas. I am not thinking about dropping the table! That would be crazy. :)

I am thinking disregarding them like @JordanReiter write the code for (aka dropping from Bookrest UI). If you open a PR, I will merge it.

@shabda
Copy link
Member

shabda commented Apr 11, 2018

I have updated the readme to Silently drop disregard tables with no PKs

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

No branches or pull requests

3 participants