from os import path
-__version__ = '0.8.2'
+__version__ = '0.8.3'
package_dir = path.abspath(path.dirname(__file__))
not isinstance(inspector_column.type, Numeric):
# don't single quote if the column type is float/numeric,
# otherwise a comparison such as SELECT 5 = '5.0' will fail
- rendered_metadata_default = "'%s'" % rendered_metadata_default
+ rendered_metadata_default = re.sub(
+ r"^u?'?|'?$", "'", rendered_metadata_default)
return not self.connection.scalar(
"SELECT %s = %s" % (
Changelog
==========
+.. changelog::
+ :version: 0.8.3
+
+ .. change::
+ :tags: bug, autogenerate, postgresql
+ :tickets: 324
+
+ Fixed issue in PG server default comparison where model-side defaults
+ configured with Python unicode literals would leak the "u" character
+ from a ``repr()`` into the SQL used for comparison, creating an invalid
+ SQL expression, as the server-side comparison feature in PG currently
+ repurposes the autogenerate Python rendering feature to get a quoted
+ version of a plain string default.
+
+
.. changelog::
:version: 0.8.2
:released: August 25, 2015
diff_expected=False
)
+ def test_compare_unicode_literal(self):
+ self._compare_default_roundtrip(
+ String(),
+ u'im a default'
+ )
+
+ # TOOD: will need to actually eval() the repr() and
+ # spend more effort figuring out exactly the kind of expression
+ # to use
+ def _TODO_test_compare_character_str_w_singlequote(self):
+ self._compare_default_roundtrip(
+ String(),
+ "hel''lo",
+ )
+
def test_compare_character_str(self):
self._compare_default_roundtrip(
String(),