Skip to content

Commit

Permalink
Merge pull request #144 from skipperbent/v4-fix-join-statements
Browse files Browse the repository at this point in the history
Fixed raw bindings not for join + generally optimized raw-bindings.
  • Loading branch information
skipperbent authored Jun 13, 2021
2 parents 77ff953 + b247436 commit 15a0990
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
C:37:"PHPUnit\Runner\DefaultTestResultCache":4437:{a:2:{s:7:"defects";a:0:{}s:5:"times";a:66:{s:42:"Pecee\Pixie\ConnectionTest::testConnection";d:0.059;s:47:"Pecee\Pixie\ConnectionTest::testMultiConnection";d:0.001;s:57:"Pecee\Pixie\CustomExceptionsTest::testConnectionException";d:0.121;s:60:"Pecee\Pixie\CustomExceptionsTest::testTableNotFoundException";d:0.467;s:61:"Pecee\Pixie\CustomExceptionsTest::testColumnNotFoundException";d:0.053;s:61:"Pecee\Pixie\CustomExceptionsTest::testDuplicateEntryException";d:0.052;s:75:"Pecee\Pixie\CustomExceptionsTest::testQueryAggregateColumnNotFoundException";d:0.048;s:57:"Pecee\Pixie\CustomExceptionsTest::testForeignKeyException";d:0.044;s:54:"Pecee\Pixie\CustomExceptionsTest::testNotNullException";d:0.041;s:45:"Pecee\Pixie\NoTableSubQueryTest::testRawQuery";d:0.001;s:53:"Pecee\Pixie\QueryBuilderAggregateTest::testQueryCount";d:0.039;s:59:"Pecee\Pixie\QueryBuilderAggregateTest::testSqliteQueryCount";d:0.001;s:51:"Pecee\Pixie\QueryBuilderAggregateTest::testQuerySum";d:0.041;s:57:"Pecee\Pixie\QueryBuilderAggregateTest::testSqliteQuerySum";d:0.001;s:55:"Pecee\Pixie\QueryBuilderAggregateTest::testQueryAverage";d:0.039;s:61:"Pecee\Pixie\QueryBuilderAggregateTest::testSqliteQueryAverage";d:0.002;s:39:"Pecee\Pixie\QueryBuilderTest::testAlias";d:0.001;s:45:"Pecee\Pixie\QueryBuilderTest::testDeleteQuery";d:0.001;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;s:58:"Pecee\Pixie\QueryBuilderTest::testRawStatementWithinSelect";d:0.001;s:56:"Pecee\Pixie\QueryBuilderTest::testRawStatementWithinJoin";d:0.001;s:47:"Pecee\Pixie\QueryBuilderTest::testRawExpression";d:0.001;s:46:"Pecee\Pixie\QueryBuilderTest::testReplaceQuery";d:0.001;s:47:"Pecee\Pixie\QueryBuilderTest::testSelectAliases";d:0.001;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;s:52:"Pecee\Pixie\QueryBuilderTest::testStandaloneWhereNot";d:0;s:45:"Pecee\Pixie\QueryBuilderTest::testUpdateQuery";d:0;s:53:"Pecee\Pixie\QueryBuilderTest::testDeleteAdvancedQuery";d:0;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: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.001;s:40:"Pecee\Pixie\QueryBuilder::testGetColumns";d:0.001;s:42:"Pecee\Pixie\QueryBuilder::testQueryPartFor";d:0;s:41:"Pecee\Pixie\QueryBuilder::testRemoveQuery";d:0.001;s:50:"Pecee\Pixie\TransactionTest::testTransactionResult";d:0.044;s:51:"Pecee\Pixie\TransactionTest::testNestedTransactions";d:0.049;s:58:"Pecee\Pixie\TransactionTest::testTransactionMultipleInsert";d:0.039;s:42:"Pecee\Pixie\TransactionTest::testLastQuery";d:0.041;}}}
C:37:"PHPUnit\Runner\DefaultTestResultCache":5748:{a:2:{s:7:"defects";a:21:{s:45:"Pecee\Pixie\QueryBuilderTest::testSelectQuery";i:3;s:71:"Pecee\Pixie\QueryBuilderTest::testSelectQueryWithNestedCriteriaAndJoins";i:3;s:53:"Pecee\Pixie\QueryBuilderTest::testUpdateAdvancedQuery";i:3;s:43:"Pecee\Pixie\QueryBuilderTest::testJoinUsing";i:3;s:55:"Pecee\Pixie\QueryBuilderTest::testJoinQueryBuilderUsing";i:3;s:53:"Pecee\Pixie\QueryBuilderTest::testDeleteAdvancedQuery";i:3;s:56:"Pecee\Pixie\QueryBuilderTest::testRawStatementWithinJoin";i:3;s:61:"Pecee\Pixie\QueryBuilderTest::testRawStatementsWithinCriteria";i:3;s:39:"Pecee\Pixie\QueryBuilderTest::testAlias";i:3;s:70:"Pecee\Pixie\QueryBuilderTest::testIsPossibleToUseSubqueryInWhereClause";i:3;s:73:"Pecee\Pixie\QueryBuilderTest::testIsPossibleToUseSubqueryInWhereNotClause";i:3;s:53:"Pecee\Pixie\QueryBuilderTest::testSelectQueryWithNull";i:3;s:55:"Pecee\Pixie\QueryBuilderTest::testSelectWithQueryEvents";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:47:"Pecee\Pixie\QueryBuilderTest::testRawExpression";i:3;s:54:"Pecee\Pixie\QueryBuilderTest::testWhereNotNullSubQuery";i:3;}s:5:"times";a:66:{s:42:"Pecee\Pixie\ConnectionTest::testConnection";d:0.022;s:47:"Pecee\Pixie\ConnectionTest::testMultiConnection";d:0.001;s:57:"Pecee\Pixie\CustomExceptionsTest::testConnectionException";d:0.003;s:60:"Pecee\Pixie\CustomExceptionsTest::testTableNotFoundException";d:0.063;s:61:"Pecee\Pixie\CustomExceptionsTest::testColumnNotFoundException";d:0.069;s:61:"Pecee\Pixie\CustomExceptionsTest::testDuplicateEntryException";d:0.062;s:75:"Pecee\Pixie\CustomExceptionsTest::testQueryAggregateColumnNotFoundException";d:0.062;s:57:"Pecee\Pixie\CustomExceptionsTest::testForeignKeyException";d:0.066;s:54:"Pecee\Pixie\CustomExceptionsTest::testNotNullException";d:0.065;s:45:"Pecee\Pixie\NoTableSubQueryTest::testRawQuery";d:0.001;s:53:"Pecee\Pixie\QueryBuilderAggregateTest::testQueryCount";d:0.151;s:59:"Pecee\Pixie\QueryBuilderAggregateTest::testSqliteQueryCount";d:0.002;s:51:"Pecee\Pixie\QueryBuilderAggregateTest::testQuerySum";d:0.061;s:57:"Pecee\Pixie\QueryBuilderAggregateTest::testSqliteQuerySum";d:0.002;s:55:"Pecee\Pixie\QueryBuilderAggregateTest::testQueryAverage";d:0.061;s:61:"Pecee\Pixie\QueryBuilderAggregateTest::testSqliteQueryAverage";d:0.002;s:39:"Pecee\Pixie\QueryBuilderTest::testAlias";d:0.001;s:45:"Pecee\Pixie\QueryBuilderTest::testDeleteQuery";d:0.001;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;s:56:"Pecee\Pixie\QueryBuilderTest::testRawStatementWithinJoin";d:0.001;s:47:"Pecee\Pixie\QueryBuilderTest::testRawExpression";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;s:52:"Pecee\Pixie\QueryBuilderTest::testStandaloneWhereNot";d:0;s:45:"Pecee\Pixie\QueryBuilderTest::testUpdateQuery";d:0;s:53:"Pecee\Pixie\QueryBuilderTest::testDeleteAdvancedQuery";d:0;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: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.001;s:41:"Pecee\Pixie\QueryBuilder::testRemoveQuery";d:0.001;s:50:"Pecee\Pixie\TransactionTest::testTransactionResult";d:0.07;s:51:"Pecee\Pixie\TransactionTest::testNestedTransactions";d:0.069;s:58:"Pecee\Pixie\TransactionTest::testTransactionMultipleInsert";d:0.075;s:42:"Pecee\Pixie\TransactionTest::testLastQuery";d:0.07;}}}
9 changes: 7 additions & 2 deletions src/Pecee/Pixie/QueryBuilder/Adapters/BaseAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ protected function buildCriteria(array $statements, bool $bindValues = true): ar
if (is_string($key) && $this->aliasPrefix !== null && strpos($key, '.') === false) {
$key = $this->aliasPrefix . '.' . $key;
}
} else {
$bindings[] = $key->getBindings();
}

$value = $statement['value'];
Expand Down Expand Up @@ -239,7 +241,6 @@ protected function buildCriteria(array $statements, bool $bindValues = true): ar
}

$criteria[] = $key;
$bindings[] = $key->getBindings();
continue;

}
Expand Down Expand Up @@ -303,6 +304,8 @@ protected function buildJoin(array $statements, array &$bindings): string
{
$sql = '';

$newBindings = [];

if (isset($statements['joins']) === false) {
return $sql;
}
Expand All @@ -323,7 +326,7 @@ protected function buildJoin(array $statements, array &$bindings): string
if ($joinBuilder instanceof QueryBuilderHandler) {
$valueQuery = $joinBuilder->getQuery('criteriaOnly', false);
$valueSql = $valueQuery->getSql();
$bindings += $valueQuery->getBindings();
$newBindings[] = $valueQuery->getBindings();
}

$sqlArr = [
Expand All @@ -337,6 +340,8 @@ protected function buildJoin(array $statements, array &$bindings): string
$sql = $this->concatenateQuery($sqlArr);
}

$bindings = array_merge($bindings, ...$newBindings);

return $sql;
}

Expand Down

0 comments on commit 15a0990

Please sign in to comment.