Closed uranusjr closed 9 years ago
Oops I missed some cases when param
is used. Will fix it and update this later.
OK, tests should pass now. My initial intentions of making Query
still return a byte string does not work with subqueries, so now MoSQL returns unicode
always. Not sure if that’s acceptable though.
Tests totally does not pass on Python 3 mainly because there are tons of print
statements in the docs; I’m now using a custom build to test my changes (they pass), but the diff is so extensive it needs another PR. Or you can just use sed
yourself to make the changes. There are a couple of cases that require manual editing, but it won’t take more than 5 minutes.
But that still won’t make tests pass. Python 3’s dict ordering is different from Python 2’s, so things like
insert('person', {'person_id': 'mosky', 'name': 'Mosky Liu'})
generates different outputs on Python 2
INSERT INTO "person" ("person_id", "name") VALUES ('mosky', 'Mosky Liu')
and Python 3
INSERT INTO "person" ("name", "person_id") VALUES ('Mosky Liu', 'mosky')
So I guess it’s not feasible to run tests on Python 3. But the code itself now should work on both Python 2 and 3.
Closed in favour of #40
sorry for missing this PR ... XD
This makes all internals in
util
useunicode
instead of byte strings, so that everything works on both Python 2 and 3. Since theStatement
object encodes strings informat
, the outputs stay as byte strings, maintaining backward compatibility.I would probably recommend using
from __future__ import unicode_literals
in all modules using literals so that things are less likely to break in the future. It’s not necessary now though.I also added a feature detection in
db
so that tests can run on Python 3 (which does not haveizip
).