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

Alexandre Pretyman alexandre.pretyman at gmail.com
Fri Sep 23 02:15:05 EDT 2011


Здравствуйте Boris,

I'm a student from Brazil evaluating ODB for a university project and I'm
wondering how would I go about adding support for the GEOMETRY sql type of
the PostGis extension for PostgreSQL and mapping it to a GEOS Geometry
type.

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? If
so, are there any source files I could poke around to get some guidelines?

The furthest I got was examining the QDateTime as an example in:
               libodb-qt-1.5.0/odb/qt/date-time/pgsql/default-mapping.hxx
               libodb-qt-1.5.0/odb/qt/date-time/pgsql/qdate-time-traits.hxx

and seeing that it's mapped to a TIMESTAMP by default on default-mapping.hxx
line 26:
#pragma db value(QDateTime) type("TIMESTAMP") null

and how you manipulate the QDateTime value in qdate-time-traits.hxx
by setting the value on line 40:
        set_value (QDateTime& v, long long i, bool is_null)

and setting the image on line 53:
        set_image (long long& i, bool& is_null, const QDateTime& v)

However I could not pin point where the TIMESTAMP sql type get's registered
as an sql_type nor where it gets converted to a "long long", which I thought
I could use as an example to register the GEOMETRY as an sql_type
and convert it to std::string and use set_value and set_image functions to
transform it into a GEOS Geometry.

Any help is appreciated,
-- 
Alexandre Pretyman


More information about the odb-users mailing list