On Sat, Jan 14, 2012 at 01:26:08PM +1300, Michael Koziarski wrote: > On Saturday, 14 January 2012 at 12:44 PM, Aaron Patterson wrote: > > It depends on the level of API people want to use. For example, PG > > always returns strings. That means we need to know the types for which > > we're querying. Say someone does this against pg: > > > > connection.execute 'select 1.2 + 20' > > > > we can't know to cast that to a float. Even doing regexp tests will be > > wrong since someone may have tried to select a string. > > > > > > Most database protocols include type information along with the values > themselves, the drivers should be able to do introspection and 'magically' > cast them completely removing our casting from the picture.
I'm not sure if the pg "over the wire" protocol contains that information, but I can tell you that libpg doesn't provide functions for casting to C types (that I can find). See PQgetvalue: http://www.postgresql.org/docs/6.4/static/libpq-chapter16943.htm -- Aaron Patterson http://tenderlovemaking.com/
pgp0jZ5hePwSx.pgp
Description: PGP signature
