Hi,

Following on the documentation (
http://docs.sqlalchemy.org/en/latest/orm/collections.html?highlight=collection_class#dictionary-collections
)

I seem to understand that attribute_mapped_should verify that the key used
is the same as the mapped attribute. And it does, but only in this case:

item = Item()
item.notes = {
            '*CCC*': Note('AAA', 'atext'),
        }

TypeError: Found incompatible key 'CCC' for value Note(id=None,
item_id=None, keyword=AAA, text=atext); this collection's keying
function requires a key of 'AAA' for this value.

This fails as expected, but the following does not:

item = Item()
item.notes['ccc'] = Note('aaa', 'atext')
print item.notes

{'ccc': Note(id=None, item_id=None, keyword=aaa, text=atext)}

item = Item()
item.notes.update({'ccc': Note('aaa', 'atext')})
print item.notes

{'ccc': Note(id=None, item_id=None, keyword=aaa, text=atext)}


I am thinking in implementing a custom collection class just to detect
those errors.
Am I missing something?

Thanks in advance :)

Pau.

-- 
----------------------------------
Pau Tallada Crespí
Dep. d'Astrofísica i Cosmologia
Port d'Informació Científica (PIC)
Tel: +34 93 586 8233
----------------------------------

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to