[odb-users] std::map<Entity, int>

Adnan RIHAN axel50397 at gmail.com
Wed Apr 15 02:43:42 EDT 2015


Hello there !

I’m coming back to this problem, from a long time ago.

On 24 novembre 2014 at 11:16:00, Boris Kolpackov (boris at codesynthesis.com(mailto:boris at codesynthesis.com)) wrote:

> #pragma db value
> struct OfferKey
> {
> QSharedPointer o;
> };
>  
> inline bool
> operator< (const OfferKey& x, const OfferKey& y) {return x.o < y.o;}

I didn’t notice earlier because I didn’t use this class yet (the Invoice class). Now I’ve just tried to insert an invoice, and I have a runtime ODB-Sqlite error:

> 1: table invoice_carts has no column named offer_id_o

As a reminder, I wanted to insert a map with an entity as the key. Boris pointed out that it wasn’t supported BUT wrapping the entity around a struct worked. Indeed, but naturally, ODB is trying to insert a wrong column name, and I don’t know how to #pragma it.

Here is what I have so far (concerning only the map):
> typedef QMap<OfferKey, quint16>    Cart;
> 
> #   pragma  db  value(OfferKey)
> 
> #   pragma  db  member(Invoice::m_cart)  table("invoice_carts") \
>                                          id_column("invoice_id") \
>                                          key_column("offer_id") \
>                                          key_type("UNSIGNED INT") \
>                                          value_column("quantity")

And of course, if I add that line below « value(OfferKey) »:
> #   pragma  db  member(OfferKey::o)             transient

It’s an odb compiler error: no persistent data members in the class... What should I do there?

Thank you for your help.
--  
Cordialement, Adnan RIHAN.

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