I'm getting this backtrace (with a Trac slightly modified to give useful
reports on DB errors):
...
File
"/usr/local/share/trac/global/plugins/TracForge-1.1-py2.5.egg/tracforge/admin/model.py",
line 165, in by_env_path
cursor.execute('SELECT name FROM tracforge_projects WHERE
env_path=%s',(env_path,))
File
"/usr/local/lib/python2.5/site-packages/Trac-0.11rc1-py2.5.egg/trac/db/util.py",
line 54, in execute
repr(sql_escape_percent(sql)) + '\n' + repr(args)
Exception: invalid sql:
sql='SELECT name FROM tracforge_projects WHERE env_path=%s'
escaped sql='SELECT name FROM tracforge_projects WHERE env_path=%s'
args=('/usr/local/share/trac/projects/master',)
So, there are a number of issues here. The code is apparently trying to
execute:
SELECT name FROM tracforge_projects WHERE
env_path=/usr/local/share/trac/projects/master
but
1) In Postgresql at least, you need enclosing quotes to embed '/' in a
string. In fact, I keep finding places where queries are written in
a way that causes problems for Postgresql. Can we find a natural way
to deal with that so our queries are more reliably portable across DB
backends?
2) The natural way to fix the problem would be:
cursor.execute("SELECT name FROM tracforge_projects WHERE
env_path='%s'",(env_path,))
but of course that won't work, because the % is now embedded in ''
and therefore sql_escape_percent will turn it into %%. It seems that
to get the right result, TracForge would have needed something like
cursor.execute('SELECT name FROM tracforge_projects WHERE
env_path=%s',("'%s'"%env_path,))
but I don't know how Noah could know that without crawling through the
code. Is there documentation somewhere about how Trac's enhanced
cursors are supposed to be used so that the results are more
predictable?
3) What about literally intended percent signs in the args? Why does
it make sense to escape them in the first argument to execute and not
in the rest?
confused-ly y'rs,
--
Dave Abrahams
BoostPro Computing
http://www.boostpro.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac
Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/trac-dev?hl=en
-~----------~----~----~----~------~----~------~--~---