You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Count is not made on the primary column when it is in a joined table. #962
I have a problem and I can't solve it.
I have to display a grid, containing datas from a table and a joined table.
The primary column is set correctly, but the count query is not made on this column ! It is made on the id of the first table !
Why should the primary column not be used to count? I don't understand. Is it a bug?
SELECT count(DISTINCT h0_.id) AS sclr_0 FROM hierabc h0_ INNER JOIN AdresseAll a1_ ON (h0_.idpeople= a1_.idpeople) WHERE h0_.idpeoplesup= ('XXXXXXXXXXX'');
Here h0.id, is the id of the entity selected as source. But it is not the column set as primary.
Don't hesitate to ask me anything if you need further details!
Hello, I'm trying to investigate it but, conceptually, isn't the result the same?
If a row is filtered out by join condition, it will not appear. If it is in there, you can count on pretty much every (unique) column.
In your case is not id a unique field so the count is not properly reported?
Setting the field as primary do not work with the count query. The count walker, takes the primary key of the source entity, not the column set as primary.
@MaxandreOgeret can you show me how did you excluded id as primary field? Moreover, as things goes in session, have you tried to exclude it, logoff, login and check again?
Could you, please, execute what I'm suggesting and report the results and annotation on Entity to exclude id as primary field?
Activity
DonCallisto commentedon Jul 28, 2017
Hello, I'm trying to investigate it but, conceptually, isn't the result the same?
If a row is filtered out by
joincondition, it will not appear. If it is in there, you can count on pretty much every (unique) column.In your case is not
idauniquefield so the count is not properly reported?MaxandreOgeret commentedon Jul 28, 2017
Thanks for your answer.
No, the result was not the same, as the count is a count distinct.
[001|value1]
[001|value2]
[002|value3]
[002|value4]
This will only count 2, while it should count 4.
DonCallisto commentedon Jul 28, 2017
Ok, so because it's not a unique value field where
value*is; am I right?DonCallisto commentedon Jul 28, 2017
What is your
Source?Entity?DonCallisto commentedon Jul 28, 2017
@MaxandreOgeret check this out https://github.com/APY/APYDataGridBundle/blob/58f4e370ba79bd7d593a3759010ab002b3946b61/Resources/doc/columns_configuration/annotations/column_annotation_property.md
MaxandreOgeret commentedon Jul 28, 2017
Yes you're right. and my source is an entity
Setting the field as primary do not work with the count query. The count walker, takes the primary key of the source entity, not the column set as primary.
DonCallisto commentedon Jul 28, 2017
@MaxandreOgeret follow my last comment, it should resolve your issue.
MaxandreOgeret commentedon Jul 28, 2017
I tried, but it don't change anything. :/
DonCallisto commentedon Jul 28, 2017
Can you show me relevant code?
MaxandreOgeret commentedon Jul 28, 2017
I don't have the sources right now, but i'll try to give you an exemple.
I have two tables :
These tables represents this tree :
Let's say customers have more than one adresses and i want to list those adresses like :
If my primary entity is CUSTOMER and max_parent comes from it, it will count only one.
Tell me if you want more explanations.
MaxandreOgeret commentedon Jul 28, 2017
You may just check that the count request is made on the column marked as primary.
DonCallisto commentedon Jul 28, 2017
I understand.
Let me tackle this (hopefully) in the next days: I'll try to reproduce it and let you know.
BTW I can't guarantee that I'll take a look soon as from today I'm in vacation :)
Last question: can you tell me what source are you using?
Entity,Document(Mongo) orVectoras grid source?MaxandreOgeret commentedon Jul 28, 2017
I am using
Entityas grid source, thanks you :)DonCallisto commentedon Jul 28, 2017
@MaxandreOgeret can you show me how did you excluded
idas primary field? Moreover, as things goes in session, have you tried to exclude it, logoff, login and check again?Could you, please, execute what I'm suggesting and report the results and annotation on
Entityto excludeidas primary field?MaxandreOgeret commentedon Jul 28, 2017
I tried :
$grid->getColumn('id')->setPrimary(false);I also tried via annotations.
Yes i tried to log again too.
I tried to dump the column and the attribute primary id expectedly false.
DonCallisto commentedon Jul 28, 2017
Ok, thank you.
I need to take a look at this so.
Once bug is confirmed, I will change the label and try to tackle it.
Thanks for the moment.
MaxandreOgeret commentedon Jul 28, 2017
I'm at your service if further investigations are required. Thanks for the moment too. 🥇
MaxandreOgeret commentedon Aug 1, 2017
THis may help you