mirror of https://github.com/django/django.git
Fixed #26140 -- Suppressed MySQL warning when inserting binary content
Thanks Tim Graham for the review.
This commit is contained in:
parent
cacc7e85e1
commit
204e00c0c5
|
@ -578,6 +578,13 @@ class BaseDatabaseOperations(object):
|
|||
def combine_duration_expression(self, connector, sub_expressions):
|
||||
return self.combine_expression(connector, sub_expressions)
|
||||
|
||||
def binary_placeholder_sql(self, value):
|
||||
"""
|
||||
Some backends require special syntax to insert binary content (MySQL
|
||||
for example uses '_binary %s').
|
||||
"""
|
||||
return '%s'
|
||||
|
||||
def modify_insert_params(self, placeholder, params):
|
||||
"""Allow modification of insert parameters. Needed for Oracle Spatial
|
||||
backend due to #10888.
|
||||
|
|
|
@ -212,6 +212,9 @@ class DatabaseOperations(BaseDatabaseOperations):
|
|||
value = uuid.UUID(value)
|
||||
return value
|
||||
|
||||
def binary_placeholder_sql(self, value):
|
||||
return '_binary %s' if value is not None else '%s'
|
||||
|
||||
def subtract_temporals(self, internal_type, lhs, rhs):
|
||||
lhs_sql, lhs_params = lhs
|
||||
rhs_sql, rhs_params = rhs
|
||||
|
|
|
@ -2371,6 +2371,9 @@ class BinaryField(Field):
|
|||
def get_internal_type(self):
|
||||
return "BinaryField"
|
||||
|
||||
def get_placeholder(self, value, compiler, connection):
|
||||
return connection.ops.binary_placeholder_sql(value)
|
||||
|
||||
def get_default(self):
|
||||
if self.has_default() and not callable(self.default):
|
||||
return self.default
|
||||
|
|
Loading…
Reference in New Issue