## Adminer dev
- Export: Fix tar (regression from 5.0.3)
+- Optimize retrieving columns for schema
- Elasticsearch: Make it work with Elasticsearch 8
- CSS: Hide menu on mobile
- CSS: Invert icons in dark mode
preg_match_all('~ CHECK *(\( *(((?>[^()]*[^() ])|(?1))*) *\))~', get_val("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = " . q($table), 0, $this->conn), $matches); //! could be inside a comment
return array_combine($matches[2], $matches[2]);
}
+
+ function allFields(): array {
+ $return = array();
+ foreach (tables_list() as $table => $type) {
+ foreach (fields($table) as $field) {
+ $return[$table][] = $field;
+ }
+ }
+ return $return;
+ }
}
JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS t ON c.CONSTRAINT_SCHEMA = t.CONSTRAINT_SCHEMA AND c.CONSTRAINT_NAME = t.CONSTRAINT_NAME
WHERE c.CONSTRAINT_SCHEMA = " . q($_GET["ns"] != "" ? $_GET["ns"] : DB) . "
AND t.TABLE_NAME = " . q($table) . "
-AND CHECK_CLAUSE NOT LIKE '% IS NOT NULL'"); // ignore default IS NOT NULL checks in PostrgreSQL
+AND CHECK_CLAUSE NOT LIKE '% IS NOT NULL'", $this->conn); // ignore default IS NOT NULL checks in PostrgreSQL
+ }
+
+ /** Get all fields in the current schema
+ * @return array<list<array{field:string, null:bool, type:string, length:?numeric-string, primary?:numeric-string}>>
+ */
+ function allFields(): array {
+ $return = array();
+ foreach (get_rows("SELECT TABLE_NAME AS tab, COLUMN_NAME AS field, IS_NULLABLE AS nullable, DATA_TYPE AS type, CHARACTER_MAXIMUM_LENGTH AS length" . (JUSH == 'sql' ? ", COLUMN_KEY = 'PRI' AS `primary`" : "") . "
+FROM INFORMATION_SCHEMA.COLUMNS
+WHERE TABLE_SCHEMA = " . q($_GET["ns"] != "" ? $_GET["ns"] : DB) . "
+ORDER BY TABLE_NAME, ORDINAL_POSITION", $this->conn) as $row) {
+ $row["null"] = ($row["nullable"] == "YES");
+ $return[$row["tab"]][] = $row;
+ }
+ return $return;
}
}
$schema = array(); // table => array("fields" => array(name => field), "pos" => array(top, left), "references" => array(table => array(left => array(source, target))))
$referenced = array(); // target_table => array(table => array(left => target_column))
$lefts = array(); // float => bool
+$all_fields = driver()->allFields();
foreach (table_status('', true) as $table => $table_status) {
if (is_view($table_status)) {
continue;
}
$pos = 0;
$schema[$table]["fields"] = array();
- foreach (fields($table) as $name => $field) {
+ foreach ($all_fields[$table] as $field) {
$pos += 1.25;
$field["pos"] = $pos;
- $schema[$table]["fields"][$name] = $field;
+ $schema[$table]["fields"][$field["field"]] = $field;
}
$schema[$table]["pos"] = ($table_pos[$table] ?: array($top, 0));
foreach (adminer()->foreignKeys($table) as $val) {
echo script("qsl('div').onmousedown = schemaMousedown;");
foreach ($table["fields"] as $field) {
- $val = '<span' . type_class($field["type"]) . ' title="' . h($field["full_type"] . ($field["null"] ? " NULL" : '')) . '">' . h($field["field"]) . '</span>';
+ $val = '<span' . type_class($field["type"]) . ' title="' . h($field["type"] . ($field["length"] ? "($field[length])" : "") . ($field["null"] ? " NULL" : '')) . '">' . h($field["field"]) . '</span>';
echo "<br>" . ($field["primary"] ? "<i>$val</i>" : $val);
}