[odb-users] Inverse pragma using composite value types
Markus Klemm
markus at markusklemm.net
Mon Sep 7 08:19:17 EDT 2015
Hi again everyone,
I have the problem that the inverse pragma don't work with composite value types. I fails to parse the . operator correctly.
The problematic scenario is that object A's ID is part of object B's composite ID.
I'm of course not sure if ODB ever had in mind to offer that solution or if it is expected that I use a odb view.
Example (or link here for syntax highlighting https://gist.github.com/Superlokkus/44d69167ca1a82e150e9 )
Given tables:
create table measurement_set(
measurement_id uniqueidentifier primary key
)
create table measurement_parameter(
measurement_set_id uniqueidentifier not null foreign key references measurement_set(id_col),
parameter_name nvarchar(32) not null,
--other columns
constraint pk primary key(measurement_set_id,parameter_name)
)
I suppose the solution should be:
struct measurement_set;
#pragma db value
struct measurement_parameter_key{
#pragma db column("measurement_set_id") type("uniqueidentifier") not_null
boost::uuids::uuid measurement_set_id;
#pragma db column("parameter_name") type("nvarchar(32)") not_null
std::wstring parameter_name;
};
#pragma db object table("measurement_parameter")
struct measurement_parameter{
#pragma db id
measurement_parameter_key measurement_set_id;
/* Other members*/
};
#pragma db object table("measurement_set")
struct measurement_set {
#pragma db column("measurement_id") type("uniqueidentifier") id not_null
boost::uuids::uuid measurement_id;
#pragma db inverse(measurement_set_id.measurement_set_id)
//^ odb parser: error: ')' expected at the end of db pragma inverse
std::set<measurement_parameter> parameters;
/* Other members*/
};
Regards and Boris thank you especially in advance for your time and patience
Markus Klemm
More information about the odb-users
mailing list