Skip to content
Permalink
Browse files

Fixing some tests involving identifier quoting

  • Loading branch information...
lorenzo committed Jan 20, 2014
1 parent 5cad7fc commit 7af54147091a0868928e77d7152d00a6d5832598
Showing with 22 additions and 5 deletions.
  1. +2 −1 tests/TestCase/Database/ConnectionTest.php
  2. +20 −4 tests/TestCase/Database/QueryTest.php
@@ -124,7 +124,8 @@ public function testPrepare() {
$query = $this->connection->newQuery()->select('1 + 1');
$result = $this->connection->prepare($query);
$this->assertInstanceOf('Cake\Database\StatementInterface', $result);
$this->assertEquals($sql, $result->queryString);
$sql = '#SELECT [`"\[]?1 \+ 1[`"\]]?#';
$this->assertRegExp($sql, $result->queryString);
}
/**
@@ -1088,29 +1088,45 @@ public function testSelectModifiers() {
->select(['city', 'state', 'country'])
->from(['addresses'])
->modifier('DISTINCTROW');
$this->assertSame('SELECT DISTINCTROW city, state, country FROM addresses', $result->sql());
$this->assertQuotedQuery(
'SELECT DISTINCTROW <city>, <state>, <country> FROM <addresses>',
$result->sql(),
true
);
$query = new Query($this->connection);
$result = $query
->select(['city', 'state', 'country'])
->from(['addresses'])
->modifier(['DISTINCTROW', 'SQL_NO_CACHE']);
$this->assertSame('SELECT DISTINCTROW SQL_NO_CACHE city, state, country FROM addresses', $result->sql());
$this->assertQuotedQuery(
'SELECT DISTINCTROW SQL_NO_CACHE <city>, <state>, <country> FROM <addresses>',
$result->sql(),
true
);
$query = new Query($this->connection);
$result = $query
->select(['city', 'state', 'country'])
->from(['addresses'])
->modifier('DISTINCTROW')
->modifier('SQL_NO_CACHE');
$this->assertSame('SELECT DISTINCTROW SQL_NO_CACHE city, state, country FROM addresses', $result->sql());
$this->assertQuotedQuery(
'SELECT DISTINCTROW SQL_NO_CACHE <city>, <state>, <country> FROM <addresses>',
$result->sql(),
true
);
$query = new Query($this->connection);
$result = $query
->select(['city', 'state', 'country'])
->from(['addresses'])
->modifier(['TOP 10']);
$this->assertSame('SELECT TOP 10 city, state, country FROM addresses', $result->sql());
$this->assertQuotedQuery(
'SELECT TOP 10 <city>, <state>, <country> FROM <addresses>',
$result->sql(),
true
);
}
/**

1 comment on commit 7af5414

@jrbasso

This comment has been minimized.

Copy link
Member

jrbasso commented on 7af5414 Jan 20, 2014

@lorenzo Thanks.

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