[odb-users] Problem with bidirectional relationship

Boris Kolpackov boris at codesynthesis.com
Thu Feb 1 04:11:16 EST 2024


Aldo Laiseca <alaiseca at gmail.com> writes:

> #A.h
> 
> class B;
> 
> #pragma db object table(“TABLE_A”)
> class A {
> ...
> };
> 
> 
> # B.h
> 
> #pragma db object table(“TABLE_B")
> class B {
> ...
> };
> 
> My odb scripts for these classes look like this:
> 
> odb -I /usr/local/include -d pgsql --generate-query --odb-epilogue "#include \”B.h\"" --std c++17 A.h
> odb -I /usr/local/include -d pgsql --generate-query --std c++17 B.h
> 
> However, my script fails saying this: 
> 
> A.h:45:55: error: unable to map C++ type '::std::__new_allocator< ::odb::lazy_weak_ptr< ::B > >::value_type' used in data member ‘b' to a PostgreSQL database type

First thing that comes to mind is that A and B do not use std::shared_ptr
as object pointer (which is a requirement to be able to use 
odb::lazy_{shared,weak}_ptr in object relationships). For background,
see:

https://www.codesynthesis.com/products/odb/doc/manual.xhtml#3.3



More information about the odb-users mailing list