Modify

Opened 4 years ago

Last modified 4 years ago

#13847 new defect

Exception "Invalid query constraint value"

Reported by: anonymous Owned by:
Priority: normal Component: WikiCalendarMacro
Severity: normal Keywords:
Cc: Trac Release: 1.4

Description

I am upgrading my Trac server from 0.12 to the latest, 1.4.2. I have used WikiCalendar for a long time, and now apparently WikiTicketCalendar comes with it. I tried using it, but there was a problem. Note: The Trac instance is a new scratch environment with a couple test tickets and such.

FYI, I am using "trunk" of WikiCalendar as of today.

Attempting one of the example invocations:

[[WikiTicketCalendar(*,*,true,/Meeting-%Y-%m-%d)]]

... I get an exception:

QueryValueError: Invalid query constraint value

I'm not adept enough at Trac plugin development to fully understand what might actually be going wrong, but in a small amount of debugging it seems that at least some query passes succeed, and they appear to have similar (or the same) query string ...

As a work-around, I caught the exception. The calendar appears and the day with a log entry (I added one with the WikiCalendar to test it) is red, as I would expect. I'm not sure if other features of WikiTicketCalendar are being lost, since I'm really not familiar with it yet.

Here is the work-around I placed in ticket.py in order to make it (appear to) work:

        try:
            result = query.execute(req)
        except:
            result = []

Attachments (3)

wikiticketcalendar_patch_for_trac_142.patch (1.8 KB) - added by anonymous 4 years ago.
Apparent fixes for invalid constraint value as well as a further issue regarding "tag" needing to be callable.
wikiticketcalendar_div_patch_for_trac_142.patch (808 bytes) - added by anonymous 4 years ago.
Sorry for the chatter, but I found a better solution to the tag issue here. The new Trac "tag" feature needs a proper tag name. The failure came where no tag was used/needed, so I tried "div". Seems fine, I guess.
Blog.py (6.0 KB) - added by anonymous 4 years ago.
For reference (FWIW), I am enclosing the simplistic Blog plugin I'm using with the WikiCalendarMacro.

Download all attachments as: .zip

Change History (16)

comment:1 Changed 4 years ago by Ryan J Ollos

Owner: set to Ryan J Ollos
Status: newaccepted

Changed 4 years ago by anonymous

Apparent fixes for invalid constraint value as well as a further issue regarding "tag" needing to be callable.

Changed 4 years ago by anonymous

Sorry for the chatter, but I found a better solution to the tag issue here. The new Trac "tag" feature needs a proper tag name. The failure came where no tag was used/needed, so I tried "div". Seems fine, I guess.

Changed 4 years ago by anonymous

Attachment: Blog.py added

For reference (FWIW), I am enclosing the simplistic Blog plugin I'm using with the WikiCalendarMacro.

comment:2 Changed 4 years ago by Ryan J Ollos

In 17850:

2.2.0dev: Fix "Invalid query constraint value"

Refs #13847.

comment:3 Changed 4 years ago by Ryan J Ollos

Resolution: fixed
Status: acceptedclosed

Thanks for raising the issue. Looks like some code wasn't modified correctly when WikiTicketCalendarMacro was integrated.

comment:4 Changed 4 years ago by anonymous

... And thanks for helping with this.

My system will not accept a colon as a date/time separator. It seems that ".." does work, though. Apparently it does not on your system, as you left out that part of the patch. When I looked at this before, the items that were being joined already had a lot of colons in the strings. Is this a locale issue? I'm just guessing.

        if name == 'WikiTicketCalendar':
            daystr = ('..').join([
                         format_datetime(first_day, locale=locale),
                         format_datetime(last_day, locale=locale)])
            provider = WikiCalendarTicketProvider(env)

Also, I think you inadvertently left a print statement in ticket.py

        query_string += '&cols=%s' % cols
        print(query_string)
        query = Query.from_string(self.env, query_string)

comment:5 Changed 4 years ago by anonymous

For instance, I see from this section:

TracQuery#QueryLanguage

... That two dots are used as the range delimiter for time variables in query strings:

created=2007-01-01..2008-01-01 query tickets created in 2007

comment:6 Changed 4 years ago by anonymous

Resolution: fixed
Status: closedreopened

comment:7 Changed 4 years ago by Ryan J Ollos

In 17857:

2.2.0dev: Remove print statement from r17850

Refs #13847.

comment:8 in reply to:  4 Changed 4 years ago by Ryan J Ollos

Replying to anonymous:

My system will not accept a colon as a date/time separator. It seems that ".." does work, though.

What is the error message (preferably a traceback from the log)?

comment:9 Changed 4 years ago by anonymous

This is the original cause of the ticket itself -- this range separator character.

2020-08-26 09:19:42,849 Trac[formatter] ERROR: Macro WikiTicketCalendar(*,*,true,/Dan/Blog/Meeting-%Y-%m-%d) failed for <Resource u'wiki:Dan/MacroTest'>:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/trac/wiki/formatter.py", line 818, in _macro_formatter
    return macro.ensure_inline(macro.process(args), in_paragraph)
  File "/usr/local/lib/python2.7/dist-packages/trac/wiki/formatter.py", line 389, in process
    text = self.processor(text)
  File "/usr/local/lib/python2.7/dist-packages/trac/wiki/formatter.py", line 361, in _macro_processor
    text)
  File "/mnt/c/Users/dmahn/ApacheTest/conf/trac/plugins/expanded/WikiCalendarMacro-2.2.0.dev0-py2.7.egg/wikicalendar/macros.py", line 491, in expand_macro
    '='.join(['created', daystr]))
  File "/mnt/c/Users/dmahn/ApacheTest/conf/trac/plugins/expanded/WikiCalendarMacro-2.2.0.dev0-py2.7.egg/wikicalendar/ticket.py", line 61, in harvest
    result = query.execute(req)
  File "/usr/local/lib/python2.7/dist-packages/trac/ticket/query.py", line 301, in execute
    sql, args = self.get_sql(req, cached_ids, authname, tzinfo, locale)
  File "/usr/local/lib/python2.7/dist-packages/trac/ticket/query.py", line 712, in get_sql
    raise QueryValueError(errors)
QueryValueError: Invalid query constraint value

comment:10 Changed 4 years ago by anonymous

In query.py, starting at line 513, I see use of the ".." separator:

                if name in self.time_fields:
                    if not value:
                        clause = "COALESCE({0},''){1}=%s" \
                                 .format(col, '!' if neg else '')
                        args = ['']
                        return clause, args
                    if '..' in value:
                        (start, end) = [each.strip() for each in
                                        value.split('..', 1)]
                    else:
                        (start, end) = (value.strip(), '')
                    start = user_parse_date(start)
                    end = user_parse_date(end)

comment:11 in reply to:  4 Changed 4 years ago by Ryan J Ollos

Replying to anonymous:

Is this a locale issue?

What is your locale? I can try to reproduce.

comment:12 Changed 4 years ago by Ryan J Ollos

Would be useful to know output of:

$ locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL=

and TracIni#trac-default_language-option.

comment:13 Changed 4 years ago by Ryan J Ollos

Owner: Ryan J Ollos deleted
Status: reopenednew

I'll return to ticket if there is more info provided.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.