mirror of
https://github.com/silverstripe/silverstripe-sqlite3
synced 2024-10-22 17:05:37 +02:00
ENHANCEMENT: take into account that older Sqlite can modify the CREATE string and inject single quotes around table names that breaks the db reflection mechanism (happens when the table is renamed)
This commit is contained in:
parent
0094e39a9e
commit
47a91fe6c5
@ -460,7 +460,7 @@ class SQLite3Database extends SS_Database {
|
|||||||
$fieldList = array();
|
$fieldList = array();
|
||||||
|
|
||||||
if($sqlCreate && $sqlCreate['sql']) {
|
if($sqlCreate && $sqlCreate['sql']) {
|
||||||
preg_match('/^[\s]*CREATE[\s]+TABLE[\s]+"[a-zA-Z0-9_]+"[\s]*\((.+)\)[\s]*$/ims', $sqlCreate['sql'], $matches);
|
preg_match('/^[\s]*CREATE[\s]+TABLE[\s]+[\'"][a-zA-Z0-9_]+[\'"][\s]*\((.+)\)[\s]*$/ims', $sqlCreate['sql'], $matches);
|
||||||
$fields = isset($matches[1]) ? preg_split('/,(?=(?:[^\'"]*$)|(?:[^\'"]*[\'"][^\'"]*[\'"][^\'"]*)*$)/x', $matches[1]) : array();
|
$fields = isset($matches[1]) ? preg_split('/,(?=(?:[^\'"]*$)|(?:[^\'"]*[\'"][^\'"]*[\'"][^\'"]*)*$)/x', $matches[1]) : array();
|
||||||
foreach($fields as $field) {
|
foreach($fields as $field) {
|
||||||
$details = preg_split('/\s/', trim($field));
|
$details = preg_split('/\s/', trim($field));
|
||||||
|
Loading…
Reference in New Issue
Block a user