Fixed #22424 -- MySQL doesn't accept migrations' one-off default values ... #2634

Merged
merged 3 commits into from May 20, 2014

Conversation

Projects
None yet
5 participants
Member

loic commented May 5, 2014

...for longtext and longblob.

@timgraham timgraham and 1 other commented on an outdated diff May 13, 2014

django/db/backends/mysql/schema.py
@@ -29,3 +30,21 @@ def quote_value(self, value):
# Inner import to allow module to fail to load gracefully
import MySQLdb.converters
return MySQLdb.escape(value, MySQLdb.converters.conversions)
+
+ def skip_default(self, field):
+ if field.db_type(self.connection) in {'longtext', 'longblob'}:
@timgraham

timgraham May 13, 2014

Owner

return directly? (also a comment that says longtext/longblob don't support default would be helpful just for clarity)

@loic

loic May 13, 2014

Member

Why simple when we can do complicated? :P Fixed.

@timgraham timgraham and 1 other commented on an outdated diff May 13, 2014

tests/migrations/test_operations.py
@@ -312,6 +312,39 @@ def test_add_field(self):
operation.database_backwards("test_adfl", editor, new_state, project_state)
self.assertColumnNotExists("test_adfl_pony", "height")
+ @unittest.skipUnless(connection.vendor == 'mysql', "MySQL-specific behaviors")
@timgraham

timgraham May 13, 2014

Owner

While yes the field types are specific to MySQL, I'd think there wouldn't be any harm in running it on all DB backends?

@loic

loic May 13, 2014

Member

Good call, removing it unveiled a regression caused by e9a456d.

@rbarrois @loic rbarrois Fixed #22626 -- Allow BinaryField defaults with SQlite.
Also fixes a slight issue in sqlite3.schema._remake_table where
default values where quoted with "column name" quoting rules.

Reference for quoting: http://www.sqlite.org/lang_expr.html

Thanks Shai Berger for the review. Refs #22424.
6aacb4c

wouldn't this change make every use of quote_value (even for values) break with " in text? I thought they were escaped by MYSQLdb.escape..

@andrewgodwin andrewgodwin added a commit that referenced this pull request May 20, 2014

@andrewgodwin andrewgodwin Merge pull request #2634 from loic/ticket22424
Fixed #22424 -- MySQL doesn't accept migrations' one-off default values ...
4e32e47

@andrewgodwin andrewgodwin merged commit 4e32e47 into django:master May 20, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment