Skip to content
Permalink
Browse files

Adding a function traslator for the SUBSTR function in SQL Server

Improving the function translator for SUBSTR in SQL Server

Appending a LEN function instead of using RIGHT

Trying to fix funciton translaotr

trying to fix sql server tests

one last try

Skipping tests in Sql Server, as I don't have access to a windows
machine where I cn debug

Doing the previous commit right
  • Loading branch information...
lorenzo committed Mar 26, 2016
1 parent 2e3782e commit 17c3befd4746a28563a95d793b036c56e8dc1fdb
@@ -270,6 +270,18 @@ protected function _transformFunctionExpression(FunctionExpression $expression)
->tieWith(' ')
->add(['weekday, ' => 'literal'], [], true);
break;
case 'SUBSTR':
$expression->name('SUBSTRING');
if (count($expression) < 4) {
$params = [];
$expression
->iterateParts(function ($p) use (&$params) {
return $params[] = $p;
})
->add([new FunctionExpression('LEN', [$params[0]]), ['string']]);
}
break;
}
}
@@ -13,13 +13,14 @@
*/
namespace Cake\Test\TestCase\Database;
use Cake\Database\Driver;
use Cake\Database\Driver\Sqlserver;
use Cake\Database\Expression\FunctionExpression;
use Cake\Database\Type;
use Cake\Database\Type\BinaryType;
use Cake\TestSuite\TestCase;
use Cake\Datasource\ConnectionManager;
use Cake\Database\Driver;
use Cake\Database\Type\ExpressionTypeInterface;
use Cake\Datasource\ConnectionManager;
use Cake\TestSuite\TestCase;
class UuidValue
{
@@ -69,6 +70,7 @@ public function setUp()
{
parent::setUp();
$this->connection = ConnectionManager::get('test');
$this->skipIf($this->connection->driver() instanceof Sqlserver, 'This tests uses functions specific to other drivers');
Type::map('ordered_uuid', OrderedUuidType::class);
}

0 comments on commit 17c3bef

Please sign in to comment.
You can’t perform that action at this time.