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

Add extra 'citext' to add support for CIText and CIText arrays on PostgreSQL database #125

Merged
merged 4 commits into from
Feb 8, 2021

Conversation

mzpqnxow
Copy link
Contributor

After entering #124, I took a quick look at this and saw that it was pretty trivial to add. I added it as an optional / extra so it can be installed using pip install sqlacodegen[citext] without impacting users that don't want or need it

Is this something you'll take upstream?

Thanks!

@coveralls
Copy link

coveralls commented Oct 10, 2020

Coverage Status

Coverage increased (+0.06%) to 91.731% when pulling d2881dc on mzpqnxow:feature-citext into 8c0b3e1 on agronholm:master.

@agronholm
Copy link
Owner

This should be mentioned in the docs or otherwise people won't know about the extra.

@mzpqnxow
Copy link
Contributor Author

mzpqnxow commented Feb 7, 2021

@agronholm good point, thank you. I went ahead and added it

# Support CIText and CIText[] in PostgreSQL via sqlalchemy-citext
try:
from citext import CIText # noqa: F401
except (NameError, ImportError):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved to after the Geoalchemy2 import.

Under what circumstances can this raise NameError?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, that was supposed to be ModuleNotFoundError not NameError. Though I realize now that's overly specific and will fail on Python2 anyway as it doesn't have ModuleNotFoundError- which is a subclass of ImportError. Will remove that and commit, nice catch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(fixing the order as well)

@@ -19,6 +19,12 @@
from sqlalchemy.types import Boolean, String
from sqlalchemy.util import OrderedDict

# Support CIText and CIText[] in PostgreSQL via sqlalchemy-citext
try:
from citext import CIText # noqa: F401
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not enough to import the module?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be no different since it's not directly used. I'll change that to only import the module

- No need to import the CIText class, the module will do
- Changed import order of citext per @agronholm
@mzpqnxow
Copy link
Contributor Author

mzpqnxow commented Feb 8, 2021

Pushed those changes up. Sorry 'bout that, especially the one that would have broken Python2 (!!!)

@agronholm agronholm merged commit 3e5c976 into agronholm:master Feb 8, 2021
@agronholm
Copy link
Owner

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