@@ -207,13 +207,17 @@ def __read_values_name(
207
207
elif column .type == FIELD_TYPE .YEAR :
208
208
return self .packet .read_uint8 () + 1900
209
209
elif column .type == FIELD_TYPE .ENUM :
210
- self .packet .read_uint_by_size (column .size )
211
- # unsupported
212
- return None
210
+ return column .enum_values [self .packet .read_uint_by_size (column .size )]
213
211
elif column .type == FIELD_TYPE .SET :
214
- self .packet .read_uint_by_size (column .size )
215
- # unsupported
216
- return None
212
+ bit_mask = self .packet .read_uint_by_size (column .size )
213
+ return (
214
+ set (
215
+ val
216
+ for idx , val in enumerate (column .set_values )
217
+ if bit_mask & 2 ** idx
218
+ )
219
+ or None
220
+ )
217
221
elif column .type == FIELD_TYPE .BIT :
218
222
return self .__read_bit (column )
219
223
elif column .type == FIELD_TYPE .GEOMETRY :
@@ -463,6 +467,7 @@ def _dump(self):
463
467
"Column Name Information Flag: %s"
464
468
% self .table_map [self .table_id ].column_name_flag
465
469
)
470
+ print (self .table_map [self .table_id ].data )
466
471
467
472
def _fetch_rows (self ):
468
473
self .__rows = []
@@ -802,9 +807,6 @@ def _get_optional_meta_data(self):
802
807
return optional_metadata
803
808
804
809
def _sync_column_info (self ):
805
- column_schemas = []
806
- if len (self .optional_metadata .column_name_list ) == 0 :
807
- return
808
810
if not self .__optional_meta_data :
809
811
# If optional_meta_data is False Do not sync Event Time Column Schemas
810
812
return
@@ -815,43 +817,18 @@ def _sync_column_info(self):
815
817
set_pos = 0
816
818
817
819
for column_idx in range (self .column_count ):
818
- column_schema = {
819
- "COLUMN_NAME" : None ,
820
- "COLLATION_NAME" : None ,
821
- "CHARACTER_SET_NAME" : None ,
822
- "CHARACTER_OCTET_LENGTH" : None ,
823
- "DATA_TYPE" : None , # not sufficient data
824
- "COLUMN_COMMENT" : "" , # we don't know this Info from optional metadata info
825
- "COLUMN_TYPE" : None , # not sufficient data
826
- "COLUMN_KEY" : "" ,
827
- "ORDINAL_POSITION" : None ,
828
- }
829
820
column_type = self .columns [column_idx ].type
830
821
column_name = self .optional_metadata .column_name_list [column_idx ]
831
- data_type = self ._get_field_type_key (column_type )
832
822
column_data : Column = self .columns [column_idx ]
833
823
column_data .name = column_name
834
824
835
- column_schema ["COLUMN_NAME" ] = column_name
836
- column_schema ["ORDINAL_POSITION" ] = column_idx + 1
837
-
838
- if data_type is not None :
839
- data_type = data_type .lower ()
840
- column_schema ["DATA_TYPE" ] = data_type
841
-
842
- if "max_length" in column_data .data :
843
- max_length = column_data .max_length
844
- column_schema ["CHARACTER_OCTET_LENGTH" ] = str (max_length )
845
-
846
825
if self ._is_character_column (column_type , dbms = self .dbms ):
847
826
charset_id = self .optional_metadata .charset_collation_list [charset_pos ]
848
827
charset_pos += 1
849
828
850
829
encode_name , collation_name , charset_name = find_charset (
851
830
charset_id , dbms = self .dbms
852
831
)
853
- column_schema ["COLLATION_NAME" ] = collation_name
854
- column_schema ["CHARACTER_SET_NAME" ] = charset_name
855
832
856
833
self .columns [column_idx ].collation_name = collation_name
857
834
self .columns [column_idx ].character_set_name = encode_name
@@ -865,8 +842,6 @@ def _sync_column_info(self):
865
842
encode_name , collation_name , charset_name = find_charset (
866
843
charset_id , dbms = self .dbms
867
844
)
868
- column_schema ["COLLATION_NAME" ] = collation_name
869
- column_schema ["CHARACTER_SET_NAME" ] = charset_name
870
845
871
846
self .columns [column_idx ].collation_name = collation_name
872
847
self .columns [column_idx ].character_set_name = encode_name
@@ -875,17 +850,11 @@ def _sync_column_info(self):
875
850
enum_column_info = self .optional_metadata .set_enum_str_value_list [
876
851
enum_pos
877
852
]
878
- enum_values = "," .join (enum_column_info )
879
- enum_format = f"enum({ enum_values } )"
880
- column_schema ["COLUMN_TYPE" ] = enum_format
881
853
self .columns [column_idx ].enum_values = ["" ] + enum_column_info
882
854
enum_pos += 1
883
855
884
856
if self ._is_set_column (column_type ):
885
857
set_column_info = self .optional_metadata .set_str_value_list [set_pos ]
886
- set_values = "," .join (set_column_info )
887
- set_format = f"set({ set_values } )"
888
- column_schema ["COLUMN_TYPE" ] = set_format
889
858
self .columns [column_idx ].set_values = set_column_info
890
859
set_pos += 1
891
860
@@ -896,12 +865,12 @@ def _sync_column_info(self):
896
865
self .columns [column_idx ].unsigned = True
897
866
898
867
if column_idx in self .optional_metadata .simple_primary_key_list :
899
- column_schema [ "COLUMN_KEY" ] = "PRI"
900
-
901
- column_schemas . append ( column_schema )
868
+ self . columns [ column_idx ]. is_primary = True
869
+ if self . optional_metadata . visibility_list [ column_idx ]:
870
+ self . columns [ column_idx ]. visibility = True
902
871
903
872
self .table_obj = Table (
904
- column_schemas , self .table_id , self .schema , self .table , self .columns
873
+ self .table_id , self .schema , self .table , self .columns , column_name_flag = True
905
874
)
906
875
907
876
def _convert_include_non_numeric_column (self , signedness_bool_list ):
0 commit comments