Skip to content
Permalink
Browse files

Update the assertQuotedQuery tests to prove issue on table quoting in…

… update statements
  • Loading branch information...
HavokInspiration committed Jun 16, 2015
1 parent 6167d95 commit cef1adb97415b4d8e61b24c14047598e839cb01b
Showing with 28 additions and 28 deletions.
  1. +28 −28 tests/TestCase/Database/QueryTest.php
@@ -539,7 +539,7 @@ public function testSelectWhereUnary()
$this->assertQuotedQuery(
'SELECT <id> FROM <articles> WHERE \(\(<title>\) IS NOT NULL AND \(<user_id>\) IS NULL\)',
$result,
true
!$this->autoQuote
);
}
@@ -837,7 +837,7 @@ function ($exp) {
$this->assertQuotedQuery(
'SELECT <id> FROM <comments> WHERE \(<id> = :c0 OR <id> = :c1\)',
$result,
true
!$this->autoQuote
);
}
@@ -1545,7 +1545,7 @@ public function testSelectModifiers()
$this->assertQuotedQuery(
'SELECT DISTINCTROW <city>, <state>, <country> FROM <addresses>',
$result->sql(),
true
!$this->autoQuote
);
$query = new Query($this->connection);
@@ -1556,7 +1556,7 @@ public function testSelectModifiers()
$this->assertQuotedQuery(
'SELECT DISTINCTROW SQL_NO_CACHE <city>, <state>, <country> FROM <addresses>',
$result->sql(),
true
!$this->autoQuote
);
$query = new Query($this->connection);
@@ -1579,7 +1579,7 @@ public function testSelectModifiers()
$this->assertQuotedQuery(
'SELECT TOP 10 <city>, <state>, <country> FROM <addresses>',
$result->sql(),
true
!$this->autoQuote
);
}
@@ -2109,7 +2109,7 @@ public function testDeleteWithFrom()
->where('1 = 1');
$result = $query->sql();
$this->assertQuotedQuery('DELETE FROM <authors>', $result, true);
$this->assertQuotedQuery('DELETE FROM <authors>', $result, !$this->autoQuote);
$result = $query->execute();
$this->assertInstanceOf('Cake\Database\StatementInterface', $result);
@@ -2130,7 +2130,7 @@ public function testDeleteWithAliasedFrom()
->where(['a.id !=' => 99]);
$result = $query->sql();
$this->assertQuotedQuery('DELETE FROM <authors> WHERE <id> != :c0', $result, true);
$this->assertQuotedQuery('DELETE FROM <authors> WHERE <id> != :c0', $result, !$this->autoQuote);
$result = $query->execute();
$this->assertInstanceOf('Cake\Database\StatementInterface', $result);
@@ -2150,7 +2150,7 @@ public function testDeleteNoFrom()
->where('1 = 1');
$result = $query->sql();
$this->assertQuotedQuery('DELETE FROM <authors>', $result, true);
$this->assertQuotedQuery('DELETE FROM <authors>', $result, !$this->autoQuote);
$result = $query->execute();
$this->assertInstanceOf('Cake\Database\StatementInterface', $result);
@@ -2170,7 +2170,7 @@ public function testSelectAndDeleteOnSameQuery()
->where('1 = 1');
$result = $query->sql();
$this->assertQuotedQuery('DELETE FROM <authors>', $result, true);
$this->assertQuotedQuery('DELETE FROM <authors>', $result, !$this->autoQuote);
$this->assertContains(' WHERE 1 = 1', $result);
}
@@ -2186,7 +2186,7 @@ public function testUpdateSimple()
->set('name', 'mark')
->where(['id' => 1]);
$result = $query->sql();
$this->assertQuotedQuery('UPDATE <authors> SET <name> = :', $result, true);
$this->assertQuotedQuery('UPDATE <authors> SET <name> = :', $result, !$this->autoQuote);
$result = $query->execute();
$this->assertCount(1, $result);
@@ -2209,10 +2209,10 @@ public function testUpdateMultipleFields()
$this->assertQuotedQuery(
'UPDATE <articles> SET <title> = :c0 , <body> = :c1',
$result,
true
!$this->autoQuote
);
$this->assertQuotedQuery(' WHERE <id> = :c2$', $result, true);
$this->assertQuotedQuery(' WHERE <id> = :c2$', $result, !$this->autoQuote);
$result = $query->execute();
$this->assertCount(1, $result);
}
@@ -2236,9 +2236,9 @@ public function testUpdateMultipleFieldsArray()
$this->assertQuotedQuery(
'UPDATE <articles> SET <title> = :c0 , <body> = :c1',
$result,
true
!$this->autoQuote
);
$this->assertQuotedQuery('WHERE <id> = :', $result, true);
$this->assertQuotedQuery('WHERE <id> = :', $result, !$this->autoQuote);
$result = $query->execute();
$this->assertCount(1, $result);
@@ -2263,7 +2263,7 @@ public function testUpdateWithExpression()
$this->assertQuotedQuery(
'UPDATE <articles> SET title = author_id WHERE <id> = :',
$result,
true
!$this->autoQuote
);
$result = $query->execute();
@@ -2287,10 +2287,10 @@ public function testUpdateArrayFields()
$this->assertQuotedQuery(
'UPDATE <comments> SET <comment> = :c0 , <created> = :c1',
$result,
true
!$this->autoQuote
);
$this->assertQuotedQuery(' WHERE <id> = :c2$', $result, true);
$this->assertQuotedQuery(' WHERE <id> = :c2$', $result, !$this->autoQuote);
$result = $query->execute();
$this->assertCount(1, $result);
@@ -2310,10 +2310,10 @@ public function testInsertValuesBeforeInsertFailure()
{
$query = new Query($this->connection);
$query->select('*')->values([
'id' => 1,
'title' => 'mark',
'body' => 'test insert'
]);
'id' => 1,
'title' => 'mark',
'body' => 'test insert'
]);
}
/**
@@ -2348,7 +2348,7 @@ public function testInsertSimple()
'INSERT INTO <articles> \(<title>, <body>\) (OUTPUT INSERTED\.\* )?' .
'VALUES \(:c0, :c1\)',
$result,
true
!$this->autoQuote
);
$result = $query->execute();
@@ -2390,7 +2390,7 @@ public function testInsertSparseRow()
'INSERT INTO <articles> \(<title>, <body>\) (OUTPUT INSERTED\.\* )?' .
'VALUES \(:c0, :c1\)',
$result,
true
!$this->autoQuote
);
$result = $query->execute();
@@ -2480,12 +2480,12 @@ public function testInsertFromSelect()
$this->assertQuotedQuery(
'INSERT INTO <articles> \(<title>, <body>, <author_id>\) (OUTPUT INSERTED\.\* )?SELECT',
$result,
true
!$this->autoQuote
);
$this->assertQuotedQuery(
'SELECT <name>, \'some text\', 99 FROM <authors>',
$result,
true
!$this->autoQuote
);
$result = $query->execute();
$result->closeCursor();
@@ -2973,7 +2973,7 @@ public function testToString()
->select(['title'])
->from('articles');
$result = (string)$query;
$this->assertQuotedQuery('SELECT <title> FROM <articles>', $result, true);
$this->assertQuotedQuery('SELECT <title> FROM <articles>', $result, !$this->autoQuote);
}
/**
@@ -3083,7 +3083,7 @@ public function testDirectIsNull()
->from(['authors'])
->where(['name IS' => null])
->sql();
$this->assertQuotedQuery('WHERE \(<name>\) IS NULL', $sql, true);
$this->assertQuotedQuery('WHERE \(<name>\) IS NULL', $sql, !$this->autoQuote);
$results = (new Query($this->connection))
->select(['name'])
@@ -3107,7 +3107,7 @@ public function testDirectIsNotNull()
->from(['authors'])
->where(['name IS NOT' => null])
->sql();
$this->assertQuotedQuery('WHERE \(<name>\) IS NOT NULL', $sql, true);
$this->assertQuotedQuery('WHERE \(<name>\) IS NOT NULL', $sql, !$this->autoQuote);
$results = (new Query($this->connection))
->select(['name'])

0 comments on commit cef1adb

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