Log message #4223143

# At Username Text
# Jan 20th 2020, 17:27 turkles I have a bunch of user roles my users can opt into, and finding it hard to check if they already have it as its User.Roles[0], User.Roles[1] etc, would be much easier if the index was role_id
# Jan 20th 2020, 17:23 turkles Is it possible to index contains by a field/key?
# Jan 20th 2020, 17:16 ndm `execute()` is a method of the inherited, "lower level" database query class, which has no ORM features like containments
# Jan 20th 2020, 17:13 ndm @kiwi_72 Under the hood `get()` uses `find()` too. In your example you are using `execute()`, not sure if that's in your actual code, or just for the example, but that won't include containments, as it will only execute the SQL that this query object creates, not the ones created by the eager loadables (containments). Use `all()`, `toArray()`, one of the collection methos, or iterate the query object instead.
# Jan 20th 2020, 17:06 kiwi_72 using get() works with the hasMany() association. something with find behaves differently than I expected it to be. @btx, @ndm thank you both for your pointers!
# Jan 20th 2020, 16:55 neon1024 https://flysystem.thephpleague.com/v1/docs/adapter/local/
# Jan 20th 2020, 16:54 neon1024 Are you using a local file system or a remote one?
# Jan 20th 2020, 16:54 neon1024 The documentation for the Flysystem library says you set a path when you setup the adapter
# Jan 20th 2020, 16:51 ricksaccous nothing makes sense here
# Jan 20th 2020, 16:51 ricksaccous but not where
# Jan 20th 2020, 16:51 ricksaccous I know they are somewhere
# Jan 20th 2020, 16:50 ricksaccous I don't know where the hell my files are being put
# Jan 20th 2020, 16:50 ricksaccous I'm running into a really stupid problem with flysystem
# Jan 20th 2020, 16:26 kiwi_72 ok i see
# Jan 20th 2020, 16:25 ndm It happens automatically under the hood, nothing you'd need to worry about
# Jan 20th 2020, 16:25 kiwi_72 or you mean what is happening in tunder the hood of cakephp?
# Jan 20th 2020, 16:25 kiwi_72 nothing I can find about additinal queries
# Jan 20th 2020, 16:24 kiwi_72 in the examples on https://book.cakephp.org/3/en/orm/retrieving-data-and-resultsets.html#retrieving-associated-data there is one find with contains, witch returns all the associated data
# Jan 20th 2020, 16:24 ndm what procedure?
# Jan 20th 2020, 16:24 kiwi_72 ndm: could you please elaborate on the procedure?
# 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?