[odb-users] Adding support for a new sql type

Boris Kolpackov boris at codesynthesis.com
Tue Sep 27 06:21:56 EDT 2011


Hi Alexandre,

Alexandre Pretyman <alexandre.pretyman at gmail.com> writes:

> What I need to do is call a function in the DB query on the GEOMETRY type
> column "asText(column)" and with the resulting string I would use functions
> in GEOS to convert it from the text to a GEOS Geometry object.
> 
> I still know little about the subject, but would this be possible in ODB?

Hm, interesting question. Generally, adding support for a new SQL type
without modifying the ODB compiler will be tricky. A column's SQL type
determines many aspects of how the data is transferred from the database
to the object and from the object to the database, especially if we use
the binary protocol, which is the case with PostgreSQL.

Now, if the new type is "interfaced with" using one of the existing SQL
types (which, as I understand, is the case with GEOMETRY), then this
could be easier. Then we could probably "map" the new type to the
existing type. We would probably also need to specify to/from
conversion expressions (ST_GeomFromText/ST_asText in case of GEOMETRY?)
that will need to be applied in the INSERT, UPDATE, and SELECT statements
generated by the ODB compiler. I think this might work. Can you show
some examples of typical INSERT/UPDATE/SELECT statements involving the
GEOMETRY type?

Once this is supported, mapping the text representation of GEOMETRY data
to a suitable C++ type will be straightforward.

Boris



More information about the odb-users mailing list