Skip to content

Commit

Permalink
Fixed #26966 -- Made MySQL backend skip defaults for JSON columns
Browse files Browse the repository at this point in the history
Thanks mcgeeco for reporting, and claudep and timgraham for review.
  • Loading branch information
adamchainz authored and timgraham committed Aug 1, 2016
1 parent 374b609 commit 4b1c970
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions django/db/backends/mysql/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ def quote_value(self, value):

def skip_default(self, field):
"""
MySQL doesn't accept default values for TEXT and BLOB types, and
implicitly treats these columns as nullable.
MySQL doesn't accept default values for some data types and implicitly
treats these columns as nullable.
"""
db_type = field.db_type(self.connection)
return (
db_type is not None and
db_type.lower() in {
'tinyblob', 'blob', 'mediumblob', 'longblob',
'tinytext', 'text', 'mediumtext', 'longtext',
'json',
}
)

Expand Down

0 comments on commit 4b1c970

Please sign in to comment.