[odb-users] table_name in ODB 2.2.0

Reza Jahanbakhshi reza.jahanbakhshi at gmail.com
Mon May 6 09:18:52 EDT 2013


Dear Boris,

First thanks for you answer. Due to limits in ODB query language we use a
lot of custom queries in our project. Wouldn't it be nice to have a cleaner
syntax to access object table name in ODB queries? Currently I'm thinking
about writing a wrapper template function like odb_table_name<Object> ()
and use is in our project. What do you suggest? Are you considering to put
such facility in ODB in future?
Again thank to you all for this great ORM system.


On Mon, May 6, 2013 at 11:17 AM, Boris Kolpackov <boris at codesynthesis.com>wrote:

> Hi Reza,
>
> Reza Jahanbakhshi <reza.jahanbakhshi at gmail.com> writes:
>
> > In ODB 2.1.0 I could use object_traits<class>::table_name to find
> physical
> > name of table in database to use in custom queries. But ODB 2.2.0 there
> is
> > no table_name member in object_trait class. What is the preferred method
> > to achieve this?
>
> In ODB 2.2.0 we've added multi-database support which required some
> changes to the traits structure. The table name is still there, but
> it is now in the database-specific object_traits_impl class rather
> than common object_traits (it is possible to map the same class to
> different tables in different databases).
>
> If you don't use multi-database support, then you can access the
> table name like this:
>
> odb::object_traits_impl<my_object, odb::id_common>::table_name
>
> If you do use multi-database support, then you will need to specify
> the database, for example:
>
> odb::object_traits_impl<my_object, odb::id_sqlite>::table_name
>
> Boris
>


More information about the odb-users mailing list