99from .constants import FIELD_TYPE
1010from .constants import BINLOG
1111from .constants import CHARSET
12+ from .constants import NONE_SOURCE
1213from .column import Column
1314from .table import Table
1415from .bitmap import BitCount , BitGet
@@ -135,11 +136,11 @@ def __read_values_name(
135136 if BitGet (cols_bitmap , i ) == 0 :
136137 # This block is only executed when binlog_row_image = MINIMAL.
137138 # When binlog_row_image = FULL, this block does not execute.
138- self .__none_sources [name ] = "cols_bitmap"
139+ self .__none_sources [name ] = NONE_SOURCE . COLS_BITMAP
139140 return None
140141
141142 if self ._is_null (null_bitmap , null_bitmap_index ):
142- self .__none_sources [name ] = "null"
143+ self .__none_sources [name ] = NONE_SOURCE . NULL
143144 return None
144145
145146 if column .type == FIELD_TYPE .TINY :
@@ -185,14 +186,14 @@ def __read_values_name(
185186 elif column .type == FIELD_TYPE .DATETIME :
186187 ret = self .__read_datetime ()
187188 if ret is None :
188- self .__none_sources [name ] = "out of datetime range"
189+ self .__none_sources [name ] = NONE_SOURCE . OUT_OF_DATETIME_RANGE
189190 return ret
190191 elif column .type == FIELD_TYPE .TIME :
191192 return self .__read_time ()
192193 elif column .type == FIELD_TYPE .DATE :
193194 ret = self .__read_date ()
194195 if ret is None :
195- self .__none_sources [name ] = "out of date range"
196+ self .__none_sources [name ] = NONE_SOURCE . OUT_OF_DATE_RANGE
196197 return ret
197198 elif column .type == FIELD_TYPE .TIMESTAMP :
198199 return datetime .datetime .utcfromtimestamp (self .packet .read_uint32 ())
@@ -201,7 +202,7 @@ def __read_values_name(
201202 elif column .type == FIELD_TYPE .DATETIME2 :
202203 ret = self .__read_datetime2 (column )
203204 if ret is None :
204- self .__none_sources [name ] = "out of datetime2 range"
205+ self .__none_sources [name ] = NONE_SOURCE . OUT_OF_DATETIME2_RANGE
205206 return ret
206207 elif column .type == FIELD_TYPE .TIME2 :
207208 return self .__read_time2 (column )
@@ -232,10 +233,10 @@ def __read_values_name(
232233 if bit_mask & (1 << idx )
233234 }
234235 if not ret :
235- self .__none_sources [column .name ] = "empty set"
236+ self .__none_sources [column .name ] = NONE_SOURCE . EMPTY_SET
236237 return None
237238 return ret
238- self .__none_sources [column .name ] = "empty set"
239+ self .__none_sources [column .name ] = NONE_SOURCE . EMPTY_SET
239240 return None
240241 elif column .type == FIELD_TYPE .BIT :
241242 return self .__read_bit (column )
@@ -244,7 +245,7 @@ def __read_values_name(
244245 elif column .type == FIELD_TYPE .JSON :
245246 return self .packet .read_binary_json (column .length_size )
246247 else :
247- raise NotImplementedError ("Unknown MySQL column type: %d" % ( column .type ) )
248+ raise NotImplementedError ("Unknown MySQL column type: %d" % column .type )
248249
249250 def __add_fsp_to_time (self , time , column ):
250251 """Read and add the fractional part of time
0 commit comments