Fix for issues with spatial fields (#14125)

*  Fix for issues with spatial fields

Fixes the following issues:

1.    #14068 SPATIAL fields with no unique index/autoincrement error when clicking
      This error occurs when there is no unique column to uniquely identify a tuple. I've disabled the geomtery view and made view as wkt the default view in such cases.

2.    #14121 View spatial fields as WKT doesn't work

1.    #14067 IS NULL search operator produces no WHERE SQL with spatial fields

Signed-Off-By: Lakshay arora <arora.lakshya123@gmail.com>

* Fix for issues with spatial fields
This commit fixes view as BINARY not working in the previous commit.
Signed-Off-By: Lakshay arora <arora.lakshya123@gmail.com>

* Fix for issues with spatial fields

Fixes typo in previous commits.

Signed-Off-By: Lakshay arora <arora.lakshya123@gmail.com>
This commit is contained in:
Lakshay arora 2018-05-12 12:14:58 +05:30 committed by Maurício Meneghini Fauth
parent 8bd91ffdaa
commit 9231620c2d
6 changed files with 47 additions and 18 deletions

View File

@ -1020,7 +1020,10 @@ class TableSearchController extends TableController
$geom_funcs = Util::getGISFunctions($types, true, false);
// If the function takes multiple parameters
if ($geom_funcs[$geom_func]['params'] > 1) {
if(strpos($func_type, "IS NULL") !== false || strpos($func_type, "IS NOT NULL") !== false) {
$where = Util::backquote($names) . " " . $func_type;
return $where;
} elseif ($geom_funcs[$geom_func]['params'] > 1) {
// create gis data from the criteria input
$gis_data = Util::createGISData($criteriaValues);
$where = $geom_func . '(' . Util::backquote($names)

View File

@ -1684,6 +1684,11 @@ class Results
*/
private function _getOptionsBlock()
{
if(isset($_SESSION['tmpval']['possible_as_geometry']) && $_SESSION['tmpval']['possible_as_geometry'] == false) {
if($_SESSION['tmpval']['geoOption'] == self::GEOMETRY_DISP_GEOM) {
$_SESSION['tmpval']['geoOption'] = self::GEOMETRY_DISP_WKT;
}
}
return Template::get('display/results/options_block')->render([
'unique_id' => $this->__get('unique_id'),
'geo_option' => $_SESSION['tmpval']['geoOption'],
@ -1693,6 +1698,7 @@ class Results
'relational_display' => $_SESSION['tmpval']['relational_display'],
'displaywork' => $GLOBALS['cfgRelation']['displaywork'],
'relwork' => $GLOBALS['cfgRelation']['relwork'],
'possible_as_geometry' => $_SESSION['tmpval']['possible_as_geometry'],
'pftext' => $_SESSION['tmpval']['pftext'],
'db' => $this->__get('db'),
'table' => $this->__get('table'),

View File

@ -1947,6 +1947,8 @@ EOT;
|| $updatableView)
&& $just_one_table;
$_SESSION['tmpval']['possible_as_geometry'] = $editable;
$displayParts = array(
'edit_lnk' => $displayResultsObject::UPDATE_ROW,
'del_lnk' => $displayResultsObject::DELETE_ROW,

View File

@ -2980,7 +2980,7 @@ class Util
}
$wktresult = $GLOBALS['dbi']->tryQuery(
$wktsql, null, DatabaseInterface::QUERY_STORE
$wktsql
);
$wktarr = $GLOBALS['dbi']->fetchRow($wktresult, 0);
$wktval = $wktarr[0];

View File

@ -73,22 +73,40 @@
} only %}
</div>
<div class="formelement">
{{ Util_getRadioFields(
'geoOption',
{
'GEOM': 'Geometry'|trans,
'WKT': 'Well Known Text'|trans,
'WKB': 'Well Known Binary'|trans
},
geo_option,
true,
true,
'',
'geoOption_' ~ unique_id
) }}
</div>
{% if possible_as_geometry %}
<div class="formelement">
{{ Util_getRadioFields(
'geoOption',
{
'GEOM': 'Geometry'|trans,
'WKT': 'Well Known Text'|trans,
'WKB': 'Well Known Binary'|trans
},
geo_option,
true,
true,
'',
'geoOption_' ~ unique_id
) }}
</div>
{% else %}
<div class="formelement">
{{ possible_as_geometry }}
{{ Util_getRadioFields(
'geoOption',
{
'WKT': 'Well Known Text'|trans,
'WKB': 'Well Known Binary'|trans
},
geo_option,
true,
true,
'',
'geoOption_' ~ unique_id
) }}
</div>
{% endif %}
<div class="clearfloat"></div>
</fieldset>

View File

@ -319,7 +319,7 @@ class TableSearchControllerTest extends PmaTestCase
'b', 'a'
);
$_POST['criteriaColumnOperators'] = array(
'<=', '='
'<=', '=', 'IS NULL', 'IS NOT NULL'
);
$_POST['criteriaValues'] = array(
'10', '2'