50 if ( !self::isPresent() ) {
51 throw new RuntimeException(
"Can't check SQL syntax: SQLite not found" );
53 if ( !is_array( $files ) ) {
57 $allowedTypes = array_fill_keys( [
65 $db = DatabaseSqlite::newStandaloneInstance(
':memory:' );
67 foreach ( $files as $file ) {
68 $err = $db->sourceFile( $file );
74 $tables = $db->query(
"SELECT name FROM sqlite_master WHERE type='table'", __METHOD__ );
75 foreach ( $tables as $table ) {
76 if ( strpos( $table->name,
'sqlite_' ) === 0 ) {
80 $columns = $db->query(
81 'PRAGMA table_info(' . $db->addIdentifierQuotes( $table->name ) .
')',
84 foreach ( $columns as $col ) {
85 if ( !isset( $allowedTypes[strtolower( $col->type )] ) ) {
86 $db->close( __METHOD__ );
88 return "Table {$table->name} has column {$col->name} with non-native type '{$col->type}'";
93 return $e->getMessage();
95 $db->close( __METHOD__ );