PostgreSQL: Fix editing data in views (bug #605)

This commit is contained in:
Jakub Vrana 2018-03-11 16:41:04 +01:00
parent d271d0b481
commit 6ba77b7899
2 changed files with 4 additions and 3 deletions

View file

@ -217,7 +217,7 @@ if (isset($_GET["pgsql"])) {
function convertSearch($idf, $val, $field) {
return (preg_match('~char|text'
. (!preg_match('~LIKE~', $val["op"]) ? '|date|time(stamp)?' . (is_numeric($val["val"]) ? '|' . number_type() : '') : '')
. '~', $field["type"]) || $val["op"] == "SQL"
. '~', $field["type"])
? $idf
: "CAST($idf AS text)"
);
@ -286,7 +286,7 @@ if (isset($_GET["pgsql"])) {
function limit1($table, $query, $where, $separator = "\n") {
return (preg_match('~^INTO~', $query)
? limit($query, $where, 1, 0, $separator)
: " $query WHERE ctid = (SELECT ctid FROM " . table($table) . $where . $separator . "LIMIT 1)"
: " $query" . (is_view(table_status1($table)) ? $where : " WHERE ctid = (SELECT ctid FROM " . table($table) . $where . $separator . "LIMIT 1)")
);
}
@ -845,7 +845,7 @@ AND typelem = 0"
$structured_types[$key] = array_keys($val);
}
$unsigned = array();
$operators = array("=", "<", ">", "<=", ">=", "!=", "~", "!~", "LIKE", "LIKE %%", "ILIKE", "ILIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL", "SQL");
$operators = array("=", "<", ">", "<=", ">=", "!=", "~", "!~", "LIKE", "LIKE %%", "ILIKE", "ILIKE %%", "IN", "IS NULL", "NOT LIKE", "NOT IN", "IS NOT NULL"); // no "SQL" to avoid SQL injection
$functions = array("char_length", "lower", "round", "to_hex", "to_timestamp", "upper");
$grouping = array("avg", "count", "count distinct", "max", "min", "sum");
$edit_functions = array(

View file

@ -5,6 +5,7 @@ Decrease timeout for running slow queries from 5 seconds to 2 seconds
Fix displaying info about non-alphabetical objects (bug #599)
PDO: Support binary fields download
MySQL: Use CONVERT() only when searching for non-ASCII (bug #603)
PostgreSQL: Fix editing data in views (bug #605, regression from 4.6.0)
PostgreSQL: Do not cast date/time searches to text
PostgreSQL: Add SQL operator to search