@@ -399,7 +399,15 @@ protected function formatFields($fields)
399399 // 'NULL' means that the default value is NULL.
400400 $ return [$ field ->name ]['default ' ] = null ;
401401 } 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 ;
403411 }
404412
405413 if ($ field ->primary_key ) {
@@ -413,6 +421,30 @@ protected function formatFields($fields)
413421 return $ return ;
414422 }
415423
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 (bool ) (strpos ($ 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 (bool ) (in_array ($ type , ['NUMERIC ' , 'DECIMAL ' ], true ));
446+ }
447+
416448 /**
417449 * Converts keys retrieved from the database to
418450 * the format needed to create later.
0 commit comments