Skip to content

Commit

Permalink
add cascades for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul M. Jones committed May 30, 2018
1 parent dca81b9 commit 91b81c1
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/DataSource/Tag/TagRelationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class TagRelationships extends MapperRelationships
{
protected function define()
{
$this->oneToMany('taggings', Tagging::CLASS);
$this->oneToMany('taggings', Tagging::CLASS)
->onDeleteCascade();
}
}
4 changes: 2 additions & 2 deletions src/DataSource/Tagging/TaggingFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

/**
* @property mixed $tagging_id INTEGER
* @property mixed $thread_id INTEGER NOT NULL
* @property mixed $tag_id INTEGER NOT NULL
* @property mixed $thread_id INTEGER
* @property mixed $tag_id INTEGER
* @property null|false|\Atlas\Testing\DataSource\Thread\ThreadRecord $thread
* @property null|false|\Atlas\Testing\DataSource\Tag\TagRecord $tag
*/
Expand Down
4 changes: 2 additions & 2 deletions src/DataSource/Tagging/TaggingRow.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

/**
* @property mixed $tagging_id INTEGER
* @property mixed $thread_id INTEGER NOT NULL
* @property mixed $tag_id INTEGER NOT NULL
* @property mixed $thread_id INTEGER
* @property mixed $tag_id INTEGER
*/
class TaggingRow extends Row
{
Expand Down
4 changes: 2 additions & 2 deletions src/DataSource/Tagging/TaggingTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TaggingTable extends Table
'type' => 'INTEGER',
'size' => null,
'scale' => null,
'notnull' => true,
'notnull' => false,
'default' => null,
'autoinc' => false,
'primary' => false,
Expand All @@ -45,7 +45,7 @@ class TaggingTable extends Table
'type' => 'INTEGER',
'size' => null,
'scale' => null,
'notnull' => true,
'notnull' => false,
'default' => null,
'autoinc' => false,
'primary' => false,
Expand Down
12 changes: 9 additions & 3 deletions src/DataSource/Thread/ThreadRelationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ class ThreadRelationships extends MapperRelationships
protected function define()
{
$this->manyToOne('author', Author::CLASS);
$this->oneToOne('summary', Summary::CLASS);
$this->oneToMany('replies', Reply::CLASS);
$this->oneToMany('taggings', Tagging::CLASS);

$this->oneToOne('summary', Summary::CLASS)
->onDeleteInitDeleted();

$this->oneToMany('replies', Reply::CLASS)
->onDeleteSetDelete();

$this->oneToMany('taggings', Tagging::CLASS)
->onDeleteSetNull();
}
}
4 changes: 2 additions & 2 deletions src/DataSourceFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ protected function taggings()
{
$this->connection->query("CREATE TABLE taggings (
tagging_id INTEGER PRIMARY KEY AUTOINCREMENT,
thread_id INTEGER NOT NULL,
tag_id INTEGER NOT NULL
thread_id INTEGER,
tag_id INTEGER
)");

// add 3 tags to each thread except thread #3
Expand Down

0 comments on commit 91b81c1

Please sign in to comment.