[odb-users] Multiple column primary key (id)

Tolga HOŞGÖR fasdfasdas at gmail.com
Wed May 6 07:04:05 EDT 2015


Hello,

I have looked through the documentation but I think ODB does not support
multi-column primary key. I'd like to use a std::pair as a key and PSQL
supports the following syntax:

CREATE TABLE example (
    a integer,
    b integer,
    c integer,
    *PRIMARY KEY (a, c)*
);

I tried using virtuals to achieve this:

#pragma db id transient

  std::pair<std::string, Provider> id_;

#pragma db member(first) virtual(std::string) access(id_.first)

#pragma db member(last) virtual(std::string) access(id_.second)


But it does not compile. Do you have any idea if I can achieve this or not?


Thanks,

Tolga.


More information about the odb-users mailing list