Opened 18 years ago
Closed 18 years ago
#3465 closed defect (duplicate)
SQL parse problem with $USER and strftime("%s", changetime)
Reported by: | Owned by: | daniel | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | report system | Version: | 0.9.5 |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
I was just trying to create a report that shows all tickets of currently logged user that have had any activity in last month.
Being fairly new to SQL, I tried the following SQL statement:
SELECT id AS ticket, summary, component, status, resolution, changetime AS modified, time AS _time FROM ticket WHERE strftime ("%s", current_date) - 60*60*24*30 < changetime ORDER BY changetime
This seems to work fine.
However, when I add another condition (" and owner = $USER"), I get the following error: "Report execution failed: not enough arguments for format string".
Funny thing is, if I hardcode the value, as in " and owner = "joe" ", it works fine. I've tried putting parentheses around both conditions, but that did not help. It seems to me like a parsing problem (when both %s and $USER are present, the parser is somehow confused).
Can anyone else confirm this problem? Or just kick me into my head for doing something obviously wrong? (Before you ask, the value of "$USER" was perfectly normal "joe" and worked fine alone.)
This is the same issue encountered in #2773. Currently on Trac 0.9.x you need to escape the "%" with another one: "%%".