Suggestion: distinguish ambiguous column value of `None`
heehehe opened this issue · 0 comments
heehehe commented
We found there are three cases of getting None
for column value.
- When the user set the column value as
"NULL"
.
python-mysql-replication/pymysqlreplication/row_event.py
Lines 158 to 159 in 8e17fb2
- When the datatype is related to date(
DATETIME
,TIME
, ...) and the value's format is not supportable.
python-mysql-replication/pymysqlreplication/row_event.py
Lines 382 to 394 in 8e17fb2
- When the datatype is
SET
and the value is empty
python-mysql-replication/pymysqlreplication/row_event.py
Lines 246 to 257 in 8e17fb2
Since these values have the same value in python-mysql-replication as None
, users cannot distinguish these cases.
Is it fine to distinguish these cases when dump()
is executed like below?
CREATE TABLE test_table (col0 int, col1 varchar(10), col2 datetime);
INSERT INTO test_table VALUES (1, 'abc', '2023-09-09 00:00:00');
UPDATE test_table SET col1=NULL, col2='0000-00-00 00:00:00' WHERE col0=1;
# dump result for UPDATE
=== UpdateRowsEvent ===
Date: 2023-09-09T05:23:14
Log position: 1360
Event size: 37
Read bytes: 13
Table: test.test_table
Affected columns: 3
Changed rows: 1
Affected columns: 3
Values:
--
*col0:1=>1
*col1:abc=>None(null)
*col2:2023-09-09 00:00:00=>None(out of datetime range)
Here's a draft of our work : python-mysql-replication-kr#86
I'd appreciate for your feedback :)