[odb-users] tagging a base struct member as id
MM
finjulhich at gmail.com
Thu Jun 18 05:21:40 EDT 2015
On 17 June 2015 at 11:44, Boris Kolpackov <boris at codesynthesis.com> wrote:
> Hi,
>
> MM <finjulhich at gmail.com> writes:
>
> > struct Base {
> > std::uint32_t id;
> > virtual ~Base() =0;
> > };
> >
> > struct Derived : public Base {
> > ...
> > };
> >
> > #pragma db object(Derived) table("mytable") definition
> > #pragma db member(Derived::id) id auto
>
> I believe the problem is due to the id member being in Base,
> which is transient. If having it transient is the intention,
> then you can still achieve what you want using a virtual data
> member:
>
> #pragma db member(Derived::id) virtual(std::uint32_t) access(Base::id) id
> auto
>
> Boris
>
derived_odb.hpp:33:12: error: virtual data member declaration 'id'
conflicts with a previous declaration
base.hpp:23:22: info: 'id' was previously declared here
the sql table for derived has a column named 'id'
More information about the odb-users
mailing list