Closed hotlabs closed 3 years ago
// skip empty results
if ($isnull)
{
if( ! $model['relation'])
{
continue;
}
change to // skip empty results if ($isnull) { continue;
query.php ~ 158 - 161 lines
Is this tested with the current HEAD of the 1.9/dev branch? There were quite a few changes last week.
@AdamSGit Mind looking at this? It is related to the code you added last week...
Sure thing.
bag in "fuel/orm": "dev-1.9/develop", this need fix this error on nested links ->related('genres') ->related('genres.translation') - two level relation this return empty object parent relation - [""]=> object(Model_Genre)
There are more issues with the code changes.
I've updated one of the apps we have in maintenance tonight, and it now crashes on the lastest ORM updates. It fetches a record with a few relations, 2 belongs_to and 1 has_many.
For some reason, 1 of the 2 belongs_to are correctly assigned, the second one ends up as an EAV value (so it is not detected as being a relation), which causes a crash on save, as EAV values must be scalar, and not an object.
I'll try to find time to dive into it tomorrow.
and this easy code not work $post = Model_Post::query()->related('articles') ->where('articles.published', 1) ->get_one();
code from docs
return null
I'll have a look at it in the weekend as well.
@hotlabs : What do you expect with this code ? Is your database populated with published articles that have a relation with post ?
yes table full
Where these objects loaded before, in a different query? If so, I just pushed a fix for that.
Just did
$session = Model\Session::query()->related('registration')
->where('registration.id', '=', 92)
->get_one();
In an app I was working on, and I get 1 session object (the first) back, and one related registration object with ID 92. If I remove the where, I get the same session object, but then with all 12 related registration objects.
So I'd say "works as advertised"?
NB: Pay attention to the question you ask. get_one()
means give me the first session, not "give me the first record that matches", the ORM is not a simple query builder.
So if I do:
$session = Model\Session::query()->related('registration')
->where('registration.id', '=', 4329873623978462394)
->get_one();
i get null
back, since the first session doesn't have a registration with that id value.
NB 2: This would give you what you want:
$session = Model\Session::query()->related('registration')
->where('registration.id', '=', 262144)
->rows_limit(1)
->get_one();
which returns me session object with id 38448, and one related registration object, with id 262144.
rows_limit()
applies the limit to the entire result, where limit()
(which is implied by get_one()
only applies to the parent record.
I think I misunderstood your report. Just pushed a fix for this issue.
Could you verify and confirm the fix?
Hadn't the time to look at it in the past few days.
What is the current status of the issue ? And about the change in general. Are some issues left ?
I think this one is fixed, just waiting for confirmation.
@hotlabs any feedback on the latest updates?
Closed due to no feedback.
Im have many to many relation; and i want include 2 level relations
protected static $_many_many = array('genres')
Model_***::query() ->related('genres') ->related('genres.translation') ->get();
SQL build - Correct but if there is no connection yet, then I get an empty object
array(1) { [""]=> object(Model_Genre)
this empty result need fix -