diff --git a/.phpunit.result.cache b/.phpunit.result.cache index e6f1c3e..08e6d59 100644 --- a/.phpunit.result.cache +++ b/.phpunit.result.cache @@ -1 +1 @@ -C:37:"PHPUnit\Runner\DefaultTestResultCache":7432:{a:2:{s:7:"defects";a:47:{s:39:"Pecee\Pixie\QueryBuilderTest::testAlias";i:4;s:45:"Pecee\Pixie\QueryBuilderTest::testDeleteQuery";i:4;s:50:"Pecee\Pixie\QueryBuilderTest::testEventPropagation";i:4;s:51:"Pecee\Pixie\QueryBuilderTest::testInsertIgnoreQuery";i:4;s:65:"Pecee\Pixie\QueryBuilderTest::testInsertOnDuplicateKeyUpdateQuery";i:4;s:45:"Pecee\Pixie\QueryBuilderTest::testInsertQuery";i:4;s:70:"Pecee\Pixie\QueryBuilderTest::testIsPossibleToUseSubqueryInWhereClause";i:4;s:73:"Pecee\Pixie\QueryBuilderTest::testIsPossibleToUseSubqueryInWhereNotClause";i:4;s:52:"Pecee\Pixie\QueryBuilderTest::testOrderByFlexibility";i:4;s:61:"Pecee\Pixie\QueryBuilderTest::testRawStatementsWithinCriteria";i:4;s:61:"Pecee\Pixie\QueryBuilderTest::testRawStatementWithinStatement";i:4;s:58:"Pecee\Pixie\QueryBuilderTest::testRawStatementWithinSelect";i:3;s:46:"Pecee\Pixie\QueryBuilderTest::testReplaceQuery";i:4;s:47:"Pecee\Pixie\QueryBuilderTest::testSelectAliases";i:4;s:48:"Pecee\Pixie\QueryBuilderTest::testSelectDistinct";i:4;s:62:"Pecee\Pixie\QueryBuilderTest::testSelectDistinctAndSelectCalls";i:4;s:64:"Pecee\Pixie\QueryBuilderTest::testSelectDistinctWithSingleColumn";i:4;s:51:"Pecee\Pixie\QueryBuilderTest::testSelectFlexibility";i:4;s:45:"Pecee\Pixie\QueryBuilderTest::testSelectQuery";i:3;s:71:"Pecee\Pixie\QueryBuilderTest::testSelectQueryWithNestedCriteriaAndJoins";i:4;s:53:"Pecee\Pixie\QueryBuilderTest::testSelectQueryWithNull";i:4;s:55:"Pecee\Pixie\QueryBuilderTest::testSelectWithQueryEvents";i:4;s:52:"Pecee\Pixie\QueryBuilderTest::testStandaloneWhereNot";i:4;s:45:"Pecee\Pixie\QueryBuilderTest::testUpdateQuery";i:4;s:53:"Pecee\Pixie\QueryBuilderTest::testDeleteAdvancedQuery";i:4;s:53:"Pecee\Pixie\QueryBuilderTest::testUpdateAdvancedQuery";i:4;s:46:"Pecee\Pixie\QueryBuilderTest::testFromSubQuery";i:4;s:44:"Pecee\Pixie\QueryBuilderTest::testTableAlias";i:4;s:54:"Pecee\Pixie\QueryBuilderTest::testWhereNotNullSubQuery";i:4;s:43:"Pecee\Pixie\QueryBuilderTest::testJoinUsing";i:4;s:55:"Pecee\Pixie\QueryBuilderTest::testJoinQueryBuilderUsing";i:4;s:60:"Pecee\Pixie\CustomExceptionsTest::testTableNotFoundException";i:4;s:61:"Pecee\Pixie\CustomExceptionsTest::testColumnNotFoundException";i:4;s:61:"Pecee\Pixie\CustomExceptionsTest::testDuplicateEntryException";i:4;s:75:"Pecee\Pixie\CustomExceptionsTest::testQueryAggregateColumnNotFoundException";i:4;s:57:"Pecee\Pixie\CustomExceptionsTest::testForeignKeyException";i:4;s:54:"Pecee\Pixie\CustomExceptionsTest::testNotNullException";i:4;s:53:"Pecee\Pixie\QueryBuilderAggregateTest::testQueryCount";i:4;s:59:"Pecee\Pixie\QueryBuilderAggregateTest::testSqliteQueryCount";i:4;s:51:"Pecee\Pixie\QueryBuilderAggregateTest::testQuerySum";i:4;s:57:"Pecee\Pixie\QueryBuilderAggregateTest::testSqliteQuerySum";i:4;s:55:"Pecee\Pixie\QueryBuilderAggregateTest::testQueryAverage";i:4;s:61:"Pecee\Pixie\QueryBuilderAggregateTest::testSqliteQueryAverage";i:4;s:50:"Pecee\Pixie\TransactionTest::testTransactionResult";i:4;s:51:"Pecee\Pixie\TransactionTest::testNestedTransactions";i:4;s:58:"Pecee\Pixie\TransactionTest::testTransactionMultipleInsert";i:4;s:42:"Pecee\Pixie\TransactionTest::testLastQuery";i:4;}s:5:"times";a:64:{s:39:"Pecee\Pixie\QueryBuilderTest::testAlias";d:0.001;s:45:"Pecee\Pixie\QueryBuilderTest::testDeleteQuery";d:0;s:50:"Pecee\Pixie\QueryBuilderTest::testEventPropagation";d:0.001;s:51:"Pecee\Pixie\QueryBuilderTest::testInsertIgnoreQuery";d:0;s:65:"Pecee\Pixie\QueryBuilderTest::testInsertOnDuplicateKeyUpdateQuery";d:0;s:45:"Pecee\Pixie\QueryBuilderTest::testInsertQuery";d:0;s:70:"Pecee\Pixie\QueryBuilderTest::testIsPossibleToUseSubqueryInWhereClause";d:0;s:73:"Pecee\Pixie\QueryBuilderTest::testIsPossibleToUseSubqueryInWhereNotClause";d:0;s:52:"Pecee\Pixie\QueryBuilderTest::testOrderByFlexibility";d:0;s:61:"Pecee\Pixie\QueryBuilderTest::testRawStatementsWithinCriteria";d:0;s:61:"Pecee\Pixie\QueryBuilderTest::testRawStatementWithinStatement";d:0.001;s:58:"Pecee\Pixie\QueryBuilderTest::testRawStatementWithinSelect";d:0;s:46:"Pecee\Pixie\QueryBuilderTest::testReplaceQuery";d:0;s:47:"Pecee\Pixie\QueryBuilderTest::testSelectAliases";d:0;s:48:"Pecee\Pixie\QueryBuilderTest::testSelectDistinct";d:0;s:62:"Pecee\Pixie\QueryBuilderTest::testSelectDistinctAndSelectCalls";d:0;s:64:"Pecee\Pixie\QueryBuilderTest::testSelectDistinctWithSingleColumn";d:0;s:51:"Pecee\Pixie\QueryBuilderTest::testSelectFlexibility";d:0;s:45:"Pecee\Pixie\QueryBuilderTest::testSelectQuery";d:0.001;s:71:"Pecee\Pixie\QueryBuilderTest::testSelectQueryWithNestedCriteriaAndJoins";d:0.001;s:53:"Pecee\Pixie\QueryBuilderTest::testSelectQueryWithNull";d:0;s:55:"Pecee\Pixie\QueryBuilderTest::testSelectWithQueryEvents";d:0.001;s:52:"Pecee\Pixie\QueryBuilderTest::testStandaloneWhereNot";d:0;s:45:"Pecee\Pixie\QueryBuilderTest::testUpdateQuery";d:0.001;s:53:"Pecee\Pixie\QueryBuilderTest::testDeleteAdvancedQuery";d:0;s:53:"Pecee\Pixie\QueryBuilderTest::testUpdateAdvancedQuery";d:0.001;s:46:"Pecee\Pixie\QueryBuilderTest::testFromSubQuery";d:0;s:44:"Pecee\Pixie\QueryBuilderTest::testTableAlias";d:0;s:54:"Pecee\Pixie\QueryBuilderTest::testWhereNotNullSubQuery";d:0;s:43:"Pecee\Pixie\QueryBuilderTest::testJoinUsing";d:0;s:55:"Pecee\Pixie\QueryBuilderTest::testJoinQueryBuilderUsing";d:0;s:42:"Pecee\Pixie\ConnectionTest::testConnection";d:0.051;s:47:"Pecee\Pixie\ConnectionTest::testMultiConnection";d:0.001;s:57:"Pecee\Pixie\CustomExceptionsTest::testConnectionException";d:0.005;s:60:"Pecee\Pixie\CustomExceptionsTest::testTableNotFoundException";d:0.053;s:61:"Pecee\Pixie\CustomExceptionsTest::testColumnNotFoundException";d:0.056;s:61:"Pecee\Pixie\CustomExceptionsTest::testDuplicateEntryException";d:0.051;s:75:"Pecee\Pixie\CustomExceptionsTest::testQueryAggregateColumnNotFoundException";d:0.048;s:57:"Pecee\Pixie\CustomExceptionsTest::testForeignKeyException";d:0.047;s:54:"Pecee\Pixie\CustomExceptionsTest::testNotNullException";d:0.04;s:45:"Pecee\Pixie\NoTableSubQueryTest::testRawQuery";d:0.001;s:53:"Pecee\Pixie\QueryBuilderAggregateTest::testQueryCount";d:0.037;s:59:"Pecee\Pixie\QueryBuilderAggregateTest::testSqliteQueryCount";d:0.002;s:51:"Pecee\Pixie\QueryBuilderAggregateTest::testQuerySum";d:0.038;s:57:"Pecee\Pixie\QueryBuilderAggregateTest::testSqliteQuerySum";d:0.002;s:55:"Pecee\Pixie\QueryBuilderAggregateTest::testQueryAverage";d:0.041;s:61:"Pecee\Pixie\QueryBuilderAggregateTest::testSqliteQueryAverage";d:0.001;s:44:"Pecee\Pixie\QueryBuilder::testFalseBoolWhere";d:0;s:59:"Pecee\Pixie\QueryBuilder::testInsertQueryReturnsIdForInsert";d:0.002;s:65:"Pecee\Pixie\QueryBuilder::testInsertQueryReturnsIdForInsertIgnore";d:0;s:68:"Pecee\Pixie\QueryBuilder::testInsertQueryReturnsNullForIgnoredInsert";d:0;s:38:"Pecee\Pixie\QueryBuilder::testRawQuery";d:0;s:43:"Pecee\Pixie\QueryBuilder::testNullableWhere";d:0;s:42:"Pecee\Pixie\QueryBuilder::testWhereBetween";d:0;s:35:"Pecee\Pixie\QueryBuilder::testUnion";d:0.001;s:43:"Pecee\Pixie\QueryBuilder::testUnionSubQuery";d:0;s:44:"Pecee\Pixie\QueryBuilder::testQueryOverwrite";d:0.001;s:40:"Pecee\Pixie\QueryBuilder::testGetColumns";d:0.001;s:42:"Pecee\Pixie\QueryBuilder::testQueryPartFor";d:0.001;s:41:"Pecee\Pixie\QueryBuilder::testRemoveQuery";d:0.001;s:50:"Pecee\Pixie\TransactionTest::testTransactionResult";d:0.043;s:51:"Pecee\Pixie\TransactionTest::testNestedTransactions";d:0.051;s:58:"Pecee\Pixie\TransactionTest::testTransactionMultipleInsert";d:0.046;s:42:"Pecee\Pixie\TransactionTest::testLastQuery";d:0.042;}}} \ No newline at end of file +C:37:"PHPUnit\Runner\DefaultTestResultCache":7914:{a:2:{s:7:"defects";a:55:{s:39:"Pecee\Pixie\QueryBuilderTest::testAlias";i:3;s:45:"Pecee\Pixie\QueryBuilderTest::testDeleteQuery";i:3;s:50:"Pecee\Pixie\QueryBuilderTest::testEventPropagation";i:4;s:51:"Pecee\Pixie\QueryBuilderTest::testInsertIgnoreQuery";i:4;s:65:"Pecee\Pixie\QueryBuilderTest::testInsertOnDuplicateKeyUpdateQuery";i:4;s:45:"Pecee\Pixie\QueryBuilderTest::testInsertQuery";i:4;s:70:"Pecee\Pixie\QueryBuilderTest::testIsPossibleToUseSubqueryInWhereClause";i:3;s:73:"Pecee\Pixie\QueryBuilderTest::testIsPossibleToUseSubqueryInWhereNotClause";i:3;s:52:"Pecee\Pixie\QueryBuilderTest::testOrderByFlexibility";i:4;s:61:"Pecee\Pixie\QueryBuilderTest::testRawStatementsWithinCriteria";i:3;s:61:"Pecee\Pixie\QueryBuilderTest::testRawStatementWithinStatement";i:3;s:58:"Pecee\Pixie\QueryBuilderTest::testRawStatementWithinSelect";i:3;s:46:"Pecee\Pixie\QueryBuilderTest::testReplaceQuery";i:4;s:47:"Pecee\Pixie\QueryBuilderTest::testSelectAliases";i:4;s:48:"Pecee\Pixie\QueryBuilderTest::testSelectDistinct";i:4;s:62:"Pecee\Pixie\QueryBuilderTest::testSelectDistinctAndSelectCalls";i:4;s:64:"Pecee\Pixie\QueryBuilderTest::testSelectDistinctWithSingleColumn";i:4;s:51:"Pecee\Pixie\QueryBuilderTest::testSelectFlexibility";i:4;s:45:"Pecee\Pixie\QueryBuilderTest::testSelectQuery";i:3;s:71:"Pecee\Pixie\QueryBuilderTest::testSelectQueryWithNestedCriteriaAndJoins";i:3;s:53:"Pecee\Pixie\QueryBuilderTest::testSelectQueryWithNull";i:3;s:55:"Pecee\Pixie\QueryBuilderTest::testSelectWithQueryEvents";i:3;s:52:"Pecee\Pixie\QueryBuilderTest::testStandaloneWhereNot";i:3;s:45:"Pecee\Pixie\QueryBuilderTest::testUpdateQuery";i:3;s:53:"Pecee\Pixie\QueryBuilderTest::testDeleteAdvancedQuery";i:3;s:53:"Pecee\Pixie\QueryBuilderTest::testUpdateAdvancedQuery";i:3;s:46:"Pecee\Pixie\QueryBuilderTest::testFromSubQuery";i:3;s:44:"Pecee\Pixie\QueryBuilderTest::testTableAlias";i:4;s:54:"Pecee\Pixie\QueryBuilderTest::testWhereNotNullSubQuery";i:4;s:43:"Pecee\Pixie\QueryBuilderTest::testJoinUsing";i:3;s:55:"Pecee\Pixie\QueryBuilderTest::testJoinQueryBuilderUsing";i:3;s:60:"Pecee\Pixie\CustomExceptionsTest::testTableNotFoundException";i:4;s:61:"Pecee\Pixie\CustomExceptionsTest::testColumnNotFoundException";i:4;s:61:"Pecee\Pixie\CustomExceptionsTest::testDuplicateEntryException";i:4;s:75:"Pecee\Pixie\CustomExceptionsTest::testQueryAggregateColumnNotFoundException";i:4;s:57:"Pecee\Pixie\CustomExceptionsTest::testForeignKeyException";i:4;s:54:"Pecee\Pixie\CustomExceptionsTest::testNotNullException";i:4;s:53:"Pecee\Pixie\QueryBuilderAggregateTest::testQueryCount";i:4;s:59:"Pecee\Pixie\QueryBuilderAggregateTest::testSqliteQueryCount";i:4;s:51:"Pecee\Pixie\QueryBuilderAggregateTest::testQuerySum";i:4;s:57:"Pecee\Pixie\QueryBuilderAggregateTest::testSqliteQuerySum";i:4;s:55:"Pecee\Pixie\QueryBuilderAggregateTest::testQueryAverage";i:4;s:61:"Pecee\Pixie\QueryBuilderAggregateTest::testSqliteQueryAverage";i:4;s:50:"Pecee\Pixie\TransactionTest::testTransactionResult";i:4;s:51:"Pecee\Pixie\TransactionTest::testNestedTransactions";i:4;s:58:"Pecee\Pixie\TransactionTest::testTransactionMultipleInsert";i:4;s:42:"Pecee\Pixie\TransactionTest::testLastQuery";i:3;s:47:"Pecee\Pixie\QueryBuilderTest::testRawExpression";i:3;s:44:"Pecee\Pixie\QueryBuilder::testFalseBoolWhere";i:3;s:43:"Pecee\Pixie\QueryBuilder::testNullableWhere";i:3;s:42:"Pecee\Pixie\QueryBuilder::testWhereBetween";i:3;s:35:"Pecee\Pixie\QueryBuilder::testUnion";i:3;s:43:"Pecee\Pixie\QueryBuilder::testUnionSubQuery";i:3;s:44:"Pecee\Pixie\QueryBuilder::testQueryOverwrite";i:3;s:41:"Pecee\Pixie\QueryBuilder::testRemoveQuery";i:3;}s:5:"times";a:65:{s:39:"Pecee\Pixie\QueryBuilderTest::testAlias";d:0.001;s:45:"Pecee\Pixie\QueryBuilderTest::testDeleteQuery";d:0;s:50:"Pecee\Pixie\QueryBuilderTest::testEventPropagation";d:0.001;s:51:"Pecee\Pixie\QueryBuilderTest::testInsertIgnoreQuery";d:0;s:65:"Pecee\Pixie\QueryBuilderTest::testInsertOnDuplicateKeyUpdateQuery";d:0;s:45:"Pecee\Pixie\QueryBuilderTest::testInsertQuery";d:0;s:70:"Pecee\Pixie\QueryBuilderTest::testIsPossibleToUseSubqueryInWhereClause";d:0;s:73:"Pecee\Pixie\QueryBuilderTest::testIsPossibleToUseSubqueryInWhereNotClause";d:0;s:52:"Pecee\Pixie\QueryBuilderTest::testOrderByFlexibility";d:0;s:61:"Pecee\Pixie\QueryBuilderTest::testRawStatementsWithinCriteria";d:0.001;s:61:"Pecee\Pixie\QueryBuilderTest::testRawStatementWithinStatement";d:0.001;s:58:"Pecee\Pixie\QueryBuilderTest::testRawStatementWithinSelect";d:0.001;s:46:"Pecee\Pixie\QueryBuilderTest::testReplaceQuery";d:0;s:47:"Pecee\Pixie\QueryBuilderTest::testSelectAliases";d:0;s:48:"Pecee\Pixie\QueryBuilderTest::testSelectDistinct";d:0;s:62:"Pecee\Pixie\QueryBuilderTest::testSelectDistinctAndSelectCalls";d:0.001;s:64:"Pecee\Pixie\QueryBuilderTest::testSelectDistinctWithSingleColumn";d:0;s:51:"Pecee\Pixie\QueryBuilderTest::testSelectFlexibility";d:0;s:45:"Pecee\Pixie\QueryBuilderTest::testSelectQuery";d:0.001;s:71:"Pecee\Pixie\QueryBuilderTest::testSelectQueryWithNestedCriteriaAndJoins";d:0.001;s:53:"Pecee\Pixie\QueryBuilderTest::testSelectQueryWithNull";d:0;s:55:"Pecee\Pixie\QueryBuilderTest::testSelectWithQueryEvents";d:0.001;s:52:"Pecee\Pixie\QueryBuilderTest::testStandaloneWhereNot";d:0;s:45:"Pecee\Pixie\QueryBuilderTest::testUpdateQuery";d:0;s:53:"Pecee\Pixie\QueryBuilderTest::testDeleteAdvancedQuery";d:0.001;s:53:"Pecee\Pixie\QueryBuilderTest::testUpdateAdvancedQuery";d:0;s:46:"Pecee\Pixie\QueryBuilderTest::testFromSubQuery";d:0;s:44:"Pecee\Pixie\QueryBuilderTest::testTableAlias";d:0;s:54:"Pecee\Pixie\QueryBuilderTest::testWhereNotNullSubQuery";d:0;s:43:"Pecee\Pixie\QueryBuilderTest::testJoinUsing";d:0;s:55:"Pecee\Pixie\QueryBuilderTest::testJoinQueryBuilderUsing";d:0;s:42:"Pecee\Pixie\ConnectionTest::testConnection";d:0.023;s:47:"Pecee\Pixie\ConnectionTest::testMultiConnection";d:0.001;s:57:"Pecee\Pixie\CustomExceptionsTest::testConnectionException";d:0.004;s:60:"Pecee\Pixie\CustomExceptionsTest::testTableNotFoundException";d:0.041;s:61:"Pecee\Pixie\CustomExceptionsTest::testColumnNotFoundException";d:0.043;s:61:"Pecee\Pixie\CustomExceptionsTest::testDuplicateEntryException";d:0.039;s:75:"Pecee\Pixie\CustomExceptionsTest::testQueryAggregateColumnNotFoundException";d:0.047;s:57:"Pecee\Pixie\CustomExceptionsTest::testForeignKeyException";d:0.045;s:54:"Pecee\Pixie\CustomExceptionsTest::testNotNullException";d:0.043;s:45:"Pecee\Pixie\NoTableSubQueryTest::testRawQuery";d:0.001;s:53:"Pecee\Pixie\QueryBuilderAggregateTest::testQueryCount";d:0.037;s:59:"Pecee\Pixie\QueryBuilderAggregateTest::testSqliteQueryCount";d:0.002;s:51:"Pecee\Pixie\QueryBuilderAggregateTest::testQuerySum";d:0.039;s:57:"Pecee\Pixie\QueryBuilderAggregateTest::testSqliteQuerySum";d:0.001;s:55:"Pecee\Pixie\QueryBuilderAggregateTest::testQueryAverage";d:0.04;s:61:"Pecee\Pixie\QueryBuilderAggregateTest::testSqliteQueryAverage";d:0.001;s:44:"Pecee\Pixie\QueryBuilder::testFalseBoolWhere";d:0;s:59:"Pecee\Pixie\QueryBuilder::testInsertQueryReturnsIdForInsert";d:0.001;s:65:"Pecee\Pixie\QueryBuilder::testInsertQueryReturnsIdForInsertIgnore";d:0;s:68:"Pecee\Pixie\QueryBuilder::testInsertQueryReturnsNullForIgnoredInsert";d:0;s:38:"Pecee\Pixie\QueryBuilder::testRawQuery";d:0;s:43:"Pecee\Pixie\QueryBuilder::testNullableWhere";d:0;s:42:"Pecee\Pixie\QueryBuilder::testWhereBetween";d:0;s:35:"Pecee\Pixie\QueryBuilder::testUnion";d:0;s:43:"Pecee\Pixie\QueryBuilder::testUnionSubQuery";d:0;s:44:"Pecee\Pixie\QueryBuilder::testQueryOverwrite";d:0;s:40:"Pecee\Pixie\QueryBuilder::testGetColumns";d:0;s:42:"Pecee\Pixie\QueryBuilder::testQueryPartFor";d:0;s:41:"Pecee\Pixie\QueryBuilder::testRemoveQuery";d:0;s:50:"Pecee\Pixie\TransactionTest::testTransactionResult";d:0.047;s:51:"Pecee\Pixie\TransactionTest::testNestedTransactions";d:0.048;s:58:"Pecee\Pixie\TransactionTest::testTransactionMultipleInsert";d:0.042;s:42:"Pecee\Pixie\TransactionTest::testLastQuery";d:0.039;s:47:"Pecee\Pixie\QueryBuilderTest::testRawExpression";d:0;}}} \ No newline at end of file diff --git a/src/Pecee/Pixie/QueryBuilder/Adapters/BaseAdapter.php b/src/Pecee/Pixie/QueryBuilder/Adapters/BaseAdapter.php index 1e40e3a..c694a91 100644 --- a/src/Pecee/Pixie/QueryBuilder/Adapters/BaseAdapter.php +++ b/src/Pecee/Pixie/QueryBuilder/Adapters/BaseAdapter.php @@ -154,11 +154,13 @@ protected function buildCriteria(array $statements, bool $bindValues = true): ar $key = $statement['key']; - $key = $this->wrapSanitizer($key); + if($key instanceof Raw === false) { + $key = $this->wrapSanitizer($key); - // Add alias non-existing - if(is_string($key) && $this->aliasPrefix !== null && strpos($key, '.') === false) { - $key = $this->aliasPrefix . '.' . $key; + // Add alias non-existing + if(is_string($key) && $this->aliasPrefix !== null && strpos($key, '.') === false) { + $key = $this->aliasPrefix . '.' . $key; + } } if ($statement['key'] instanceof Raw) { diff --git a/tests/Pecee/Pixie/QueryBuilderBehaviorTest.php b/tests/Pecee/Pixie/QueryBuilderBehaviorTest.php index 5cd105a..8d7ec5a 100644 --- a/tests/Pecee/Pixie/QueryBuilderBehaviorTest.php +++ b/tests/Pecee/Pixie/QueryBuilderBehaviorTest.php @@ -177,7 +177,7 @@ public function testRawStatementWithinStatement() { } public function testRawStatementWithinSelect() { - $query = $this->builder->from('my_table') + $this->builder->from('my_table') ->select($this->builder->raw('CONCAT(`simple`, ?)', ['criteria'])) ->where('simple', '=', 'criteria') ->first(); @@ -188,6 +188,17 @@ public function testRawStatementWithinSelect() { ); } + public function testRawExpression() { + $query = $this->builder + ->table('my_table') + ->alias('test') + ->select($this->builder->raw('count(cb_my_table.id) as tot')) + ->where('value', '=', 'Ifrah') + ->where($this->builder->raw('DATE(?)', 'now')); + + $this->assertEquals("SELECT count(cb_my_table.id) as tot FROM `cb_my_table` AS `test` WHERE test.`value` = 'Ifrah' AND DATE('now')", $query->getQuery()->getRawSql()); + } + public function testReplaceQuery() { $builder = $this->builder->from('my_table');