@@ -278,156 +278,38 @@ public static MySqlDbType ConvertToMySqlDbType(ColumnDefinitionPayload columnDef
278
278
279
279
public static ushort ConvertToColumnTypeAndFlags ( MySqlDbType dbType , MySqlGuidFormat guidFormat )
280
280
{
281
- var isUnsigned = false ;
282
- ColumnType columnType ;
283
- switch ( dbType )
281
+ var isUnsigned = dbType == MySqlDbType . UByte || dbType == MySqlDbType . UInt16 ||
282
+ dbType == MySqlDbType . UInt24 || dbType == MySqlDbType . UInt32 || dbType == MySqlDbType . UInt64 ;
283
+ var columnType = dbType switch
284
284
{
285
- case MySqlDbType . Bool :
286
- case MySqlDbType . Byte :
287
- columnType = ColumnType . Tiny ;
288
- break ;
289
-
290
- case MySqlDbType . UByte :
291
- columnType = ColumnType . Tiny ;
292
- isUnsigned = true ;
293
- break ;
294
-
295
- case MySqlDbType . Int16 :
296
- columnType = ColumnType . Short ;
297
- break ;
298
-
299
- case MySqlDbType . UInt16 :
300
- columnType = ColumnType . Short ;
301
- isUnsigned = true ;
302
- break ;
303
-
304
- case MySqlDbType . Int24 :
305
- columnType = ColumnType . Int24 ;
306
- break ;
307
-
308
- case MySqlDbType . UInt24 :
309
- columnType = ColumnType . Int24 ;
310
- isUnsigned = true ;
311
- break ;
312
-
313
- case MySqlDbType . Int32 :
314
- columnType = ColumnType . Long ;
315
- break ;
316
-
317
- case MySqlDbType . UInt32 :
318
- columnType = ColumnType . Long ;
319
- isUnsigned = true ;
320
- break ;
321
-
322
- case MySqlDbType . Int64 :
323
- columnType = ColumnType . Longlong ;
324
- break ;
325
-
326
- case MySqlDbType . UInt64 :
327
- columnType = ColumnType . Longlong ;
328
- isUnsigned = true ;
329
- break ;
330
-
331
- case MySqlDbType . Bit :
332
- columnType = ColumnType . Bit ;
333
- break ;
334
-
335
- case MySqlDbType . Guid :
336
- if ( guidFormat == MySqlGuidFormat . Char36 || guidFormat == MySqlGuidFormat . Char32 )
337
- columnType = ColumnType . String ;
338
- else
339
- columnType = ColumnType . Blob ;
340
- break ;
341
-
342
- case MySqlDbType . Enum :
343
- case MySqlDbType . Set :
344
- columnType = ColumnType . String ;
345
- break ;
346
-
347
- case MySqlDbType . Binary :
348
- case MySqlDbType . String :
349
- columnType = ColumnType . String ;
350
- break ;
351
-
352
- case MySqlDbType . VarBinary :
353
- case MySqlDbType . VarChar :
354
- case MySqlDbType . VarString :
355
- columnType = ColumnType . VarString ;
356
- break ;
357
-
358
- case MySqlDbType . TinyBlob :
359
- case MySqlDbType . TinyText :
360
- columnType = ColumnType . TinyBlob ;
361
- break ;
362
-
363
- case MySqlDbType . Blob :
364
- case MySqlDbType . Text :
365
- columnType = ColumnType . Blob ;
366
- break ;
367
-
368
- case MySqlDbType . MediumBlob :
369
- case MySqlDbType . MediumText :
370
- columnType = ColumnType . MediumBlob ;
371
- break ;
372
-
373
- case MySqlDbType . LongBlob :
374
- case MySqlDbType . LongText :
375
- columnType = ColumnType . LongBlob ;
376
- break ;
377
-
378
- case MySqlDbType . JSON :
379
- columnType = ColumnType . Json ; // TODO: test
380
- break ;
381
-
382
- case MySqlDbType . Date :
383
- case MySqlDbType . Newdate :
384
- columnType = ColumnType . Date ;
385
- break ;
386
-
387
- case MySqlDbType . DateTime :
388
- columnType = ColumnType . DateTime ;
389
- break ;
390
-
391
- case MySqlDbType . Timestamp :
392
- columnType = ColumnType . Timestamp ;
393
- break ;
394
-
395
- case MySqlDbType . Time :
396
- columnType = ColumnType . Time ;
397
- break ;
398
-
399
- case MySqlDbType . Year :
400
- columnType = ColumnType . Year ;
401
- break ;
402
-
403
- case MySqlDbType . Float :
404
- columnType = ColumnType . Float ;
405
- break ;
406
-
407
- case MySqlDbType . Double :
408
- columnType = ColumnType . Double ;
409
- break ;
410
-
411
- case MySqlDbType . Decimal :
412
- columnType = ColumnType . Decimal ;
413
- break ;
414
-
415
- case MySqlDbType . NewDecimal :
416
- columnType = ColumnType . NewDecimal ;
417
- break ;
418
-
419
- case MySqlDbType . Geometry :
420
- columnType = ColumnType . Geometry ;
421
- break ;
422
-
423
- case MySqlDbType . Null :
424
- columnType = ColumnType . Null ;
425
- break ;
426
-
427
- default :
428
- throw new NotImplementedException ( "ConvertToColumnTypeAndFlags for {0} is not implemented" . FormatInvariant ( dbType ) ) ;
429
- }
430
-
285
+ MySqlDbType . Bool or MySqlDbType . Byte or MySqlDbType . UByte => ColumnType . Tiny ,
286
+ MySqlDbType . Int16 or MySqlDbType . UInt16 => ColumnType . Short ,
287
+ MySqlDbType . Int24 or MySqlDbType . UInt24 => ColumnType . Int24 ,
288
+ MySqlDbType . Int32 or MySqlDbType . UInt32 => ColumnType . Long ,
289
+ MySqlDbType . Int64 or MySqlDbType . UInt64 => ColumnType . Longlong ,
290
+ MySqlDbType . Bit => ColumnType . Bit ,
291
+ MySqlDbType . Guid => ( guidFormat == MySqlGuidFormat . Char36 || guidFormat == MySqlGuidFormat . Char32 ) ? ColumnType . String : ColumnType . Blob ,
292
+ MySqlDbType . Enum or MySqlDbType . Set => ColumnType . String ,
293
+ MySqlDbType . Binary or MySqlDbType . String => ColumnType . String ,
294
+ MySqlDbType . VarBinary or MySqlDbType . VarChar or MySqlDbType . VarString => ColumnType . VarString ,
295
+ MySqlDbType . TinyBlob or MySqlDbType . TinyText => ColumnType . TinyBlob ,
296
+ MySqlDbType . Blob or MySqlDbType . Text => ColumnType . Blob ,
297
+ MySqlDbType . MediumBlob or MySqlDbType . MediumText => ColumnType . MediumBlob ,
298
+ MySqlDbType . LongBlob or MySqlDbType . LongText => ColumnType . LongBlob ,
299
+ MySqlDbType . JSON => ColumnType . Json , // TODO: test
300
+ MySqlDbType . Date or MySqlDbType . Newdate => ColumnType . Date ,
301
+ MySqlDbType . DateTime => ColumnType . DateTime ,
302
+ MySqlDbType . Timestamp => ColumnType . Timestamp ,
303
+ MySqlDbType . Time => ColumnType . Time ,
304
+ MySqlDbType . Year => ColumnType . Year ,
305
+ MySqlDbType . Float => ColumnType . Float ,
306
+ MySqlDbType . Double => ColumnType . Double ,
307
+ MySqlDbType . Decimal => ColumnType . Decimal ,
308
+ MySqlDbType . NewDecimal => ColumnType . NewDecimal ,
309
+ MySqlDbType . Geometry => ColumnType . Geometry ,
310
+ MySqlDbType . Null => ColumnType . Null ,
311
+ _ => throw new NotImplementedException ( "ConvertToColumnTypeAndFlags for {0} is not implemented" . FormatInvariant ( dbType ) ) ,
312
+ } ;
431
313
return ( ushort ) ( ( byte ) columnType | ( isUnsigned ? 0x8000 : 0 ) ) ;
432
314
}
433
315
0 commit comments