# plateforme.database
# -------------------
# Copyright (c) 2023 Plateforme
# This module is part of Plateforme and is released under the MIT License.
# For the full license text, see the LICENSE file at the root directory of the
# project repository or visit https://opensource.org/license/mit.

"""
This module provides tools for database management within the Plateforme
framework, utilizing SQLAlchemy to enable both synchronous and asynchronous
operations. It offers comprehensive support for database interactions,
including engine configuration, session management, query construction,
and ORM capabilities, enhancing efficiency and scalability in database
operations.
"""

from .core.database.base import inspect
from .core.database.engines import (
    async_engine_from_config,
    create_async_engine,
    create_engine,
    create_mock_engine,
    engine_from_config,
)
from .core.database.expressions import (
    alias,
    all_,
    and_,
    any_,
    asc,
    between,
    bindparam,
    case,
    cast,
    collate,
    column,
    cte,
    delete,
    desc,
    distinct,
    except_,
    except_all,
    exists,
    extract,
    false,
    func,
    funcfilter,
    insert,
    intersect,
    intersect_all,
    join,
    label,
    lambda_stmt,
    lateral,
    literal,
    literal_column,
    modifier,
    not_,
    null,
    nulls_first,
    nulls_last,
    nullsfirst,
    nullslast,
    or_,
    outerjoin,
    outparam,
    over,
    select,
    table,
    tablesample,
    text,
    true,
    tuple_,
    type_coerce,
    union,
    union_all,
    update,
    values,
    within_group,
)
from .core.database.orm import (
    contains_eager,
    defaultload,
    defer,
    immediateload,
    joinedload,
    lazyload,
    load_only,
    noload,
    raiseload,
    selectin_polymorphic,
    selectinload,
    subqueryload,
    undefer,
    undefer_group,
    with_expression,
    with_polymorphic,
)
from .core.database.routing import DatabaseRouter
from .core.database.sessions import (
    AsyncSession,
    AsyncSessionFactory,
    Session,
    SessionFactory,
    async_session_factory,
    async_session_manager,
    session_factory,
    session_manager,
)
from .core.database.types import (
    ARRAY,
    BIGINT,
    BINARY,
    BLOB,
    BOOLEAN,
    CHAR,
    CLOB,
    DATE,
    DATETIME,
    DECIMAL,
    DOUBLE,
    DOUBLE_PRECISION,
    FLOAT,
    INTEGER,
    JSON,
    NCHAR,
    NUMERIC,
    NVARCHAR,
    REAL,
    SMALLINT,
    TEXT,
    TIME,
    TIMESTAMP,
    UUID,
    VARBINARY,
    VARCHAR,
    BinaryEngine,
    BooleanEngine,
    DateEngine,
    DateTimeEngine,
    DefaultEngine,
    EnumEngine,
    IntegerEngine,
    IntervalEngine,
    JsonEngine,
    NumericEngine,
    StringEngine,
    TimeEngine,
    UuidEngine,
)
from .core.database.utils import (
    apply_filter,
    apply_reference,
    apply_sort,
    build_options,
    build_query,
)

__all__ = (
    # Base
    'inspect',
    # Engines (async)
    'async_engine_from_config',
    'create_async_engine',
    # Engines (sync)
    'create_engine',
    'create_mock_engine',
    'engine_from_config',
    # Expressions
    'alias',
    'all_',
    'and_',
    'any_',
    'asc',
    'between',
    'bindparam',
    'case',
    'cast',
    'collate',
    'column',
    'cte',
    'delete',
    'desc',
    'distinct',
    'except_',
    'except_all',
    'exists',
    'extract',
    'false',
    'func',
    'funcfilter',
    'insert',
    'intersect',
    'intersect_all',
    'join',
    'label',
    'lambda_stmt',
    'lateral',
    'literal',
    'literal_column',
    'modifier',
    'not_',
    'null',
    'nulls_first',
    'nulls_last',
    'nullsfirst',
    'nullslast',
    'or_',
    'outerjoin',
    'outparam',
    'over',
    'select',
    'table',
    'tablesample',
    'text',
    'true',
    'tuple_',
    'type_coerce',
    'union',
    'union_all',
    'update',
    'values',
    'within_group',
    # ORM
    'contains_eager',
    'defaultload',
    'defer',
    'immediateload',
    'joinedload',
    'lazyload',
    'load_only',
    'noload',
    'raiseload',
    'selectin_polymorphic',
    'selectinload',
    'subqueryload',
    'undefer',
    'undefer_group',
    'with_expression',
    'with_polymorphic',
    # Routing
    'DatabaseRouter',
    # Sessions (async)
    'AsyncSession',
    'AsyncSessionFactory',
    'async_session_factory',
    'async_session_manager',
    # Sessions (sync)
    'Session',
    'SessionFactory',
    'session_factory',
    'session_manager',
    # Types (concrete)
    'ARRAY',
    'BIGINT',
    'BINARY',
    'BLOB',
    'BOOLEAN',
    'CHAR',
    'CLOB',
    'DATE',
    'DATETIME',
    'DECIMAL',
    'DOUBLE',
    'DOUBLE_PRECISION',
    'FLOAT',
    'INTEGER',
    'JSON',
    'NCHAR',
    'NUMERIC',
    'NVARCHAR',
    'REAL',
    'SMALLINT',
    'TEXT',
    'TIME',
    'TIMESTAMP',
    'UUID',
    'VARBINARY',
    'VARCHAR',
    # Types (engine)
    'BinaryEngine',
    'BooleanEngine',
    'DateEngine',
    'DateTimeEngine',
    'DefaultEngine',
    'EnumEngine',
    'IntegerEngine',
    'IntervalEngine',
    'JsonEngine',
    'NumericEngine',
    'StringEngine',
    'TimeEngine',
    'UuidEngine',
    # Utilities
    'apply_filter',
    'apply_reference',
    'apply_sort',
    'build_options',
    'build_query',
)
