@@ -399,7 +399,15 @@ protected function formatFields($fields)
399
399
// 'NULL' means that the default value is NULL.
400
400
$ return [$ field ->name ]['default ' ] = null ;
401
401
} else {
402
- $ return [$ field ->name ]['default ' ] = trim ($ field ->default , "' " );
402
+ $ default = trim ($ field ->default , "' " );
403
+
404
+ if ($ this ->isIntegerType ($ field ->type )) {
405
+ $ default = (int ) $ default ;
406
+ } elseif ($ this ->isNumericType ($ field ->type )) {
407
+ $ default = (float ) $ default ;
408
+ }
409
+
410
+ $ return [$ field ->name ]['default ' ] = $ default ;
403
411
}
404
412
405
413
if ($ field ->primary_key ) {
@@ -413,6 +421,30 @@ protected function formatFields($fields)
413
421
return $ return ;
414
422
}
415
423
424
+ /**
425
+ * Is INTEGER type?
426
+ *
427
+ * @param string $type SQLite data type (case-insensitive)
428
+ *
429
+ * @see https://www.sqlite.org/datatype3.html
430
+ */
431
+ private function isIntegerType (string $ type ): bool
432
+ {
433
+ return strpos (strtoupper ($ type ), 'INT ' ) !== false ;
434
+ }
435
+
436
+ /**
437
+ * Is NUMERIC type?
438
+ *
439
+ * @param string $type SQLite data type (case-insensitive)
440
+ *
441
+ * @see https://www.sqlite.org/datatype3.html
442
+ */
443
+ private function isNumericType (string $ type ): bool
444
+ {
445
+ return in_array (strtoupper ($ type ), ['NUMERIC ' , 'DECIMAL ' ], true );
446
+ }
447
+
416
448
/**
417
449
* Converts keys retrieved from the database to
418
450
* the format needed to create later.
0 commit comments