Skip to content

Commit

Permalink
even more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
verfriemelt-dot-org committed Nov 22, 2024
1 parent 58daebb commit 55de6d8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 3 additions & 2 deletions _/DataModel/TreeDataModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ private function validateMove(TreeDataModel $moveTo)
}

if (
$moveTo->getLeft() > $this->left && $moveTo->getRight() < $this->right
isset($this->left) && isset($this->right)
&& $moveTo->getLeft() > $this->left && $moveTo->getRight() < $this->right
) {
throw new DatabaseException('cannot move model under itself');
}
Expand Down Expand Up @@ -225,7 +226,7 @@ protected function prepareDataForStorage(bool $includeNonFuzzy = false): array
foreach ((new DataModelAnalyser($this))->fetchProperties() as $attribute) {
// skip pk
if (static::getPrimaryKey() !== null && $attribute->getName() === static::getPrimaryKey(
) && $this->{static::getPrimaryKey()} === null) {
) && !isset($this->{static::getPrimaryKey()})) {
continue;
}

Expand Down
14 changes: 11 additions & 3 deletions tests/Integration/DataModel/DataModelAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,17 @@ public function setUp(): void

parent::setUp();

static::$connection->query('create table lowerdummy ( id integer primary key not null, complexfieldname text );');
static::$connection->query('create table "camelCaseDummy" ( id integer primary key not null, "complexFieldName" text );');
static::$connection->query('create table snake_case_dummy ( id integer primary key not null, complex_field_name text );');
if (static::$connection instanceof SQLite) {
static::$connection->query('create table lowerdummy ( id integer primary key not null, complexfieldname text );');
static::$connection->query('create table "camelCaseDummy" ( id integer primary key not null, "complexFieldName" text );');
static::$connection->query('create table snake_case_dummy ( id integer primary key not null, complex_field_name text );');
} else {
static::$connection->query('create table lowerdummy ( id serial primary key not null, complexfieldname text );');
static::$connection->query('create table "camelCaseDummy" ( id serial primary key not null, "complexFieldName" text );');
static::$connection->query('create table snake_case_dummy ( id serial primary key not null, complex_field_name text );');
}


}

#[Override]
Expand Down
3 changes: 2 additions & 1 deletion tests/Integration/DataModel/TreeDataModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ public function test_move(): void
],
]);


$c->move()->under($a)->save();
$this->validateStruct([
'a' => [
Expand Down Expand Up @@ -342,8 +343,8 @@ public function test_move(): void
$this->validateStruct([
'b' => [
'a' => [
'd' => [],
'c' => [],
'd' => [],
],
],
]);
Expand Down

0 comments on commit 55de6d8

Please sign in to comment.