Skip to content

Commit 7206b25

Browse files
committed
BUG19179711: Fix using '%s' in django backend
Currently it is not possible to escape '%s' in queries so, '%s' is changed to '%S' which produces the same result for both date and time formatting.
1 parent 902ad1c commit 7206b25

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/mysql/connector/django/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def date_trunc_sql(self, lookup_type, field_name):
283283
The field_name is returned when lookup_type is not supported.
284284
"""
285285
fields = ['year', 'month', 'day', 'hour', 'minute', 'second']
286-
format = ('%Y-', '%m', '-%d', ' %H:', '%i', ':%s')
286+
format = ('%Y-', '%m', '-%d', ' %H:', '%i', ':%S')
287287
format_def = ('0000-', '01', '-01', ' 00:', '00', ':00')
288288
try:
289289
i = fields.index(lookup_type) + 1
@@ -323,7 +323,7 @@ def datetime_trunc_sql(self, lookup_type, field_name, tzname):
323323
else:
324324
params = []
325325
fields = ['year', 'month', 'day', 'hour', 'minute', 'second']
326-
format_ = ('%Y-', '%m', '-%d', ' %H:', '%i', ':%s')
326+
format_ = ('%Y-', '%m', '-%d', ' %H:', '%i', ':%S')
327327
format_def = ('0000-', '01', '-01', ' 00:', '00', ':00')
328328
try:
329329
i = fields.index(lookup_type) + 1

0 commit comments

Comments
 (0)