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

Fix unicode issue with SORTKEY on python 2 #34

Merged
merged 1 commit into from Sep 1, 2015

Conversation

@bouk
Copy link
Contributor

@bouk bouk commented Sep 1, 2015

This is to make sure unicode is supported in python2

@graingert

@graingert
graingert reviewed Sep 1, 2015
View changes
tests/test_ddl_compiler.py Outdated
MetaData(),
Column('id', Integer, primary_key=True),
Column('name', String),
redshift_sortkey=unicode("id"))

This comment has been minimized.

@graingert

graingert Sep 1, 2015
Collaborator

You can use u'id' and this will work on both

This comment has been minimized.

@bouk

bouk Sep 1, 2015
Author Contributor

fixed

This comment has been minimized.

@jklukas

jklukas Sep 1, 2015
Collaborator

The lint test runs on python 3 and throws an error for this unicode.

@jklukas
jklukas reviewed Sep 1, 2015
View changes
tests/test_ddl_compiler.py Outdated
@@ -131,6 +132,25 @@ def test_create_table_with_sortkey(self, compiler):
)
assert expected == actual, self._compare_strings(expected, actual)

@pytest.mark.skipif(sys.version_info[0] != 2, reason="only applicable to python 2")

This comment has been minimized.

@jklukas

jklukas Sep 1, 2015
Collaborator

Line too long here.

@bouk bouk force-pushed the bouk:check-unicode branch Sep 1, 2015
@jklukas
Copy link
Collaborator

@jklukas jklukas commented Sep 1, 2015

+1

@graingert
graingert reviewed Sep 1, 2015
View changes
redshift_sqlalchemy/dialect.py Outdated
@@ -11,6 +11,7 @@
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.sql.expression import Executable, ClauseElement
from sqlalchemy.types import VARCHAR, NullType
from sqlalchemy.util.compat import string_types

This comment has been minimized.

@graingert

graingert Sep 1, 2015
Collaborator

When was this added to sqlalchemy? Is it considered public?

This comment has been minimized.

@bouk

bouk Sep 1, 2015
Author Contributor

hmm looking at it it's definitely not public. What would be the best way to go about this? If I were to copy over the code, the linter would complain about unicode or basestring

This comment has been minimized.

@graingert

graingert Sep 1, 2015
Collaborator

What about a compat.py with a # noqa line?

@bouk bouk force-pushed the bouk:check-unicode branch 3 times, most recently Sep 1, 2015
@bouk
Copy link
Contributor Author

@bouk bouk commented Sep 1, 2015

@graingert how's this look?

@graingert
graingert reviewed Sep 1, 2015
View changes
redshift_sqlalchemy/compat.py Outdated
if py3k:
string_types = str,
else:
string_types = basestring,

This comment has been minimized.

@graingert

graingert Sep 1, 2015
Collaborator

I prefer parenthesis with my tuples

This comment has been minimized.

@graingert

graingert Sep 1, 2015
Collaborator

can you move the noqa to this line?

This comment has been minimized.

@bouk

bouk Sep 1, 2015
Author Contributor

Me too, I just copied the sa style. fixed

@bouk bouk force-pushed the bouk:check-unicode branch Sep 1, 2015
@graingert
Copy link
Collaborator

@graingert graingert commented Sep 1, 2015

Looks good to me, have a look at the fixes then update the issue name, changelog, squash etc

@bouk bouk force-pushed the bouk:check-unicode branch Sep 1, 2015
@bouk bouk changed the title Use sqlalchemy.util.string_types to check if it's a string Use a compatibility layer to check string types Sep 1, 2015
@bouk bouk changed the title Use a compatibility layer to check string types Fix unicode with SORTKEY on python 2 Sep 1, 2015
@bouk bouk changed the title Fix unicode with SORTKEY on python 2 Fix unicode issue with SORTKEY on python 2 Sep 1, 2015
@bouk bouk force-pushed the bouk:check-unicode branch to 55b0998 Sep 1, 2015
@bouk
Copy link
Contributor Author

@bouk bouk commented Sep 1, 2015

done

graingert added a commit that referenced this pull request Sep 1, 2015
Fix unicode issue with SORTKEY on python 2
@graingert graingert merged commit be53c70 into sqlalchemy-redshift:master Sep 1, 2015
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@bouk bouk deleted the bouk:check-unicode branch Sep 1, 2015
haleemur pushed a commit to haleemur/redshift_sqlalchemy that referenced this pull request Sep 2, 2015
Fix unicode issue with SORTKEY on python 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.