Skip to content

Do not automatically add primary key to attributes (or include[].attributes) if raw is set - #4029

Merged
mickhansen merged 3 commits into
sequelize:masterfrom
pimterry:aggregate-with-include
Jul 3, 2015
Merged

mickhansen merged 3 commits into
sequelize:masterfrom
pimterry:aggregate-with-include

Conversation

@pimterry

Copy link
Copy Markdown
Contributor

This bring in the changes discussed in #3920, disabling the automatic addition of the primary key field to the attributes returned by a query, and thereby allowing aggregation in more cases, when raw is set to true.

This includes the changes and tests. Is there any documentation anywhere that needs to be updated in line with this?

@mickhansen

Copy link
Copy Markdown
Contributor

Thank you for this PR. The only issue i have is passing raw as a single argument, perhaps we could pass the options instead?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the console.log

@pimterry

pimterry commented Jul 3, 2015

Copy link
Copy Markdown
Contributor Author

Both those comments are now fixed.

Build has failed, but that looks to be for other unrelated reasons (issues with transaction serialization), which I suspect is something intermittent, but I don't have permission to retrigger the build. I can't see any way these couple of tiny markups could've caused that.

mickhansen added a commit that referenced this pull request Jul 3, 2015
Do not automatically add primary key to attributes (or include[].attributes) if raw is set
@mickhansen
mickhansen merged commit e8eae76 into sequelize:master Jul 3, 2015
@mickhansen

Copy link
Copy Markdown
Contributor

Thanks for the contribution :)

@hamza-sabri

Copy link
Copy Markdown

Sorry for opening this again.
I read the article and I still couldn't find a way to do what the article suggested

I had three tables invoice, item, invoice_item(which had a quantity column)
I am doing a join between invoice and item models and would like to apply some aggregate functions (sum, min, max, count, avg, ... etc) on the result of the join or simply add up the quantity field from the result.

But I had the same error described here (https://www.softwire.com/insights/fixing-aggregation-over-relationships-with-sequelize/) and it was the closest I came to a solution but couldn't figure it out.

could someone help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants