[odb-users] tagging a base struct member as id

MM finjulhich at gmail.com
Tue Jun 16 09:59:38 EDT 2015


As far as I can see from the manual, this should be possible:

namespace N {      //// in header1 in ~/mydir
struct Base {
  std::uint32_t  id;
  virtual ~Base() =0;
};
}
namespace N {     /// in header2 ~/mydir , includes header1
struct Derived : public Base {
   ...
};
}
namespace N {      //// in header3 in ~/mydir_odb, includes header2 from
~/mydir
#pragma db object(Derived) table("mytable") definition
#pragma db member(Derived::id) id auto
}

Running odb 2.3.0 like this:
odb -d sqlite --sqlite-override-null --std c++11 --profile boost
--omit-drop --generate-schema-only --schema-format sql --at-once
--changelog-dir <somedir> -I~/mydir --input-name <somename> ....
~/mydir_odb/<header3>.hpp

yields this error:

header2.hpp:39:8: error: no data member designated as an object id
header2:39:8: info: use '#pragma db id' to specify an object id member
header2:39:8: info: or explicitly declare that this persistent class has no
object id with '#pragma db object no_id'


This looks similar to the permanent_employee example in the manual....
But I am surely missing something obvious, apologies if so.

Rds,

MM


More information about the odb-users mailing list