You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$this->query('INSERT into "sys/version" ("version") VALUES (?);', [$version]);
6112
-
6113
-
// update tables data
6114
-
$this->query('DELETE FROM "sys/tables";', []);
6115
-
$result = $this->query('SELECT "name", "type" FROM sqlite_master WHERE ("type" = \'table\' or "type" = \'view\') and name not like "sys/%" and name<>"sqlite_sequence";', []);
6116
-
$tables = array();
6117
-
foreach ($resultas$row) {
6118
-
$tables[] = $row['name'];
6119
-
$this->query('INSERT into "sys/tables" ("name", "type") VALUES (?, ?);', [$row['name'], $row['type']]);
6120
-
}
6121
-
// update columns and foreign_keys data
6122
-
$this->query('DELETE FROM "sys/columns";', []);
6123
-
$this->query('DELETE FROM "sys/foreign_keys";', []);
@@ -6160,8 +6115,7 @@ private function getTablesSQL(): string
6160
6115
case'sqlsrv':
6161
6116
return'SELECT o.name as "TABLE_NAME", o.xtype as "TABLE_TYPE" FROM sysobjects o WHERE o.xtype IN (\'U\', \'V\') ORDER BY "TABLE_NAME"';
6162
6117
case'sqlite':
6163
-
$this->updateSqlLiteReflectionTables();
6164
-
return'SELECT t.name as "TABLE_NAME", t.type as "TABLE_TYPE" FROM "sys/tables" t WHERE t.type IN (\'table\', \'view\') AND \'\' <> ? ORDER BY "TABLE_NAME"';
6118
+
return'SELECT t.name as "TABLE_NAME", t.type as "TABLE_TYPE" FROM sqlite_master t WHERE t.type IN (\'table\', \'view\') AND \'\' <> ? ORDER BY "TABLE_NAME"';
6165
6119
}
6166
6120
}
6167
6121
@@ -6175,8 +6129,7 @@ private function getTableColumnsSQL(): string
6175
6129
case'sqlsrv':
6176
6130
return'SELECT c.name AS "COLUMN_NAME", c.is_nullable AS "IS_NULLABLE", t.Name AS "DATA_TYPE", (c.max_length/2) AS "CHARACTER_MAXIMUM_LENGTH", c.precision AS "NUMERIC_PRECISION", c.scale AS "NUMERIC_SCALE", \'\' AS "COLUMN_TYPE" FROM sys.columns c INNER JOIN sys.types t ON c.user_type_id = t.user_type_id WHERE c.object_id = OBJECT_ID(?) AND \'\' <> ?';
6177
6131
case'sqlite':
6178
-
$this->updateSqlLiteReflectionTables();
6179
-
return'SELECT "name" AS "COLUMN_NAME", case when "notnull"==1 then \'no\' else \'yes\' end as "IS_NULLABLE", "type" AS "DATA_TYPE", 2147483647 AS "CHARACTER_MAXIMUM_LENGTH", 0 AS "NUMERIC_PRECISION", 0 AS "NUMERIC_SCALE", \'\' AS "COLUMN_TYPE" FROM "sys/columns" WHERE "self" = ? AND \'\' <> ?';
6132
+
return'SELECT "name" AS "COLUMN_NAME", case when "notnull"==1 then \'no\' else \'yes\' end as "IS_NULLABLE", lower("type") AS "DATA_TYPE", 2147483647 AS "CHARACTER_MAXIMUM_LENGTH", 0 AS "NUMERIC_PRECISION", 0 AS "NUMERIC_SCALE", \'\' AS "COLUMN_TYPE" FROM pragma_table_info(?) WHERE \'\' <> ?';
6180
6133
}
6181
6134
}
6182
6135
@@ -6190,7 +6143,7 @@ private function getTablePrimaryKeysSQL(): string
6190
6143
case'sqlsrv':
6191
6144
return'SELECT c.NAME as "COLUMN_NAME" FROM sys.key_constraints kc inner join sys.objects t on t.object_id = kc.parent_object_id INNER JOIN sys.index_columns ic ON kc.parent_object_id = ic.object_id and kc.unique_index_id = ic.index_id INNER JOIN sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id WHERE kc.type = \'PK\' and t.object_id = OBJECT_ID(?) and \'\' <> ?';
6192
6145
case'sqlite':
6193
-
return'SELECT "name" as "COLUMN_NAME" FROM "sys/columns" WHERE "pk"=1 AND "self"=? AND \'\' <> ?';
6146
+
return'SELECT "name" as "COLUMN_NAME" FROM pragma_table_info(?) WHERE "pk"=1 AND \'\' <> ?';
6194
6147
}
6195
6148
}
6196
6149
@@ -6204,7 +6157,7 @@ private function getTableForeignKeysSQL(): string
6204
6157
case'sqlsrv':
6205
6158
return'SELECT COL_NAME(fc.parent_object_id, fc.parent_column_id) AS "COLUMN_NAME", OBJECT_NAME (f.referenced_object_id) AS "REFERENCED_TABLE_NAME" FROM sys.foreign_keys AS f INNER JOIN sys.foreign_key_columns AS fc ON f.OBJECT_ID = fc.constraint_object_id WHERE f.parent_object_id = OBJECT_ID(?) and \'\' <> ?';
6206
6159
case'sqlite':
6207
-
return'SELECT "from" AS "COLUMN_NAME", "table" AS "REFERENCED_TABLE_NAME" FROM "sys/foreign_keys" WHERE "self" = ? AND\'\' <> ?';
6160
+
return'SELECT "from" AS "COLUMN_NAME", "table" AS "REFERENCED_TABLE_NAME" FROM pragma_foreign_key_list(?) WHERE\'\' <> ?';
6208
6161
}
6209
6162
}
6210
6163
@@ -6268,8 +6221,8 @@ public function getTableColumns(string $tableName, string $type): array
6268
6221
}
6269
6222
if ($this->driver == 'sqlite') {
6270
6223
foreach ($resultsas &$result) {
6271
-
// mysql does not properly reflect display width of types
0 commit comments