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

raise an error when no columns are found #1676

Merged
merged 2 commits into from
Jun 3, 2016

Conversation

maxcountryman
Copy link
Contributor

No description provided.

The method `create_table` uses the length of the first element of the `columns` property to determine how column names are formatted. Unfortunately this is not exhaustive case coverage. For instance, if a `columns` property is formatted improperly, `create_table` can fail silently, matching neither the first nor the second if clause. In such cases we should alert the user that something has gone awry.

To remedy this, here we raise a `ValueError` when neither if clause is met. This both alerts the user to the cause of the problem and halts the application from making erroneous and incorrect progress. If we prefer to make the `CREATE` query optional, we could instead log an error to stderr, however it seems unlikely that we would ever wish to not create our tables.
@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @dlstadther, @ddaniels888 and @steenzout to be potential reviewers

@dlstadther
Copy link
Collaborator

By default rdbms.py sets columns = [] so your conditional addition should catch when the user does not override this variable.

lgtm

@dlstadther
Copy link
Collaborator

@Tarrasch Any reason not to merge this?

@Tarrasch
Copy link
Contributor

Isn't all the tests failing due to indentation error?

@dlstadther
Copy link
Collaborator

Ah, yes. The else block appears to line up with the method declaration. @maxcountryman , you'll need to indent your additions to line up with rest of the conditional.

@Tarrasch
Copy link
Contributor

That also raises the question of how much this was tested (if at all).

@maxcountryman, can you also add a motivation to this patch? What real world use case scenario does it solve for you?

@maxcountryman
Copy link
Contributor Author

@Tarrasch did you read the commit message...?

@Tarrasch
Copy link
Contributor

@maxcountryman I did not, sorry! Thanks, it explains it well. I'm too used to GitHub copying it into the PR description. :)

@dlstadther
Copy link
Collaborator

Ready to merge?

@Tarrasch Tarrasch merged commit 71bb115 into spotify:master Jun 3, 2016
This was referenced Jun 29, 2022
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.

4 participants