sequelize / website

Our beloved website that contains all versions of our documentations and the API references.
https://sequelize.org
29 stars 156 forks source link

misleading documentation on "type" parameter #294

Open runfaj opened 5 years ago

runfaj commented 5 years ago

https://github.com/sequelize/sequelize/blob/ff1c97cd9264d50c1d779b31a8d38dd4182ddfaa/lib/sequelize.js#L427

This documentation indicates that ANY time the "type" parameter is specified, the returned result is the row, without the counts. However, looking at the actual code:

https://github.com/sequelize/sequelize/blob/ff1c97cd9264d50c1d779b31a8d38dd4182ddfaa/lib/dialects/postgres/query.js#L261

This is NOT the case with insert/update/raw. This should either be adjusted in the documentation to mention excluded cases, or should be updated in the Query to return the expected result for these other cases. I vote the latter personally, as it provides more code flexibility in general - but I do understand that would be a breaking change, since people would have had to work around this issue by now.

It should also be noted, that this was working properly in sequelize v3. When I started migrating to v4, this issue presented itself. Here's the example query I had to modify as a result:

   return sequelize.query(sql, {
        type: models.Sequelize.QueryTypes.UPDATE,
        replacements: {
          jobId,
          status: metricStatuses.PROCESSING,
          workerMeta: JSON.stringify(workerMeta),
        },
        raw: true,
      })
      .then(_.first) ////////// this shouldn't be needed, docs say setting the type avoids this
      .then(_.first);
stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂