[odb-users] Querying entity's container
Adnan RIHAN
axel50397 at gmail.com
Wed Mar 25 12:41:47 EDT 2015
Hi,
On 25 mars 2015 at 14:35:17, Boris Kolpackov (boris at codesynthesis.com(mailto:boris at codesynthesis.com)) wrote:
> then you should use QSharedPointer in
> relationships (the first issue) or when getting a result from
> calls like query_one() (second issue).
This is what I do. But the issue seems not being the return of my function, but the return inside result.cxx
/usr/local/include/odb/result.txx:19:20: error: no viable conversion from 'typename view_traits<product_view>::pointer_type' (aka 'QSharedPointer< ::product_view>') to 'pointer_type' (aka 'product_view *')
pointer_type o (i.load ());
^ ~~~~~~~~~
In my methods, I always use QSharedPointer. The thing is that I’m trying with query_one() but the same call with query() is working (then I return the first result if it’s not null).
This works:
> QSharedPointer<product_view> one(new product_view);
> try {
> odb::result<product_view> r(this->m_db->query<product_view>(
> odb::query<product_view>::barcode::barcode == scan
> ));
> typename odb::result<product_view>::iterator i(r.begin());
>
> if (i != r.end()) {
> *one = *i;
> }
> } catch (const odb::exception &e) {}
> return (one);
But this, doesn’t and produce the error:
> QSharedPointer<product_view> one;
> try {
> one.reset(this->m_db->query_one<product_view>(
> odb::query<product_view>::barcode::barcode == scan
> ));
> } catch (const odb::exception &e) {}
> return (one);
In the two functions, the template is « product_view » and the return type is a QSharedPointer<T>
--
Cordialement, Adnan RIHAN.
Directeur-Gérant de Eolis-Software, société de services informatiques.
GPG: 5675-62BA (https://keybase.io/max13/key.asc)
-> Si vous n'utilisez pas GPG mais souhaitez quand même m’envoyer un e-mail chiffré: (https://encrypt.to/0x567562BA).
More information about the odb-users
mailing list