Fixed gh-518 to allow decimal for SQL to work properly. Fixed database relationship mapping in dynamicGet area.
This commit is contained in:
@ -3613,15 +3613,14 @@ class Get
|
||||
// array(join_field_as, join_field)
|
||||
$bucket['join_field'] = array_map('trim', explode('.', $op['join_field']));
|
||||
// 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['join_field'][0]]))
|
||||
isset($_part_of_a[$bucket['join_field'][0]])))
|
||||
{
|
||||
$_part_of_a[$op['as']] = $op['as'];
|
||||
}
|
||||
return $bucket;
|
||||
}, $result->join_view_table);
|
||||
|
||||
// loop joints
|
||||
foreach ($result->join_view_table as $nr => &$option)
|
||||
{
|
||||
@ -3679,9 +3678,9 @@ class Get
|
||||
// array(join_field_as, join_field)
|
||||
$bucket['join_field'] = array_map('trim', explode('.', $op['join_field']));
|
||||
// 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['join_field'][0]]))
|
||||
isset($_part_of_a[$bucket['join_field'][0]])))
|
||||
{
|
||||
$_part_of_a[$op['as']] = $op['as'];
|
||||
}
|
||||
|
@ -2734,12 +2734,25 @@ class Fields extends Structure
|
||||
elseif (isset($field['settings']->datatype))
|
||||
{
|
||||
// insure default not none if number type
|
||||
$intKeys = array('INT', 'TINYINT', 'BIGINT', 'FLOAT', 'DECIMAL', 'DOUBLE');
|
||||
if (in_array($field['settings']->datatype, $intKeys))
|
||||
$numberKeys = array('INT', 'TINYINT', 'BIGINT', 'FLOAT', 'DECIMAL', 'DOUBLE');
|
||||
// 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 (!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';
|
||||
}
|
||||
@ -2749,10 +2762,7 @@ class Fields extends Structure
|
||||
$field['settings']->datadefault = '0';
|
||||
}
|
||||
}
|
||||
// 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 not text
|
||||
if (!in_array($field['settings']->datatype, $textKeys))
|
||||
{
|
||||
$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]['other'] = $field['settings']->datadefault_other;
|
||||
}
|
||||
// fall back unto EMPTY for text
|
||||
else
|
||||
{
|
||||
$this->queryBuilder[$view_name_single][$name]['default'] = 'EMPTY';
|
||||
|
@ -1637,10 +1637,10 @@ class Interpretation extends Fields
|
||||
{
|
||||
// to insure that there be no double entries of a call
|
||||
$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
|
||||
$this->customViewQueryChecker[$this->target][] = $checker;
|
||||
$this->customViewQueryChecker[$this->target][$checker] = true;
|
||||
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'];
|
||||
@ -1673,7 +1673,9 @@ class Interpretation extends Fields
|
||||
// set the method defaults
|
||||
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
|
||||
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
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user