Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Remove old TIMESTAMP format for MySQL<4.1 #308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 MySQLdb/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def quote_tuple(t, d):
FIELD_TYPE.LONGLONG: int,
FIELD_TYPE.INT24: int,
FIELD_TYPE.YEAR: int,
FIELD_TYPE.TIMESTAMP: mysql_timestamp_converter,
FIELD_TYPE.TIMESTAMP: DateTime_or_None,
FIELD_TYPE.DATETIME: DateTime_or_None,
FIELD_TYPE.TIME: TimeDelta_or_None,
FIELD_TYPE.DATE: Date_or_None,
Expand Down
14 changes: 0 additions & 14 deletions 14 MySQLdb/times.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,3 @@ def DateTime2literal(d, c):
def DateTimeDelta2literal(d, c):
"""Format a DateTimeDelta object as a time."""
return string_literal(format_TIMEDELTA(d))

def mysql_timestamp_converter(s):
"""Convert a MySQL TIMESTAMP to a Timestamp object."""
# MySQL>4.1 returns TIMESTAMP in the same format as DATETIME
if s[4] == '-': return DateTime_or_None(s)
s = s + "0"*(14-len(s)) # padding
parts = map(int, filter(None, (s[:4],s[4:6],s[6:8],
s[8:10],s[10:12],s[12:14])))
try:
return Timestamp(*parts)
except (SystemExit, KeyboardInterrupt):
raise # pragma: no cover
except:
return None
12 changes: 0 additions & 12 deletions 12 tests/test_MySQLdb_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,6 @@ def test_timestamp_from_ticks(self, mock):
assert times.TimestampFromTicks(1430000000.123) == datetime(2015, 4, 25, 22, 13, 20)


class TestTimestampConverter(unittest.TestCase):
def test_mysql_timestamp_converter(self):
assert times.mysql_timestamp_converter('2015-12-13') == date(2015, 12, 13)
assert times.mysql_timestamp_converter('2038-01-19 03:14:07') == datetime(2038, 1, 19, 3, 14, 7)

assert times.mysql_timestamp_converter('2015121310') == datetime(2015, 12, 13, 10, 0)
assert times.mysql_timestamp_converter('20151213101112') == datetime(2015, 12, 13, 10, 11, 12)

assert times.mysql_timestamp_converter('20151313') is None
assert times.mysql_timestamp_converter('2015-13-13') is None


class TestToLiteral(unittest.TestCase):
def test_datetime_to_literal(self):
assert times.DateTime2literal(datetime(2015, 12, 13), '') == b"'2015-12-13 00:00:00'"
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.