-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Currently it seems serialization with attributes defined in mixins wont work:
# mixin
from sqlalchemy import BigInteger
from sqlathanor import Column
class PrimaryMixin(object):
"""
Mixin for adding a autoincrementing PK
"""
id: int = Column(BigInteger, primary_key=True, autoincrement=True, supports_dict=True)#concrete class
from sqlalchemy import UnicodeText, BigInteger, ForeignKey
from sqlathanor import Column, relationship
from model import deferred_reflection, base
from model.mixins.primary import PrimaryMixin
class Example(PrimaryMixin, base, deferred_reflection):
"""
Example Table
"""
__tablename__ = "example"
name: str = Column(UnicodeText, comment="name", supports_dict=True)#test case
class ExampleTestCase(unittest.TestCase):
def test_serialize_to_dict(self):
m = Example(name="Test", id=4711)
self.assertEqual(m.to_dict(), {
'id': 4711,
'name': 'Test'
})what am i doing wrong here? The id is correctly filled and setup by SQLAlchemy itself, but the serialization definition isnt respected.
i just followed the working/common https://docs.sqlalchemy.org/en/13/orm/extensions/declarative/mixins.html#mixing-in-columns to keep my models dry
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working