[odb-users] odb::query problem
luca paganotti
luca.paganotti at gmail.com
Tue May 4 16:56:59 EDT 2021
Hi Boris,
thanks,
nice to know, what I was thinking about was that I could be able to
directly compare mykey objects as I declared them overriding the < operator
as the docs say operator < must be defined for composite values (and to
tell the truth I overrided also >= , <=, > == and != operators for class
mykey), I didn't imagine that I would split the comparing expression using
all the mykey members to this detail.
I wrote the query condition as
myquery::key >= kf && myquery::key <= kt
where kf and kt are myquery instances, instead of
myquery::key.t >= from &&
myquery::key.t <= to &&
myquery::key.s == strval &&
myquery::key.i == intval
but the latter is compiling and working.
Thank you.
----------------------------------------------------------------
-- Dott. Ing. Luca Paganotti
-- Via dei Giardini 9
-- 21035 Cunardo (VA)
-- 393 1346898
----------------------------------------------------------------
-- softech s.r.l. email:
-- luca.paganotti at softechweb.it
-- luca.paganotti at gmail.com
-- https://github.com/lucapaganotti
-- sourceforge email:
-- lucapaganotti at users.sourceforge.net
-- skype name: luca.paganotti
[image: http://it.linkedin.com/in/lucapaganotti]
<http://it.linkedin.com/in/lucapaganotti>
-- ---------------------------------------------------------------
-- Mistakes are portals of discovery - JAAJ
--- --------------------------------------------------------------
On Tue, May 4, 2021 at 3:25 PM Boris Kolpackov <boris at codesynthesis.com>
wrote:
> luca paganotti <luca.paganotti at gmail.com> writes:
>
> > mydb->erase_query<myclass>(myquery::key_ >= kf && myquery::key_ <= kt);
> >
> > anyway g++ complains this way on the last statement:
> >
> > error: ‘key_’ is not a member of ‘myquery’ {aka ‘odb::query<myclass>’}
>
> Right, but query::key is, as described in the documentation (ODB
> removes data member decorations like `m_` and trailing `_` for
> query members).
>
>
> > So it seems, key_ it's not a member of myquery that instead has a key
> > member, using that g++ gives tons of errors mainly saying that operands
> for
> > the overloaded operators are not of the same type
> > the first operand is of type
> >
> > const odb::query_columns<myclass, (odb::database_id)2,
> > odb::access::object_traits_impl<myclass, (odb::database_id)2>
> >::key_class_
> >
> > and the second one is of type mykey.
> >
> > As an additional info, I'm able to use the query functions that get a
> > std::string as parameter, but it will be nice to be able to use also the
> > others.
>
> Key is a composite value (it contains multiple members) so you need
> to pick the member you want to compare to, as in, query::key.member.
>
More information about the odb-users
mailing list