[PgPy] [ python-Bugs-1000306 ] Make Postgres.Query more intuitive

noreply at pgfoundry.org noreply at pgfoundry.org
Fri Apr 29 03:00:07 GMT 2005


Bugs item #1000306, was opened at 2005-04-28 20:00
You can respond by visiting: 
http://pgfoundry.org/tracker/?func=detail&atid=442&aid=1000306&group_id=1000094

Category: Backend
Group: To do
Status: Open
Resolution: None
Priority: 6
Submitted By: James Pye (jwp)
Assigned to: James Pye (jwp)
Summary: Make Postgres.Query more intuitive

Initial Comment:
Postgres.Query currently requires the type of each argument used in the given query string to be explicitly specified as an extra argument. The creation interface should provide some intelligence here by defaulting all types to unknown and allowing the extra arguments to specify the type oid of their associated query argument.

q = Postgres.Query("select * from foo where x = $1")
q(3) # would convert three to a string then to an unknown

q = Postgres.Query("select * from bar where x = $1 and y = $2", N2=Postgres.bytea)
# The first argument would end up being an unknown but the second would be
# seen as a bytea(this allows escaping to be avoided)

Also, I think the pq protocol allows the type to be specified/extracted from the query itself, so this too should be allowed to set the type oid. If this is possible, it should override the default 'unknown' type and restrict overrides via the extra call arguments.

q = Postgres.Query("select * from bleh where x = $1::bytea")
# No need to specify the type as an extra argument.

Looking at server side pq should show how this needs to be done.

----------------------------------------------------------------------

You can respond by visiting: 
http://pgfoundry.org/tracker/?func=detail&atid=442&aid=1000306&group_id=1000094


More information about the Python-general mailing list