# Generated by ORMatic

from __future__ import annotations
from sqlalchemy import Column, ForeignKey, Integer, String, Float, Boolean, DateTime, Enum, JSON
from sqlalchemy.orm import relationship, Mapped, mapped_column, DeclarativeBase

{% for import in ormatic.imported_modules %}
import {{ import }}
{% endfor %}


from krrood.ormatic.dao import DataAccessObject
from krrood.ormatic.custom_types import TypeType

class Base(DeclarativeBase):
    type_mappings = {
    {% for key, value in ormatic.type_annotation_map.items() %}
        {{ key }}: {{ value }},
    {% endfor %}
    }


{% for table in ormatic.wrapped_tables.values() %}
class {{ table.tablename }}({{ table.base_class_name }}, DataAccessObject[{{ table.wrapped_clazz.clazz.__module__ }}.{{ table.wrapped_clazz.clazz.__name__ }}]):

    __tablename__ = '{{ table.tablename }}'

    {{ table.primary_key }}


    {% for column in table.builtin_columns %}
    {{ column }}
    {% endfor %}

    {% for column in table.custom_columns %}
    {{ column }}
    {% endfor %}

    {% for column in table.foreign_keys %}
    {{ column }}
    {% endfor %}

    {% for column in table.relationships %}
    {{ column }}
    {% endfor %}

    {% if table.mapper_args %}
    __mapper_args__ = {
    {% for key, value in table.mapper_args.items() %}
        {{ key }}: {{ value }},
    {% endfor %}
    }
    {% endif %}

{% endfor %}
