#13282 closed (fixed)
Document patch: WEEK_DAY should start from 0, not 1
Reported by: | wangchun | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 1.1 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Confirmed with postgresql
Attachments (3)
Change History (9)
by , 15 years ago
Attachment: | 13282.diff added |
---|
follow-up: 2 comment:1 by , 15 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
by , 15 years ago
Attachment: | 13282-r13135.diff added |
---|
comment:2 by , 15 years ago
Has patch: | set |
---|---|
milestone: | → 1.2 |
Replying to kmtracey:
Alternatively we could remove the "SQL equivalent" entirely and just describe what the function does without including any indication of the SQL generated (which in fact is very different for the different databases).
I've attached a patch implementing just that choice as outlined by Karen.
by , 15 years ago
Attachment: | 13282-r13135.2.diff added |
---|
ramiro's patch with # for Saturday fixed from 6 to 7
comment:3 by , 15 years ago
Patch needs improvement: | unset |
---|---|
Triage Stage: | Accepted → Ready for checkin |
comment:4 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:5 by , 15 years ago
Note:
See TracTickets
for help on using tickets.
There is a slight problem in the doc here, but the patch does not fix it. The only thing wrong in the cited doc is that the "SQL equivalent" is not in fact the SQL produced, for any supported database, for the given example. For the function as implemented, the days of the week do start on Sunday and the numbering does starts at 1, as documented. So the parts of the patch which change that are incorrect. The example query, using week_day of 2, will in fact produce all matching objects that fall on a Monday.
The problem in the doc is that the extract(dow) function is what is used to implement the feature on PostgreSQL, and there the days are numbered differently. If you check the actual SQL generated for the example query, you will see that it adds 1 to the result of extract(dow) and compares against the requested numerical day of week. Putting the actual PostgreSQL query in the doc, would, I think, be more confusing than helpful. Putting the MySQL version of the query (DAYOFWEEK(pub_date) = 2) would likely be more helpful. Alternatively we could remove the "SQL equivalent" entirely and just describe what the function does without including any indication of the SQL generated (which in fact is very different for the different databases).
Note changing the numbering is not an option, this was already requested and rejected in #10345, and cannot be changed at this point since it would break backwards compatibility.