Fixed gh-518 to allow decimal for SQL to work properly. Fixed database relationship mapping in dynamicGet area.

This commit is contained in:
Llewellyn van der Merwe 2020-02-09 13:13:42 +02:00
parent 12c456ca6b
commit 4664d89d0e
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
7 changed files with 38 additions and 22 deletions

View File

@ -144,11 +144,11 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 4th February, 2020 + *Last Build*: 9th February, 2020
+ *Version*: 2.10.11 + *Version*: 2.10.11
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **281315** + *Line count*: **281319**
+ *Field count*: **1505** + *Field count*: **1505**
+ *File count*: **1770** + *File count*: **1770**
+ *Folder count*: **280** + *Folder count*: **280**

View File

@ -144,11 +144,11 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015 + *First Build*: 30th April, 2015
+ *Last Build*: 4th February, 2020 + *Last Build*: 9th February, 2020
+ *Version*: 2.10.11 + *Version*: 2.10.11
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt + *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **281315** + *Line count*: **281319**
+ *Field count*: **1505** + *Field count*: **1505**
+ *File count*: **1770** + *File count*: **1770**
+ *Folder count*: **280** + *Folder count*: **280**

View File

@ -3613,15 +3613,14 @@ class Get
// array(join_field_as, join_field) // array(join_field_as, join_field)
$bucket['join_field'] = array_map('trim', explode('.', $op['join_field'])); $bucket['join_field'] = array_map('trim', explode('.', $op['join_field']));
// triget filed that has table a relationship // triget filed that has table a relationship
if ($bucket['on_field'][0] === 'a' || if ($op['row_type'] == 1 && ($bucket['on_field'][0] === 'a' ||
isset($_part_of_a[$bucket['on_field'][0]]) || isset($_part_of_a[$bucket['on_field'][0]]) ||
isset($_part_of_a[$bucket['join_field'][0]])) isset($_part_of_a[$bucket['join_field'][0]])))
{ {
$_part_of_a[$op['as']] = $op['as']; $_part_of_a[$op['as']] = $op['as'];
} }
return $bucket; return $bucket;
}, $result->join_view_table); }, $result->join_view_table);
// loop joints // loop joints
foreach ($result->join_view_table as $nr => &$option) foreach ($result->join_view_table as $nr => &$option)
{ {
@ -3679,9 +3678,9 @@ class Get
// array(join_field_as, join_field) // array(join_field_as, join_field)
$bucket['join_field'] = array_map('trim', explode('.', $op['join_field'])); $bucket['join_field'] = array_map('trim', explode('.', $op['join_field']));
// triget filed that has table a relationship // triget filed that has table a relationship
if ($bucket['on_field'][0] === 'a' || if ($op['row_type'] == 1 && ($bucket['on_field'][0] === 'a' ||
isset($_part_of_a[$bucket['on_field'][0]]) || isset($_part_of_a[$bucket['on_field'][0]]) ||
isset($_part_of_a[$bucket['join_field'][0]])) isset($_part_of_a[$bucket['join_field'][0]])))
{ {
$_part_of_a[$op['as']] = $op['as']; $_part_of_a[$op['as']] = $op['as'];
} }

View File

@ -2734,12 +2734,25 @@ class Fields extends Structure
elseif (isset($field['settings']->datatype)) elseif (isset($field['settings']->datatype))
{ {
// insure default not none if number type // insure default not none if number type
$intKeys = array('INT', 'TINYINT', 'BIGINT', 'FLOAT', 'DECIMAL', 'DOUBLE'); $numberKeys = array('INT', 'TINYINT', 'BIGINT', 'FLOAT', 'DECIMAL', 'DOUBLE');
if (in_array($field['settings']->datatype, $intKeys)) // don't use these as index or uniqe keys
$textKeys = array('TEXT', 'TINYTEXT', 'MEDIUMTEXT', 'LONGTEXT', 'BLOB', 'TINYBLOB', 'MEDIUMBLOB', 'LONGBLOB');
// build the query values
$this->queryBuilder[$view_name_single][$name]['type'] = $field['settings']->datatype;
// check if this is a number
if (in_array($field['settings']->datatype, $numberKeys))
{ {
if ($field['settings']->datadefault === 'Other') if ($field['settings']->datadefault === 'Other')
{ {
if (!is_numeric($field['settings']->datadefault_other) || $field['settings']->datadefault_other !== '0000-00-00 00:00:00') // setup the checking
$number_check = $field['settings']->datadefault_other;
// Decimals in SQL needs some help
if ('DECIMAL' === $field['settings']->datatype && !is_numeric($number_check))
{
$number_check = str_replace(',', '.', $field['settings']->datadefault_other);
}
// check if we have a valid number value
if (!is_numeric($number_check))
{ {
$field['settings']->datadefault_other = '0'; $field['settings']->datadefault_other = '0';
} }
@ -2749,10 +2762,7 @@ class Fields extends Structure
$field['settings']->datadefault = '0'; $field['settings']->datadefault = '0';
} }
} }
// don't use these as index or uniqe keys // check if this is not text
$textKeys = array('TEXT', 'TINYTEXT', 'MEDIUMTEXT', 'LONGTEXT', 'BLOB', 'TINYBLOB', 'MEDIUMBLOB', 'LONGBLOB');
// build the query values
$this->queryBuilder[$view_name_single][$name]['type'] = $field['settings']->datatype;
if (!in_array($field['settings']->datatype, $textKeys)) if (!in_array($field['settings']->datatype, $textKeys))
{ {
$this->queryBuilder[$view_name_single][$name]['lenght'] = $field['settings']->datalenght; $this->queryBuilder[$view_name_single][$name]['lenght'] = $field['settings']->datalenght;
@ -2760,6 +2770,7 @@ class Fields extends Structure
$this->queryBuilder[$view_name_single][$name]['default'] = $field['settings']->datadefault; $this->queryBuilder[$view_name_single][$name]['default'] = $field['settings']->datadefault;
$this->queryBuilder[$view_name_single][$name]['other'] = $field['settings']->datadefault_other; $this->queryBuilder[$view_name_single][$name]['other'] = $field['settings']->datadefault_other;
} }
// fall back unto EMPTY for text
else else
{ {
$this->queryBuilder[$view_name_single][$name]['default'] = 'EMPTY'; $this->queryBuilder[$view_name_single][$name]['default'] = 'EMPTY';

View File

@ -1637,10 +1637,10 @@ class Interpretation extends Fields
{ {
// to insure that there be no double entries of a call // to insure that there be no double entries of a call
$checker = md5(serialize($the_get) . $code); $checker = md5(serialize($the_get) . $code);
if (!isset($this->customViewQueryChecker[$this->target]) || !in_array($checker, $this->customViewQueryChecker[$this->target])) if (!isset($this->customViewQueryChecker[$this->target]) || !isset($checker, $this->customViewQueryChecker[$this->target][$checker]))
{ {
// load this unuiqe key // load this unuiqe key
$this->customViewQueryChecker[$this->target][] = $checker; $this->customViewQueryChecker[$this->target][$checker] = true;
if (isset($the_get['selection']['type']) && ComponentbuilderHelper::checkString($the_get['selection']['type'])) if (isset($the_get['selection']['type']) && ComponentbuilderHelper::checkString($the_get['selection']['type']))
{ {
$getItem = PHP_EOL . PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "//" . $this->setLine(__LINE__) . " Get from " . $the_get['selection']['table'] . " as " . $the_get['as']; $getItem = PHP_EOL . PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "//" . $this->setLine(__LINE__) . " Get from " . $the_get['selection']['table'] . " as " . $the_get['as'];
@ -1673,7 +1673,9 @@ class Interpretation extends Fields
// set the method defaults // set the method defaults
if (($default = $this->setCustomViewMethodDefaults($the_get, $code)) !== false) if (($default = $this->setCustomViewMethodDefaults($the_get, $code)) !== false)
{ {
if (isset($this->siteDynamicGet[$this->target][$default['code']][$default['as']][$default['join_field']]) && ComponentbuilderHelper::checkString($this->siteDynamicGet[$this->target][$default['code']][$default['as']][$default['join_field']]) && !in_array($check, $mainAsArray)) if (isset($this->siteDynamicGet[$this->target][$default['code']][$default['as']][$default['join_field']])
&& ComponentbuilderHelper::checkString($this->siteDynamicGet[$this->target][$default['code']][$default['as']][$default['join_field']])
&& !in_array($check, $mainAsArray))
{ {
// load to other query // load to other query
if (!isset($this->otherQuery[$this->target][$default['code']][$this->siteDynamicGet[$this->target][$default['code']][$default['as']][$default['join_field']]][$default['valueName']])) if (!isset($this->otherQuery[$this->target][$default['code']][$this->siteDynamicGet[$this->target][$default['code']][$default['as']][$default['join_field']]][$default['valueName']]))
@ -4458,7 +4460,7 @@ class Interpretation extends Fields
else else
{ {
// insure the form is added (only if no form exist) // insure the form is added (only if no form exist)
if ('admin' === $this->target && strpos($view['settings']->default, '<form') === false) if ('site' !== $this->target && strpos($view['settings']->default, '<form') === false)
{ {
$this->addCustomForm[$this->target][$view['settings']->code] = true; $this->addCustomForm[$this->target][$view['settings']->code] = true;
} }

View File

@ -34,6 +34,7 @@ JHtml::_('behavior.keepalive');
} }
</script> </script>
<?php $urlId = (isset($this->item->id)) ? '&id='. (int) $this->item->id : ''; ?> <?php $urlId = (isset($this->item->id)) ? '&id='. (int) $this->item->id : ''; ?>
<form action="<?php echo JRoute::_('index.php?option=com_componentbuilder&view=assistant' . $urlId); ?>" method="post" name="adminForm" id="adminForm" class="form-validate" enctype="multipart/form-data">
<script type="text/javascript"> <script type="text/javascript">
// Add spindle-wheel for importations: // Add spindle-wheel for importations:
@ -124,6 +125,9 @@ function JRouter(link) {
return url+link; return url+link;
} }
</script> </script>
<input type="hidden" name="task" value="" />
<?php echo JHtml::_('form.token'); ?>
</form>
<?php else: ?> <?php else: ?>
<h1><?php echo JText::_('COM_COMPONENTBUILDER_NO_ACCESS_GRANTED'); ?></h1> <h1><?php echo JText::_('COM_COMPONENTBUILDER_NO_ACCESS_GRANTED'); ?></h1>
<?php endif; ?> <?php endif; ?>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2" method="upgrade"> <extension type="component" version="3.2" method="upgrade">
<name>COM_COMPONENTBUILDER</name> <name>COM_COMPONENTBUILDER</name>
<creationDate>4th February, 2020</creationDate> <creationDate>9th February, 2020</creationDate>
<author>Llewellyn van der Merwe</author> <author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail> <authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl> <authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>