var $functions = array("hex", "length", "lower", "round", "unixepoch", "upper");
var $grouping = array("avg", "count", "count distinct", "group_concat", "max", "min", "sum");
+ function __construct($connection) {
+ parent::__construct($connection);
+ if (min_version(3.31, 0, $connection)) {
+ $this->generated = array("STORED", "VIRTUAL");
+ }
+ }
+
function structuredTypes() {
return array_keys($this->types[0]);
}
global $connection;
$return = array();
$primary = "";
- foreach (get_rows("PRAGMA table_info(" . table($table) . ")") as $row) {
+ foreach (get_rows("PRAGMA table_" . (min_version(3.31) ? "x" : "") . "info(" . table($table) . ")") as $row) {
$name = $row["name"];
$type = strtolower($row["type"]);
$default = $row["dflt_value"];
}
}
$sql = $connection->result("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = " . q($table));
- preg_match_all('~(("[^"]*+")+|[a-z0-9_]+)\s+text\s+COLLATE\s+(\'[^\']+\'|\S+)~i', $sql, $matches, PREG_SET_ORDER);
+ $idf = '(("[^"]*+")+|[a-z0-9_]+)';
+ preg_match_all('~' . $idf . '\s+text\s+COLLATE\s+(\'[^\']+\'|\S+)~i', $sql, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$name = str_replace('""', '"', preg_replace('~^"|"$~', '', $match[1]));
if ($return[$name]) {
$return[$name]["collation"] = trim($match[3], "'");
}
}
+ preg_match_all('~' . $idf . '\s.*GENERATED ALWAYS AS \((.+)\) (STORED|VIRTUAL)~i', $sql, $matches, PREG_SET_ORDER);
+ foreach ($matches as $match) {
+ $name = str_replace('""', '"', preg_replace('~^"|"$~', '', $match[1]));
+ $return[$name]["default"] = $match[3];
+ $return[$name]["generated"] = strtoupper($match[4]);
+ }
return $return;
}
queries("BEGIN");
}
foreach ($fields as $key => $field) {
+ if (preg_match('~GENERATED~', $field[3])) {
+ unset($originals[array_search($field[0], $originals)]);
+ }
$fields[$key] = " " . implode($field);
}
$fields = array_merge($fields, array_filter($foreign));
PostgreSQL: Skip editing generated columns
PostgreSQL, MS SQL, Oracle: Hide table actions for information_schema
SQLite: Support CHECK constraint
+SQLite: Support generated columns
SQLite: Add command Check tables
SQLite: Display all rows of variable values
SQLite: Remove support for SQLite version 2