[web2py] Re: Problem with Web2py sql that includes % on Postgres; breaking New Relic

2011-12-21 Thread Massimo Di Pierro
Thank you Patrick and Graham. On Dec 21, 3:05 pm, pbreit wrote: > Graham sent me a patched NewRelic agent (version 1.0.6.176) which appears > to be working fine.

[web2py] Re: Problem with Web2py sql that includes % on Postgres; breaking New Relic

2011-12-21 Thread pbreit
Graham sent me a patched NewRelic agent (version 1.0.6.176) which appears to be working fine.

[web2py] Re: Problem with Web2py sql that includes % on Postgres; breaking New Relic

2011-12-15 Thread Massimo Di Pierro
Thanks Graham, we may eventually change this. One of the reason for rewriting the DAL was to add parametric queries. It just ever happened because there was not sufficient motivation, as users do not see this. Massimo On Dec 15, 6:44 pm, Graham Dumpleton wrote: > I am making a change on New Reli

[web2py] Re: Problem with Web2py sql that includes % on Postgres; breaking New Relic

2011-12-15 Thread pbreit
I tried the fix without New Relic and it worked OK. Will try out your patched agent tomorrow. It does seem like Web2py would be well off sending in parameterized queries.

[web2py] Re: Problem with Web2py sql that includes % on Postgres; breaking New Relic

2011-12-15 Thread Graham Dumpleton
I am making a change on New Relic side. You can't do what you are doing as that then will cause wrong thing to happen for when New Relic not used. So am changing things to accommodate for what psycopg2 interprets as default argument. The issue hasn't come up before because Web2Py is the only fr

[web2py] Re: Problem with Web2py sql that includes % on Postgres; breaking New Relic

2011-12-15 Thread pbreit
I found a fix but I am not qualified to determine if it should go in as a patch. I basically added a % on each side. I think %% distills down to % without triggering a substitution. http://code.google.com/p/web2py/source/browse/gluon/dal.py#1924 From: key = '%|'+str(second).replace('|','||').r

[web2py] Re: Problem with Web2py sql that includes % on Postgres; breaking New Relic

2011-12-15 Thread pbreit
Thanks for investigating. Is it something that is fixable on NewRelic's end? Or would Web2py need to change how it submits the query? >From my brief research, it does seem like psycopg expects queries to be parameterized (ie, using string substitution). However my query works fine when not wrap

[web2py] Re: Problem with Web2py sql that includes % on Postgres; breaking New Relic

2011-12-15 Thread Graham Dumpleton
Okay, have an answer. Looks like we may be falling into a bit of undefined territory within the DBAPI2 specification that I can see and different DBAPI2 modules behave differently. Some will take parameters as evaluating False to mean no parameters and so not trigger doing any variable substituti

[web2py] Re: Problem with Web2py sql that includes % on Postgres; breaking New Relic

2011-12-15 Thread Graham Dumpleton
Are you perhaps introspecting the type of the cursor object in some way and changing behaviour based on that? We wrap the cursor object returned by DBAPI2 module and so you wouldn't see original psycopg2 cursor type. Graham On Dec 16, 10:02 am, Graham Dumpleton wrote: > On Dec 16, 7:13 am, Massi

[web2py] Re: Problem with Web2py sql that includes % on Postgres; breaking New Relic

2011-12-15 Thread Graham Dumpleton
On Dec 16, 7:13 am, Massimo Di Pierro wrote: > I disagree. this > > SELECT * FROM table where field ILIKE '%|featured|%'; > > is valid SQL. % does not need to be escaped in SQL and, in fact, it is > used for pattern patching: > > http://www.postgresql.org/docs/7.4/static/functions-matching.html

[web2py] Re: Problem with Web2py sql that includes % on Postgres; breaking New Relic

2011-12-15 Thread pbreit
Although it does seem like psycopg prefers parameterization.

[web2py] Re: Problem with Web2py sql that includes % on Postgres; breaking New Relic

2011-12-15 Thread pbreit
I tend to agree. Even if it's not "best practice" (probably debatable), it should still be supported by New Relic).

[web2py] Re: Problem with Web2py sql that includes % on Postgres; breaking New Relic

2011-12-15 Thread Massimo Di Pierro
I disagree. this SELECT * FROM table where field ILIKE '%|featured|%'; is valid SQL. % does not need to be escaped in SQL and, in fact, it is used for pattern patching: http://www.postgresql.org/docs/7.4/static/functions-matching.html Perhaps new-relic may have a bug. On Dec 14, 5:30 pm, pbrei

[web2py] Re: Problem with Web2py sql that includes % on Postgres; breaking New Relic

2011-12-15 Thread pbreit
Bump