[odb-users] Re: 2-table query

MM finjulhich at gmail.com
Tue Sep 15 16:43:31 EDT 2015


On 14 September 2015 at 21:27, MM <finjulhich at gmail.com> wrote:

>
>
> On 14 September 2015 at 15:45, Boris Kolpackov <boris at codesynthesis.com>
> wrote:
>
>> MM <finjulhich at gmail.com> writes:
>>
>> > odb generates the ?xx files, but it doesn't compile
>>
>> What is the error?!
>>
>>
>> > #pragma db view object(F) object(M: F::get_m)\
>> >   query( F::month.in (M::month1, M::month2) )
>>
>> ODB in() function only works on values, not members. I guess that's
>> the error but I shouldn't be guessing.
>>
>> Boris
>>
>
> I see. I changed that. Thanks.
>
> For the pragma syntax:
>
> *object(**name* [*=* *alias*] [*join-type*] [*:* *join-condition*]*)*
>
> In my case, I have 2 associated objects. F and M.
>
> One can obtain the M object from the F object through this public member
> function
>
> struct F : public Base {
> ...
>    const M* getM() const override;
> };
>
> I couldn't find out how to express the *join-condition.*
> I tried (and used 2 aliases as well) this:
>
> #pragma db view object(::NS::NS1::F = fctrct)   object(::NS::NS2::M =
> fmkt: fctrct::getM)
>
>  The error by the odb compiler is:
>
> error: unable to resolve data member 'getM' specified with db pragma
> object
>
> Basically, I don't understand the syntax of the join-condition. The
> example in the manual show actual data members. I couldn't find an example
> with a function member .
>
> Rds,
>
> getM() in fact, only returns a protected data member     const M* m_;
from struct Base

I change the pragma to

#pragma db view object(::NS::NS1::F = fctrct)   object(::NS::NS2::M = fmkt:
fctrct::m_)
struct Fcurrent {
  ::NS::NS1::F* fctrct;
};

the odb compiler generates the cxx code, but compiling that code fails.

Is the join-condition limited to data members?


More information about the odb-users mailing list