Can someone have example of this?
Example is
class TownDetail(object):
def __init__(self, name, value):
self.name = name
self.value = value
def __composite_values__(self):
return self.name, self.value
def __eq__(self, other):
return isinstance(other, self.__class__) and\
make_dump(self) == make_dump(other)
def __ne__(self, other):
return not self.__eq__(other)
class Address(object):
def __init__(self, name, value, towndetail):
self.name = name
self.value = value
self.towndetail = towndetail
def __composite_values__(self):
return self.name, self.value
def __eq__(self, other):
return isinstance(other, self.__class__) and\
make_dump(self) == make_dump(other)
def __ne__(self, other):
return not self.__eq__(other)
class TestComposite(Base):
__tablename__ = 'test_composite'
id = sqlalchemy.Column(sqlalchemy.types.Integer, primary_key=True)
name = sqlalchemy.Column(sqlalchemy.types.String)
_street_address_name = sqlalchemy.Column(sqlalchemy.types.String)
_street_address_value = sqlalchemy.Column(sqlalchemy.types.Integer)
_street_address_town_detail_name = sqlalchemy.Column(sqlalchemy.types.
String)
_street_address_town_detail_value = sqlalchemy.Column(sqlalchemy.types.
Integer)
towndetail = composite(TownDetail, _street_address_town_detail_name,
_street_address_town_detail_value)
street = composite(Address, _street_address_name, _street_address_value,
towndetail)
test_instance = TestComposite(
name='tratata!', street=Address(name=22, value='values',
towndetail=TownDetail(322, '322')))
Error is
sqlalchemy.exc.ArgumentError: Composite expects Column objects or mapped
attributes/attribute names as arguments, got: <CompositeProperty at
0x7f7aa0a75d68; towndetail>
have some info in here
<https://stackoverflow.com/questions/51864432/sql-alchemy-nested-composite-column-types-and-custom-types>,
but cannot undestand what to do. No access to full example bucket
<https://bitbucket.org/zzzeek/sqlalchemy/issues/4168/nested-composite-column-types>
--
SQLAlchemy -
The Python SQL Toolkit and Object Relational Mapper
http://www.sqlalchemy.org/
To post example code, please provide an MCVE: Minimal, Complete, and Verifiable
Example. See http://stackoverflow.com/help/mcve for a full description.
---
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 https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.