Log message #4197688

# At Username Text
# Aug 13th 2019, 09:50 challgren Ahhh, how many assertions so far?
# Aug 13th 2019, 09:50 neothermic @challgren also I've had to do other work inbetween writing tests :S
# Aug 13th 2019, 09:49 neon1024 https://github.com/cakephp/cakephp/blob/master/src/Core/ObjectRegistry.php
# Aug 13th 2019, 09:49 neon1024 @val Have a look at the ObjectRegistry class if you’re interested, it’s one of the key patterns for the whole framework, even in Cake 2
# Aug 13th 2019, 09:48 challgren @val maybe someone else knows a better answer, I by no means am a ORM expert
# Aug 13th 2019, 09:48 neon1024 @val That’s exactly what you asked for
# Aug 13th 2019, 09:47 neothermic it gets fun when you have a function with an npath of 442.. :)
# Aug 13th 2019, 09:46 val omg. new table instance for each subquery?! that's insane
# Aug 13th 2019, 09:45 neon1024 It can lead to sub-standard test-cases
# Aug 13th 2019, 09:45 neon1024 Chasing coverage is dangerous
# Aug 13th 2019, 09:44 challgren I had 100% at one time but it dropped to 80% and Im sad about it, but need to focus on getting it back up to 100%
# Aug 13th 2019, 09:43 neon1024 So you can use it later again if needed
# Aug 13th 2019, 09:43 neon1024 ..and you’ll have added an alias to the Registry
# Aug 13th 2019, 09:43 neon1024 Then you can use the return @val
# Aug 13th 2019, 09:43 challgren Yes so you use $Example2->find() as your subquery
# Aug 13th 2019, 09:43 neothermic @challgren unit tests. Working from critical parts forward
# Aug 13th 2019, 09:43 slackebot1 <neon1024>
# Aug 13th 2019, 09:43 challgren Are you just doing integration tests?
# Aug 13th 2019, 09:42 val @challgren the same problem. I need the alias to be applied only to a single subquery.
# Aug 13th 2019, 09:42 neon1024 Probably something like `$t = new TableLocator(); $t->get(‘Cat’, [ ‘className’ => \App\Model\Table\DogsTable::class ])`
# Aug 13th 2019, 09:42 neothermic 0.9% of 500k is still a lot of lines tested
# Aug 13th 2019, 09:42 challgren Damm figured you’d be at least 5%
# Aug 13th 2019, 09:41 neothermic argh, 0.9% covered. gotta keep going to hit that first 1%
# Aug 13th 2019, 09:41 challgren `$Example2 = TableRegistry::getTableLocator()->get('Example')->setAlias('Example2');`
# Aug 13th 2019, 09:41 neon1024 So I guess you’d need to load a new aliased instance
# Aug 13th 2019, 09:40 neon1024 Although as Cake uses the Registry pattern you’ll always be changing the same instance, unless you clone it as @challgren said
# Aug 13th 2019, 09:40 neon1024 `$query->getRepository()->setAlias();`
# Aug 13th 2019, 09:39 challgren Yep not defined.
# Aug 13th 2019, 09:39 val I can't find `setAlias` in Query class
# Aug 13th 2019, 09:39 neon1024 Call it on the query instance instead of the table?
# Aug 13th 2019, 09:37 challgren Try it first and see
# Aug 13th 2019, 09:37 challgren You could clone it
# Aug 13th 2019, 09:36 val not what is needed
# Aug 13th 2019, 09:36 challgren I could see that happening
# Aug 13th 2019, 09:35 val @challgren wouldn't this set 'Example2' alias for all consecutive queries to Example table?
# Aug 13th 2019, 09:35 Martin` When do I need to use Aliasses?
# Aug 13th 2019, 09:34 challgren `$this->Example->setAlias('Example2')->find()`
# Aug 13th 2019, 09:31 val and how a table alias can be set on Query object?
# Aug 13th 2019, 09:12 neon1024 `$newSubQuery = $this->Examples->find()`
# Aug 13th 2019, 09:05 val @admad any example?
# Aug 13th 2019, 08:51 admad Create a separate query instance for the sub query