[odb-users] Query std::vector or object relationships
Jan Küntzer
kuentzer at googlemail.com
Mon Jul 4 12:35:58 EDT 2011
Hi Boris
Thanks for the fast reply
You are right, what i would like to have in this example is the contains function.
Another nice thing would be:
For a vector of pointers, e.g. vector<Xref*> xrefs and Xref with string attribut db, it would be nice to have a chance for checking if one of the xrefs has the stated attribute. Something like
odb::query<UtitlityClass>::xrefs::db = "some_string"
?
Jan
Am 04.07.2011 um 18:09 schrieb Boris Kolpackov <boris at codesynthesis.com>:
> Hi Jan,
>
> Jan Kuentzer <kuentzer at googlemail.com> writes:
>
>> But the class UtilityClass has a std::vector<std::string> attribute called
>> "comment" and for this the following gives the mentioned compile error:
>> odb::query<UtitliyClass> q (odb::query<UtitlityClass>::comment ==
>> "some_string");
>
> There is currently no support for using container members as predicates
> in the C++-integrated queries. As a workaround for the meantime you can
> use native queries (which are essentially the SQL WHERE text).
>
> Also, for when we get to supporting this, it would be helpful to know what
> kind operations you expect to be able to perform on container. The one
> that you use above doesn't make much sense since a vector of strings
> cannot be meaningfully compared to a string. Maybe something like this:
>
> odb::query<UtitlityClass>::comment.contains ("some_string")
>
> Or
>
> odb::query<UtitlityClass>::comment[0] == "some_string"
>
> ?
>
> Boris
More information about the odb-users
mailing list