# Path: pynYNAB/schema/types.py
# class ArrayType(TypeDecorator):
#     """ Sqlite-like does not support arrays.
#         Let's use a custom type decorator.
# 
#         See http://docs.sqlalchemy.org/en/latest/core/types.html#sqlalchemy.types.TypeDecorator
#     """
#     impl = String
# 
#     def process_bind_param(self, value, dialect):
#         return json.dumps(value)
# 
#     def process_result_value(self, value, dialect):
#         return json.loads(value)
# 
#     def copy(self, **kw):
#         return ArrayType(self.impl.length)


from sqlalchemy import Boolean
from sqlalchemy import Column
from sqlalchemy import DateTime
from sqlalchemy import ForeignKey
from sqlalchemy import String
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.orm import relationship
from pynYNAB.schema.Entity import Entity, Base
from pynYNAB.schema.types import ArrayType



class CatalogEntity(Entity):
    @declared_attr
    def parent_id(self):
        return Column(ForeignKey('catalog.id'))

    @declared_attr
    def parent(self):
        return relationship('Catalog')


class CatalogBudget(Base, CatalogEntity):
    budget_name = Column(String)
    created_at = Column(DateTime)


class User(Base, CatalogEntity):

# Path: pynYNAB/schema/types.py
# class ArrayType(TypeDecorator):
#     """ Sqlite-like does not support arrays.
#         Let's use a custom type decorator.
# 
#         See http://docs.sqlalchemy.org/en/latest/core/types.html#sqlalchemy.types.TypeDecorator
#     """
#     impl = String
# 
#     def process_bind_param(self, value, dialect):
#         return json.dumps(value)
# 
#     def process_result_value(self, value, dialect):
#         return json.loads(value)
# 
#     def copy(self, **kw):
#         return ArrayType(self.impl.length)


# Path: pynYNAB/schema/catalog.py
from sqlalchemy import Boolean
from sqlalchemy import Column
from sqlalchemy import DateTime
from sqlalchemy import ForeignKey
from sqlalchemy import String
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.orm import relationship
from pynYNAB.schema.Entity import Entity, Base
from pynYNAB.schema.types import ArrayType




class CatalogEntity(Entity):
    @declared_attr
    def parent_id(self):
        return Column(ForeignKey('catalog.id'))

    @declared_attr
    def parent(self):
        return relationship('Catalog')


class CatalogBudget(Base, CatalogEntity):
    budget_name = Column(String)
    created_at = Column(DateTime)


class User(Base, CatalogEntity):

    username = Column(String)