julien-duponchelle / julien-duponchelle/python-mysql-replication
field type timestamp default '0000-00-00 00:00:00' parse to sql can't import to mysql server
- Dominant language
- Python
- Stars
- 2.4k
- Forks
- 690
- PR merge metrics
- No merged PRs in 30d
Description
field type timestamp default '0000-00-00 00:00:00', when field value is '0000-00-00 00:00:00', python-mysql-replication parse the field value to '1970-01-01 08:00:00' which can't import to mysql server with a error:
1292, "Incorrect datetime value: '1970-01-01 08:00:00' for column 'promotion_begintime' at row 1"
source code:
elif column.type == FIELD_TYPE.TIMESTAMP2:
values[name] = self.__add_fsp_to_time(
datetime.datetime.fromtimestamp(
self.packet.read_int_be_by_size(4)), column)
datetime.datetime.fromtimestamp(0) will return '1970-01-01 08:00:00'
Contributor guide
Research direction
Start with the TIMESTAMP2 parsing branch shown in the issue and reproduce the zero timestamp case against a MySQL server. Trace how the four-byte value becomes a Python datetime, then verify that the zero timestamp is preserved in the parsed output and can be imported without the reported datetime error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, python
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100