Commit a5140e33 authored by Benjamin Morel's avatar Benjamin Morel

Introduce properties for SQL parts in QueryBuilder

parent 6d673d77
......@@ -5,10 +5,9 @@
1. The `select()`, `addSelect()`, `groupBy()` and `addGroupBy()` methods no longer accept an array of arguments. Pass each expression as an individual argument or expand an array of expressions using the `...` operator.
2. The `select()`, `addSelect()`, `groupBy()` and `addGroupBy()` methods no longer ignore the first argument if it's empty.
3. The `addSelect()` method can be no longer called without arguments.
## BC BREAK: `QueryBuilder::insert()`, `update()` and `delete()` signatures changed
These methods now require the `$table` parameter, and do not support aliases anymore.
4. The `insert()`, `update()` and `delete()` methods now require the `$table` parameter, and do not support aliases anymore.
5. The `add()`, `getQueryPart()`, `getQueryParts()`, `resetQueryPart()` and `resetQueryParts()` methods are removed.
6. For a `select()` query, the `getSQL()` method now throws an expression if no `SELECT` expressions have been provided.
## BC BREAK: `OCI8Statement::convertPositionalToNamedPlaceholders()` is removed.
......
This diff is collapsed.
......@@ -293,7 +293,7 @@ class QueryBuilderTest extends DbalTestCase
->from('users', 'u')
->orderBy('u.name');
self::assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC', (string) $qb);
self::assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name', (string) $qb);
}
public function testSelectAddOrderBy() : void
......@@ -305,7 +305,7 @@ class QueryBuilderTest extends DbalTestCase
->orderBy('u.name')
->addOrderBy('u.username', 'DESC');
self::assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC, u.username DESC', (string) $qb);
self::assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name, u.username DESC', (string) $qb);
}
public function testSelectAddAddOrderBy() : void
......@@ -317,7 +317,7 @@ class QueryBuilderTest extends DbalTestCase
->addOrderBy('u.name')
->addOrderBy('u.username', 'DESC');
self::assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC, u.username DESC', (string) $qb);
self::assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name, u.username DESC', (string) $qb);
}
public function testEmptySelect() : void
......@@ -327,6 +327,9 @@ class QueryBuilderTest extends DbalTestCase
self::assertSame($qb, $qb2);
self::assertEquals(QueryBuilder::SELECT, $qb->getType());
$this->expectException(QueryException::class);
$qb->getSQL();
}
public function testSelectAddSelect() : void
......@@ -506,28 +509,6 @@ class QueryBuilderTest extends DbalTestCase
self::assertEquals(10, $qb->getFirstResult());
}
public function testResetQueryPart() : void
{
$qb = new QueryBuilder($this->conn);
$qb->select('u.*')->from('users', 'u')->where('u.name = ?');
self::assertEquals('SELECT u.* FROM users u WHERE u.name = ?', (string) $qb);
$qb->resetQueryPart('where');
self::assertEquals('SELECT u.* FROM users u', (string) $qb);
}
public function testResetQueryParts() : void
{
$qb = new QueryBuilder($this->conn);
$qb->select('u.*')->from('users', 'u')->where('u.name = ?')->orderBy('u.name');
self::assertEquals('SELECT u.* FROM users u WHERE u.name = ? ORDER BY u.name ASC', (string) $qb);
$qb->resetQueryParts(['where', 'orderBy']);
self::assertEquals('SELECT u.* FROM users u', (string) $qb);
}
public function testCreateNamedParameter() : void
{
$qb = new QueryBuilder($this->conn);
......@@ -692,7 +673,6 @@ class QueryBuilderTest extends DbalTestCase
$qb->andWhere('u.id = 1');
self::assertNotSame($qb->getQueryParts(), $qb_clone->getQueryParts());
self::assertNotSame($qb->getParameters(), $qb_clone->getParameters());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment