[odb-users] possible regression in odb 2.5 beta with composite values

Boris Kolpackov boris at codesynthesis.com
Thu May 12 01:46:38 EDT 2022


Sebastian Groth <sebastian.groth at enervision.de> writes:

> #pragma db value
> class Name
> {
>   std::string first;
>   std::string last;
> };
> 
> #pragma db object
> class Person
> {
>   #pragma db id auto
>   unsigned long id;
> 
>   Name name;
> };
> 
> 
> #pragma db view table("Person")
> class ViewPerson
> {
>   #pragma db column("name")
>   Name name;
> };
> 
> This will generate a table with the columns: id, name_first, name_last
> 
> odb 2.4 generates a select statement for the view with column names name_first and name_last
> odb 2.5 generates a select statement for the view with column names namefirst and namelast

This is actually a bug fix[1] that makes the column name derivation
consistent across objects and views. Consider how the two versions
behave if you add an explicit column prefix in Person:

#pragma db object
class Person
{
  #pragma db id auto
  unsigned long id;

  #pragma db column("name")
  Name name;
};

To fix your original example would need to add the underscore in
ViewPerson:

#pragma db view table("Person")
class ViewPerson
{
  #pragma db column("name_")
  Name name;
};

[1] https://scm.codesynthesis.com/cgit/odb/odb/commit/?id=de130e93d8b2c026732211e67b6f31157f1b7e87



More information about the odb-users mailing list