[odb-users] Unique index in abstract class

Boris Kolpackov boris at codesynthesis.com
Thu Oct 1 06:18:25 EDT 2020


Патрушев Данил Андреевич <d.patrushev at prosoftsystems.ru> writes:

> I have an abstract database class inherited by a bunch of concrete database
> classes. The shared abstract class contains a data member which, according
> to the plan, must have a unique index. If we provide a definition of the
> index inside the abstract class ODB generates unique indices sharing the
> same name (say, AbstractClassName_columnName_i) which is not good. We tried
> putting the index specification into the concrete classes (by referring to
> the base class member in the pragma) and this approach actually worked until
> recently.  Latest modifications in our code base introduced new dependencies
> between database classes which made the dreaded same name index definition
> appear again (alongside the good definition).

I am surprised you haven't also gotten table name conflicts in this case
(or maybe I am not seeing the complete picture from your description).

There are two mechanisms in ODB for dealing with this kind of issues:
database schemas (Section 14.1.8) and table prefixes (Section 14.5.2).
I would suggest that you try the simpler table prefix approach to see
if you can make it work.

Another idea (that would work best if the conflicts do not happen in
the same header files), is to use the --index-regex option to mangle
index names to make them unique.



More information about the odb-users mailing list