Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
d6992ae0
Unverified
Commit
d6992ae0
authored
Jan 19, 2020
by
Sergei Morozov
Committed by
GitHub
Jan 19, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3832 from BenMorel/join-no-on
Fix JOIN with no condition bug
parents
e5d1edc2
22b5494f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
4 deletions
+17
-4
QueryBuilder.php
lib/Doctrine/DBAL/Query/QueryBuilder.php
+5
-3
QueryBuilderTest.php
tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
+12
-1
No files found.
lib/Doctrine/DBAL/Query/QueryBuilder.php
View file @
d6992ae0
...
@@ -1327,9 +1327,11 @@ class QueryBuilder
...
@@ -1327,9 +1327,11 @@ class QueryBuilder
if
(
array_key_exists
(
$join
[
'joinAlias'
],
$knownAliases
))
{
if
(
array_key_exists
(
$join
[
'joinAlias'
],
$knownAliases
))
{
throw
QueryException
::
nonUniqueAlias
(
$join
[
'joinAlias'
],
array_keys
(
$knownAliases
));
throw
QueryException
::
nonUniqueAlias
(
$join
[
'joinAlias'
],
array_keys
(
$knownAliases
));
}
}
$sql
.=
' '
.
strtoupper
(
$join
[
'joinType'
])
$sql
.=
' '
.
strtoupper
(
$join
[
'joinType'
])
.
' JOIN '
.
$join
[
'joinTable'
]
.
' '
.
$join
[
'joinAlias'
]
.
' JOIN '
.
$join
[
'joinTable'
]
.
' '
.
$join
[
'joinAlias'
];
.
' ON '
.
((
string
)
$join
[
'joinCondition'
]);
if
(
$join
[
'joinCondition'
]
!==
null
)
{
$sql
.=
' ON '
.
$join
[
'joinCondition'
];
}
$knownAliases
[
$join
[
'joinAlias'
]]
=
true
;
$knownAliases
[
$join
[
'joinAlias'
]]
=
true
;
}
}
...
...
tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
View file @
d6992ae0
...
@@ -92,11 +92,22 @@ class QueryBuilderTest extends DbalTestCase
...
@@ -92,11 +92,22 @@ class QueryBuilderTest extends DbalTestCase
$qb
->
select
(
'u.*'
,
'p.*'
)
$qb
->
select
(
'u.*'
,
'p.*'
)
->
from
(
'users'
,
'u'
)
->
from
(
'users'
,
'u'
)
->
J
oin
(
'u'
,
'phones'
,
'p'
,
$expr
->
eq
(
'p.user_id'
,
'u.id'
));
->
j
oin
(
'u'
,
'phones'
,
'p'
,
$expr
->
eq
(
'p.user_id'
,
'u.id'
));
self
::
assertEquals
(
'SELECT u.*, p.* FROM users u INNER JOIN phones p ON p.user_id = u.id'
,
(
string
)
$qb
);
self
::
assertEquals
(
'SELECT u.*, p.* FROM users u INNER JOIN phones p ON p.user_id = u.id'
,
(
string
)
$qb
);
}
}
public
function
testSelectWithJoinNoCondition
()
:
void
{
$qb
=
new
QueryBuilder
(
$this
->
conn
);
$qb
->
select
(
'u.*'
,
'p.*'
)
->
from
(
'users'
,
'u'
)
->
join
(
'u'
,
'phones'
,
'p'
);
self
::
assertEquals
(
'SELECT u.*, p.* FROM users u INNER JOIN phones p'
,
(
string
)
$qb
);
}
public
function
testSelectWithInnerJoin
()
:
void
public
function
testSelectWithInnerJoin
()
:
void
{
{
$qb
=
new
QueryBuilder
(
$this
->
conn
);
$qb
=
new
QueryBuilder
(
$this
->
conn
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment