# |
Mar 17th 2019, 11:48 |
birdy247 |
typically there will only be upto 5 other records |
# |
Mar 17th 2019, 11:46 |
edgaras.jan |
yes, but it retrieves all records, but uses only the last one |
# |
Mar 17th 2019, 11:44 |
birdy247 |
all tests are passing with that |
# |
Mar 17th 2019, 11:44 |
birdy247 |
my original aproach works |
# |
Mar 17th 2019, 11:44 |
birdy247 |
@edgaras.jan to be honest |
# |
Mar 17th 2019, 11:18 |
birdy247 |
no luck :( |
# |
Mar 17th 2019, 11:16 |
edgaras.jan |
comment out for now |
# |
Mar 17th 2019, 11:16 |
edgaras.jan |
yes |
# |
Mar 17th 2019, 11:15 |
birdy247 |
so get rid of the order? |
# |
Mar 17th 2019, 11:15 |
edgaras.jan |
`having(['MAX(CurrentPrices.effective_from) = CurrentPrices.effective_from'])` |
# |
Mar 17th 2019, 11:14 |
birdy247 |
presumably I need to select the having field |
# |
Mar 17th 2019, 11:14 |
birdy247 |
https://book.cakephp.org/3.0/en/orm/query-builder.html#aggregates-group-and-having |
# |
Mar 17th 2019, 11:14 |
birdy247 |
->group('published_date') ->having(['count >' => 3]); |
# |
Mar 17th 2019, 11:13 |
birdy247 |
how can I write that with the query builder |
# |
Mar 17th 2019, 11:12 |
birdy247 |
@edgaras.jan ok, will give it a go |
# |
Mar 17th 2019, 11:06 |
edgaras.jan |
group+order doesn't work on mysql, you need group+having max |
# |
Mar 17th 2019, 11:05 |
edgaras.jan |
try this sql `GROUP by CurrentPrices.id HAVING MAX(effective_from)=effective_from` |
# |
Mar 17th 2019, 10:57 |
edgaras.jan |
check what queries are generated, with DebugKit or query logging |
# |
Mar 17th 2019, 10:54 |
birdy247 |
but... I am then not sure what hapens if I find an entity and contain many entities, each with a current_proce |
# |
Mar 17th 2019, 10:54 |
birdy247 |
if I am a limit(1) it works |
# |
Mar 17th 2019, 10:54 |
birdy247 |
this is the select startegy |
# |
Mar 17th 2019, 10:52 |
birdy247 |
Its taking the last on the list |
# |
Mar 17th 2019, 10:52 |
birdy247 |
My test fails |
# |
Mar 17th 2019, 10:52 |
edgaras.jan |
ok |
# |
Mar 17th 2019, 10:52 |
slackebot2 |
<birdy247> |
# |
Mar 17th 2019, 10:51 |
edgaras.jan |
and revert to orderDesc |
# |
Mar 17th 2019, 10:51 |
birdy247 |
thats what we want |
# |
Mar 17th 2019, 10:51 |
birdy247 |
and orderDesc |
# |
Mar 17th 2019, 10:51 |
edgaras.jan |
after orderAsc add group() |
# |
Mar 17th 2019, 10:51 |
birdy247 |
so add a group in there? |
# |
Mar 17th 2019, 10:50 |
slackebot2 |
<birdy247> |
# |
Mar 17th 2019, 10:50 |
slackebot2 |
<birdy247> |
# |
Mar 17th 2019, 10:49 |
edgaras.jan |
group('hasoneTable.primary.key') |
# |
Mar 17th 2019, 10:48 |
birdy247 |
@edgaras.jan how do you mean groupByKey |
# |
Mar 17th 2019, 10:47 |
edgaras.jan |
Adding gruop by key should return 1 result for each key |
# |
Mar 17th 2019, 10:46 |
birdy247 |
ok tahnks |
# |
Mar 17th 2019, 10:45 |
savant |
im headed to bed for now, but hopefulluy someone else can help |
# |
Mar 17th 2019, 10:45 |
savant |
i wonder if we have a test for this |
# |
Mar 17th 2019, 10:45 |
savant |
ooo that might be it |
# |
Mar 17th 2019, 10:44 |
edgaras.jan |
https://github.com/cakephp/cakephp/blob/master/src/ORM/Association/Loader/SelectLoader.php#L474 I think here last latter duplicate result with same key overwrites former |
# |
Mar 17th 2019, 10:44 |
birdy247 |
I am using the select strategy |