[odb-users] Query std::vector or object relationships

Boris Kolpackov boris at codesynthesis.com
Mon Jul 4 12:09:21 EDT 2011

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")


odb::query<UtitlityClass>::comment[0] == "some_string"



More information about the odb-users mailing list