Skip to content

Commit

Permalink
Fixing some tests involving identifier quoting
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jan 20, 2014
1 parent 5cad7fc commit 7af5414
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
3 changes: 2 additions & 1 deletion tests/TestCase/Database/ConnectionTest.php
Expand Up @@ -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);
}

/**
Expand Down
24 changes: 20 additions & 4 deletions tests/TestCase/Database/QueryTest.php
Expand Up @@ -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
);
}

/**
Expand Down

1 comment on commit 7af5414

@jrbasso
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lorenzo Thanks.

Please sign in to comment.