Skip to content

Commit

Permalink
Revert "1:1 join save issue"
Browse files Browse the repository at this point in the history
This reverts commit 7162a41.
  • Loading branch information
DarkSide666 committed Dec 10, 2020
1 parent 7162a41 commit 9f888c0
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions tests/JoinSqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -599,38 +599,4 @@ public function testJoinHasOneHasMany()
['id' => 41, 'contact_id' => 10, 'address' => '[email protected]'],
], $m_u->ref('Email')->export());
}

public function testJoinOneOnOne()
{
$this->setDb([
'user' => [
10 => ['id' => 10, 'name' => 'John'],
20 => ['id' => 20, 'name' => 'Peter'],
], 'detail' => [
100 => ['id' => 100, 'user_id' => 10, 'notes' => 'first note'],
200 => ['id' => 200, 'user_id' => 20, 'notes' => 'second note'],
],
]);

$db = new Persistence\Sql($this->db->connection);
$m_user = new Model($db, 'user');
$m_user->addField('name');
$j = $m_user->join('detail', [
'master_field' => 'id',
'foreign_field' => 'user_id',
]);
$j->addField('notes');

// try load one record
$m = (clone $m_user)->tryLoad(20);
$this->assertTrue($m->loaded());
$this->assertEquals(['id' => 20, 'name' => 'Peter', 'notes' => 'second note'], $m->get());

// insert new record
$m = (clone $m_user)->save(['name' => 'Emily']);
var_export($this->getDb());



}
}

0 comments on commit 9f888c0

Please sign in to comment.