Skip to content

docs: fix incorrect example of attributes in SELECT query docs #798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

emad-saud
Copy link

@emad-saud emad-saud commented Apr 12, 2025

Under the heading "Specifying attributes for SELECT queries" in the
"Model Querying - Basics" documentation page, the example incorrectly
used:

Model.findAll({
  attributes: ['foo', ['bar', 'baz'], 'qux'],
});

which would cause a runtime error. Updated it to the correct format:

Model.findAll({
  attributes: [['foo', 'baz'], ['baz', 'qux']],
});

to properly map field names to aliases.

Also fixed a similar issue in the next example on the same page, which used the same incorrect structure for the attributes option, the previous example showed:

Model.findAll({
  attributes: ['foo', [sequelize.fn('COUNT', sequelize.col('hats')), 'n_hats'], 'bar'],
});

which causes the same runtime error. Updated it to the right format:

Model.findAll({
  attributes: [['foo', 'bar'], [sequelize.fn('COUNT', sequelize.col('hats')), 'n_hats']],
});

These correction ensures valid syntax and clearer guidance for Sequelize users.

@emad-saud emad-saud requested a review from a team as a code owner April 12, 2025 11:56
@emad-saud emad-saud requested review from sdepold and ephys April 12, 2025 11:56
@emad-saud emad-saud changed the title docs: fix incorrect example of attributes in SELECT query docs docs docs: fix incorrect example of attributes in SELECT query docs Apr 14, 2025
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.

1 participant