Make COUNT returns error if there is no result, show warnings if there are too many parameters #2139

Closed
opened 2022-04-25 06:33:18 +00:00 by wxiaoguang · 0 comments

Background

  1. Developers may make mistakes about COUNT, eg: SELECT COUNT(*) FROM table LIMIT 10, which produces unexpected result. A simple COUNT should already have one row result. If not, there must be something wrong.

  2. Databases have limitations about the number of preparted statement parameters.

Solution

To handle all similar problems gracefully in future, some improvements from XORM side:

  1. Make XORM's Count return an error if the result is 0 row.
  2. Make XORM report warnings for SQLs with more than xxxx parameters (eg: 16384), then users/developers can know there is something needed to be refactored, they have enough time to optimize the query before the hard limit comes.
# Background 1. Developers may make mistakes about `COUNT`, eg: `SELECT COUNT(*) FROM table LIMIT 10`, which produces unexpected result. A simple `COUNT` should already have one row result. If not, there must be something wrong. 2. Databases have limitations about the number of preparted statement parameters. # Solution To handle all similar problems gracefully in future, some improvements from XORM side: 1. Make XORM's Count return an error if the result is 0 row. 2. Make XORM report warnings for SQLs with more than xxxx parameters (eg: 16384), then users/developers can know there is something needed to be refactored, they have enough time to optimize the query before the hard limit comes.
lunny added the
kind
enhancement
label 2022-04-25 07:06:50 +00:00
lunny added this to the 1.3.1 milestone 2022-04-25 07:07:02 +00:00
lunny modified the milestone from 1.3.1 to 1.3.2 2022-05-31 02:23:50 +00:00
lunny modified the milestone from 1.3.2 to 1.3.3 2022-09-03 07:12:16 +00:00
lunny closed this issue 2023-07-20 14:48:33 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#2139
No description provided.