-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from flightphp/double-join-fix
fixed duplicated sql syntax if join called twice.
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,6 +183,32 @@ public function testJoin() | |
$this->assertEquals($user->address, $contact->address); | ||
} | ||
|
||
public function testJoinIsClearedAfterCalledTwice() | ||
{ | ||
$user = new User(new PDO('sqlite:test.db')); | ||
$user->name = 'demo'; | ||
$user->password = md5('demo'); | ||
$user->insert(); | ||
|
||
$contact = new Contact(new PDO('sqlite:test.db')); | ||
$contact->user_id = $user->id; | ||
$contact->email = '[email protected]'; | ||
$contact->address = 'test address'; | ||
$contact->insert(); | ||
|
||
$user->select('*, c.email, c.address')->join('contact as c', 'c.user_id = user.id')->find(); | ||
// email and address will stored in user data array. | ||
$this->assertEquals($user->id, $contact->user_id); | ||
$this->assertEquals($user->email, $contact->email); | ||
$this->assertEquals($user->address, $contact->address); | ||
|
||
$user->select('*, c.email, c.address')->join('contact as c', 'c.user_id = user.id')->find(); | ||
// email and address will stored in user data array. | ||
$this->assertEquals($user->id, $contact->user_id); | ||
$this->assertEquals($user->email, $contact->email); | ||
$this->assertEquals($user->address, $contact->address); | ||
} | ||
|
||
public function testQuery() | ||
{ | ||
$user = new class (new PDO('sqlite:test.db')) extends User { | ||
|