Log message #4223123

# At Username Text
# Jan 20th 2020, 16:22 ndm `hasMany` and `belongsToMany` associations are generally being retrieved in separate/additional queries
# Jan 20th 2020, 16:20 kiwi_72 btx: i've got the query statements form the query object. and it is missing the association as soon as the table association is hasMany. (and vardumping the result is just accoring to this, it doesn't contain anything about the second table)
# Jan 20th 2020, 16:19 lorenzo haha
# Jan 20th 2020, 16:17 btx (my answers are always a trick to get a more qualified person to correct me)
# Jan 20th 2020, 16:16 lorenzo contain is always eager
# Jan 20th 2020, 16:16 lorenzo the orm does not lazy load
# Jan 20th 2020, 16:16 btx the new ORM lazy loads, it probably wont pull it back unless asked to
# Jan 20th 2020, 16:16 btx what happens when you actually vardump the executed object
# Jan 20th 2020, 16:15 kiwi_72 I have checked with find() as you suggested, and it behaves the same
# Jan 20th 2020, 16:15 btx because you’re using find(‘all’), probably
# Jan 20th 2020, 16:14 kiwi_72 I see, but do you have any hints on why is the other table completely omitted in the query if the relation is hasMany() (with the same,and proven to work paramters (foreingKey/bindingKey)?
# Jan 20th 2020, 16:09 btx also I wouldn’t specify the `hasMany` params unless you’re overriding them, but that’s just me
# Jan 20th 2020, 16:09 btx kiwi, I would do `$ordersTable->find()->contain(['Tablebs'])` instead of `find('all')`
# Jan 20th 2020, 16:06 kiwi_72 on https://pastebin.com/TUSQt5Va i try to explain in more detail
# Jan 20th 2020, 15:59 val @lorenzo I see `firstOrFail()` method that could be used as an example. That might work. What if I would like to do similar thing with `null` associated records returned by `find('all')` ?
# Jan 20th 2020, 15:54 kiwi_72 When dumping the query i see no sign of the association when the model is set to hasMany, but I can see the other table when it is sat to hasOne(). Perhaps anyone could lighten me up what is going on here? thanks
# Jan 20th 2020, 15:54 kiwi_72 Im stuck with cakephp 3.8's associated models. I think I have sat it up right, but I get nothing back from my find()->contains() if the association is set to hasMany(). By just changing the association to hasOne() inside the table it returns the first associated data row. Which is resonable, but I have no idea why it doesnt't work with hasMany().
# Jan 20th 2020, 15:51 lorenzo you can override the query function in the table class to return your own query class instance
# Jan 20th 2020, 15:50 lorenzo @val I would extend the Query class, and add a `firstOrDefault()` function
# Jan 20th 2020, 15:49 kiwi_72 hello!
# Jan 20th 2020, 15:48 val @lorenzo?
# Jan 20th 2020, 15:45 neon1024 Question for Jose really, he wrote the ORM and would know better
# Jan 20th 2020, 15:45 neon1024 As you can see here https://github.com/cakephp/cakephp/blob/3.8.8/src/ORM/ResultSet.php#L517
# Jan 20th 2020, 15:44 neon1024 It sure does!
# Jan 20th 2020, 15:43 val @neon1024 Thanks. `hydrate()` simply toggles the hydration.
# Jan 20th 2020, 15:37 neon1024 Perhaps easier to implement a custom ResultSet class?
# Jan 20th 2020, 15:37 neon1024 https://github.com/cakephp/cakephp/blob/3.8.8/src/ORM/ResultSet.php#L579
# Jan 20th 2020, 15:36 neon1024 ..and associations
# Jan 20th 2020, 15:36 neon1024 So that contained associations returned the new special type as well
# Jan 20th 2020, 15:36 neon1024 https://github.com/cakephp/cakephp/blob/3.8.8/src/ORM/ResultSet.php#L522
# Jan 20th 2020, 15:36 neon1024 You’d also want to do it for matching
# Jan 20th 2020, 15:33 neon1024 …and doesn’t match the framework documentation and the code is often hidden and not obvious, making the behaviour hard to understand, unless you “just know it”
# Jan 20th 2020, 15:32 neon1024 Although I’m not a fan of changes like this because it’s often undocumented and produces behaviour which isn’t consistent with the framework
# Jan 20th 2020, 15:31 neon1024 That controls the conversion
# Jan 20th 2020, 15:29 neon1024 I’d look at `_hydrate()` method in Query
# Jan 20th 2020, 15:24 val @ndm, @admad what method should be overriden if I want that `Cake\ORM\Query->first()` would return a special object instead of `null` in case when no record is found in 3.x? I have difficulties in locating places where the entities are actually constructed.
# Jan 20th 2020, 14:23 ricksaccous @admad nice if that's the case that might make things loads easier, i'm going to try that
# Jan 20th 2020, 14:07 martin https://www.munderwood.ca/index.php/2017/02/28/responding-to-http-options-requests-in-cakephp/ this way
# Jan 20th 2020, 14:07 martin fixed the options method with a middleware :)
# Jan 20th 2020, 13:36 admad you can instead just use `$file->getStream()->getMetadata()['uri']` to get the file path to pass to flysystem
# Jan 20th 2020, 13:35 ndm or reattach it