36 if ( !self::isPresent() ) {
37 throw new RuntimeException(
"Can't check SQL syntax: SQLite not found" );
39 if ( !is_array( $files ) ) {
43 $allowedTypes = array_fill_keys( [
51 $db = DatabaseSqlite::newStandaloneInstance(
':memory:' );
53 foreach ( $files as $file ) {
54 $err = $db->sourceFile( $file );
60 $tables = $db->query(
"SELECT name FROM sqlite_master WHERE type='table'", __METHOD__ );
61 foreach ( $tables as $table ) {
62 if ( str_starts_with( $table->name,
'sqlite_' ) ) {
66 $columns = $db->query(
67 'PRAGMA table_info(' . $db->addIdentifierQuotes( $table->name ) .
')',
70 foreach ( $columns as $col ) {
71 if ( !isset( $allowedTypes[strtolower( $col->type )] ) ) {
72 $db->close( __METHOD__ );
74 return "Table {$table->name} has column {$col->name} with non-native type '{$col->type}'";
79 return $e->getMessage();
81 $db->close( __METHOD__ );