julien-duponchelle / julien-duponchelle/python-mysql-replication
datetime '0000-00-00' return string '0000-00-00'
- Dominant language
- Python
- Stars
- 2.4k
- Forks
- 690
- PR merge metrics
- No merged PRs in 30d
Description
'0000-00-00 00:00:00' is a invalid datetime but it can be inserted in `datetime` column type. If I have `f_time datetime NOT NULL` defined, the parsed value in row event is set to `None`: `row_event.py: __read_datetime2()`
Then I use all column values to insert/update, that `None` value would lead to no data matched, or insert a null value to `NOT NULL` columns(error occurs).
We all know datetime '0000-00-00' is nasty but when it already exists, we shall keep the data consistent. It's nice if a parameter like `date_tostr` is given to `BinlogStreamReader` to decide the behavior.
I've implemented this, I will make a pull request later.
Contributor guide
Research direction
Start in row_event.py at __read_datetime2() and trace how BinlogStreamReader exposes column parsing options. Check how an existing '0000-00-00 00:00:00' value is currently converted, then verify that the proposed date_tostr behavior preserves the original value when requested without changing other datetime handling.
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
- 45/100