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

Handle invalid characters in table names #61

Merged
merged 2 commits into from
May 19, 2018

Conversation

danohu
Copy link
Contributor

@danohu danohu commented May 10, 2018

Fixes Issue #60

Also remove some unused duplicated code

Fixes Issue agronholm#60

Also remove some unused duplicated code
@coveralls
Copy link

coveralls commented May 10, 2018

Coverage Status

Coverage increased (+0.8%) to 90.83% when pulling 88a5ff9 on danohuiginn:invalid_table_name into 9667827 on agronholm:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.8%) to 90.83% when pulling 28571d1 on danohuiginn:invalid_table_name into 9667827 on agronholm:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.8%) to 90.83% when pulling 28571d1 on danohuiginn:invalid_table_name into 9667827 on agronholm:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.8%) to 90.83% when pulling 28571d1 on danohuiginn:invalid_table_name into 9667827 on agronholm:master.

@agronholm
Copy link
Owner

It's not obvious to me how this fixes anything.

@danohu
Copy link
Contributor Author

danohu commented May 14, 2018

hi @agronholm

so, you have a table called 'simple-items', as in the test case. Because there is no sanitization of table names, this will generate python code like:

class Simple-item(Base):

But you can't have a hyphen in a classname; it's interpreted as a minus sign, so you'll get a SyntaxError when importing the generated code. I assume (but haven't checked) that you'd get similar problems with other non-alphanumeric characters that are valid as db table names but have special meanings in python.

So I've passed table names through the existing sanitization routine, that converts non-alphanumeric characters into underscores.

@agronholm agronholm merged commit 2629556 into agronholm:master May 19, 2018
@agronholm
Copy link
Owner

I see it now. Thanks!

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.

None yet

3 participants