User tests: Successful: Unsuccessful:
as per comment on #18915 (comment)
JDatabaseQuery doesn't implement castAsInteger
implement castAsInteger()
like sql CAST('field' AS integer)
$query->select($query->castAsInteger('field'))
same Testing Instructions as #18915
implemented
JDatabaseQuery doesn't implement castAsInteger()
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries Postgresql MS SQL |
@wilsonge What I meant was - should there be some sort of unit test for a library method such as this? Do we need to test it in extremis as per my observation about matching int(11) values (does it truncate and missmatch in this circumstance?).
There is a unit test for caseAsChar - I've never looked at the unit tests for Joomla before so not sure where to start about creating a new one/extending the ones that are there
Unit tests are easy when you know how. I can do a skype/hangout or whatever and take you through if you have a free 15 minutes? Always good to spread the knowledge :)
castAsBigint()
with a new prcastAsInteger()
to the search plugin in this prLabels |
Added:
?
|
Category | Libraries Postgresql MS SQL | ⇒ | Libraries Postgresql MS SQL Front End Plugins |
Can we come up with a more general cast helper than just implementing castAsFoo
methods each time we need something?
Status | Pending | ⇒ | Information Required |
did you mean something like this ?
public function castAs($type, $value, $len = null, $scale = null)
{
switch ($type)
{
case 'CHAR':
if (!$len)
{
return $value;
}
else
{
return ' CAST(' . $value . ' AS CHAR(' . $len . '))';
}
break;
case 'INTEGER':
return ' ('. $value . ' + 0) ';
break;
case 'DECIMAL':
if ((!$len) && (!scale))
{
return $value;
}
else
{
return ' CAST(' . $value . ' AS DECIMAL(' . $len . ', ' . $scale . '))';
}
break;
case 'DATE':
//
case 'TIME':
//
case 'DATETIME':
//
}
}
Status | Information Required | ⇒ | Pending |
That looks nice.
Title |
|
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-08-03 10:09:54 |
Closed_By | ⇒ | alikon | |
Labels |
Removed:
J3 Issue
|
How do I test this? it works for mySQL and Postgres and is consistent with the documentation.
One thought though, if we use it to match int(11) ids then the cast should be to a 'bigint' in Postgres and MS SQL ??