| 1 | module mysql |
| 2 | |
| 3 | // FieldType is a list of all supported MYSQL field types. |
| 4 | pub enum FieldType { |
| 5 | type_decimal |
| 6 | type_tiny |
| 7 | type_short |
| 8 | type_long |
| 9 | type_float |
| 10 | type_double |
| 11 | type_null |
| 12 | type_timestamp |
| 13 | type_longlong |
| 14 | type_int24 |
| 15 | type_date |
| 16 | type_time |
| 17 | type_datetime |
| 18 | type_year |
| 19 | type_newdate |
| 20 | type_varchar |
| 21 | type_bit |
| 22 | type_timestamp2 |
| 23 | type_datetime2 |
| 24 | type_time2 |
| 25 | type_json = 245 |
| 26 | type_newdecimal |
| 27 | type_enum |
| 28 | type_set |
| 29 | type_tiny_blob |
| 30 | type_medium_blob |
| 31 | type_long_blob |
| 32 | type_blob |
| 33 | type_var_string |
| 34 | type_string |
| 35 | type_geometry |
| 36 | } |
| 37 | |
| 38 | // str returns a text representation of the field type `f`. |
| 39 | pub fn (f FieldType) str() string { |
| 40 | return match f { |
| 41 | .type_decimal { 'decimal' } |
| 42 | .type_tiny { 'tiny' } |
| 43 | .type_short { 'short' } |
| 44 | .type_long { 'long' } |
| 45 | .type_float { 'float' } |
| 46 | .type_double { 'double' } |
| 47 | .type_null { 'null' } |
| 48 | .type_timestamp { 'timestamp' } |
| 49 | .type_longlong { 'longlong' } |
| 50 | .type_int24 { 'int24' } |
| 51 | .type_date { 'date' } |
| 52 | .type_time { 'time' } |
| 53 | .type_datetime { 'datetime' } |
| 54 | .type_year { 'year' } |
| 55 | .type_newdate { 'newdate' } |
| 56 | .type_varchar { 'varchar' } |
| 57 | .type_bit { 'bit' } |
| 58 | .type_timestamp2 { 'timestamp2' } |
| 59 | .type_datetime2 { 'datetime2' } |
| 60 | .type_time2 { 'time2' } |
| 61 | .type_json { 'json' } |
| 62 | .type_newdecimal { 'newdecimal' } |
| 63 | .type_enum { 'enum' } |
| 64 | .type_set { 'set' } |
| 65 | .type_tiny_blob { 'tiny_blob' } |
| 66 | .type_medium_blob { 'medium_blob' } |
| 67 | .type_long_blob { 'long_blob' } |
| 68 | .type_blob { 'blob' } |
| 69 | .type_var_string { 'var_string' } |
| 70 | .type_string { 'string' } |
| 71 | .type_geometry { 'geometry' } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // get_len returns the length in bytes, for the given field type `f`. |
| 76 | // Should be deleted after the `time` type reimplementation. |
| 77 | pub fn (f FieldType) get_len() u32 { |
| 78 | return match f { |
| 79 | .type_blob { 262140 } |
| 80 | else { 0 } |
| 81 | } |
| 82 | } |
| 83 | |