From 42bc4995a11ec58db19188f0cba10b458985cd1b Mon Sep 17 00:00:00 2001 From: "Evgeniy V. Kokovikhin" Date: Mon, 28 Nov 2011 11:35:40 +0400 Subject: [PATCH 1/5] + test for lazy incapsulant added --- test/misc/DAOTest.class.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/misc/DAOTest.class.php b/test/misc/DAOTest.class.php index 04c2680814..14f8dacb8a 100644 --- a/test/misc/DAOTest.class.php +++ b/test/misc/DAOTest.class.php @@ -826,6 +826,30 @@ public function testIpRangeProperty() $this->drop(); } + public function testLazy() + { + $this->create(); + + $parent = TestParentObject::create(); + $child = TestChildObject::create()->setParent($parent); + + $parent->dao()->add($parent); + + $child->dao()->add($child); + + $this->assertEquals( + $parent->getId(), + Criteria::create(TestChildObject::dao())-> + setProjection( + Projection::property('parent.id', 'parentId') + )-> + add(Expression::eq('id', $child->getId()))-> + getCustom('parentId') + ); + + $this->drop(); + } + protected function getSome() { for ($i = 1; $i < 3; ++$i) { From 5ae2e378252667e2a626b8d5fdefba4d216426d6 Mon Sep 17 00:00:00 2001 From: AlexeyDsov Date: Mon, 28 Nov 2011 21:08:26 +0400 Subject: [PATCH 2/5] fix BusinessObject::getLazyObjectId method --- meta/types/ObjectType.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/meta/types/ObjectType.class.php b/meta/types/ObjectType.class.php index a1995659f7..525c77f407 100644 --- a/meta/types/ObjectType.class.php +++ b/meta/types/ObjectType.class.php @@ -121,7 +121,9 @@ public function {$methodName}() public function {$methodName}Id() { - return \$this->{$name}Id; + return \$this->{$name} + ? \$this->{$name}->getId() + : \$this->{$name}Id; } EOT; From d25d80012a8fc4b8ae2efb4578bd9b81f8c93f42 Mon Sep 17 00:00:00 2001 From: "Evgeniy V. Kokovikhin" Date: Fri, 25 Nov 2011 12:45:08 +0400 Subject: [PATCH 3/5] wrong changes for me. ObjectId may be absent --- main/Base/LightMetaProperty.class.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/main/Base/LightMetaProperty.class.php b/main/Base/LightMetaProperty.class.php index e3a9225c54..933b49180f 100644 --- a/main/Base/LightMetaProperty.class.php +++ b/main/Base/LightMetaProperty.class.php @@ -360,14 +360,7 @@ public function fillQuery( return $query; $getter = $this->getter; - - if ( - $this->relationId - && $this->strategyId == FetchStrategy::LAZY - ) { - $getter = $getter.'Id'; - } - + $value = $object->{$getter}(); if ($this->type == 'binary') { From 487034aed4745e08b2518e66fd6ab0bd5a6b641e Mon Sep 17 00:00:00 2001 From: "Evgeniy V. Kokovikhin" Date: Tue, 29 Nov 2011 15:59:21 +0400 Subject: [PATCH 4/5] d25d80012a8fc4b8ae2efb4578bd9b81f8c93f42 rolled back --- main/Base/LightMetaProperty.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main/Base/LightMetaProperty.class.php b/main/Base/LightMetaProperty.class.php index 933b49180f..e3a9225c54 100644 --- a/main/Base/LightMetaProperty.class.php +++ b/main/Base/LightMetaProperty.class.php @@ -360,7 +360,14 @@ public function fillQuery( return $query; $getter = $this->getter; - + + if ( + $this->relationId + && $this->strategyId == FetchStrategy::LAZY + ) { + $getter = $getter.'Id'; + } + $value = $object->{$getter}(); if ($this->type == 'binary') { From fdf6e5f6530d83e8977b81c82d9b38fb0ccb14a1 Mon Sep 17 00:00:00 2001 From: "Evgeniy V. Kokovikhin" Date: Wed, 30 Nov 2011 11:34:00 +0400 Subject: [PATCH 5/5] + changelog --- doc/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/ChangeLog b/doc/ChangeLog index db1d37bac9..a3b3acd841 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,8 @@ +2011-11-21 Alexey S. Denisov, Evgeny V. Kokovikhin + + * meta/types/ObjectType.class.php, test/misc/DAOTest.class.php: changed logic + for getObjectId method of lazy encapsulant; test for lazy logic added + 2011-11-21 Evgeny V. Kokovikhin * core/DB/PostgresDialect.class.php, test/main/PostgresDialectTest.class.php: