diff --git a/.claude/agents/expert.md b/.claude/agents/expert.md index 2c1cb0eb4..7ee6148e7 100644 --- a/.claude/agents/expert.md +++ b/.claude/agents/expert.md @@ -109,7 +109,7 @@ from sqlspec.protocols import SupportsWhere from sqlspec.utils.type_guards import supports_where if TYPE_CHECKING: - from sqlspec.core.statement import Statement + from sqlspec.core import Statement def execute_query(stmt: "Statement", params: dict[str, Any] | None = None) -> list[dict[str, Any]]: """Execute SQL query with optional parameters. diff --git a/.claude/agents/testing.md b/.claude/agents/testing.md index 904435f92..228806e8c 100644 --- a/.claude/agents/testing.md +++ b/.claude/agents/testing.md @@ -64,7 +64,7 @@ Read("docs/guides/testing/testing.md") # tests/unit/test_core/test_statement.py import pytest -from sqlspec.core.statement import Statement +from sqlspec.core import Statement def test_statement_creation(): diff --git a/AGENTS.md b/AGENTS.md index e4ca5e33a..1bd927d35 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1310,7 +1310,7 @@ SQLSpec implements Apache Arrow support through a dual-path architecture: native Override `select_to_arrow()` in adapter's driver class: ```python -from sqlspec.core.result import create_arrow_result +from sqlspec.core import create_arrow_result from sqlspec.utils.module_loader import ensure_pyarrow class NativeArrowDriver(AsyncDriverAdapterBase): @@ -1416,7 +1416,7 @@ UUID → utf8 (converted to string) Use `create_arrow_result()` for consistent result wrapping: ```python -from sqlspec.core.result import create_arrow_result +from sqlspec.core import create_arrow_result # Create ArrowResult from Arrow Table result = create_arrow_result(arrow_table, rows_affected=arrow_table.num_rows) diff --git a/docs/contributing/creating_adapters.rst b/docs/contributing/creating_adapters.rst index 697d5d62e..ed24b56f6 100644 Binary files a/docs/contributing/creating_adapters.rst and b/docs/contributing/creating_adapters.rst differ diff --git a/docs/examples/adapters/psycopg/connect_sync.py b/docs/examples/adapters/psycopg/connect_sync.py index 1efdc9f90..f4de9b809 100644 --- a/docs/examples/adapters/psycopg/connect_sync.py +++ b/docs/examples/adapters/psycopg/connect_sync.py @@ -3,7 +3,7 @@ import os from sqlspec.adapters.psycopg import PsycopgSyncConfig -from sqlspec.core.statement import SQL +from sqlspec.core import SQL __all__ = ("main",) diff --git a/docs/examples/frameworks/fastapi/aiosqlite_app.py b/docs/examples/frameworks/fastapi/aiosqlite_app.py index 6da3c4406..901818062 100644 --- a/docs/examples/frameworks/fastapi/aiosqlite_app.py +++ b/docs/examples/frameworks/fastapi/aiosqlite_app.py @@ -8,7 +8,7 @@ from docs.examples.shared.configs import aiosqlite_registry from docs.examples.shared.data import ARTICLES, CREATE_ARTICLES from sqlspec.adapters.aiosqlite import AiosqliteConfig, AiosqliteDriver -from sqlspec.core.statement import SQL +from sqlspec.core import SQL __all__ = ("get_session", "list_articles", "main", "on_startup", "seed_database") diff --git a/docs/examples/frameworks/fastapi/sqlite_app.py b/docs/examples/frameworks/fastapi/sqlite_app.py index 6c9ffee9f..f41a4cbbb 100644 --- a/docs/examples/frameworks/fastapi/sqlite_app.py +++ b/docs/examples/frameworks/fastapi/sqlite_app.py @@ -9,7 +9,7 @@ from docs.examples.shared.configs import sqlite_registry from docs.examples.shared.data import ARTICLES, CREATE_ARTICLES from sqlspec.adapters.sqlite import SqliteConfig, SqliteDriver -from sqlspec.core.statement import SQL +from sqlspec.core import SQL __all__ = ("get_session", "list_articles", "main", "on_startup", "seed_database") diff --git a/docs/examples/frameworks/flask/sqlite_app.py b/docs/examples/frameworks/flask/sqlite_app.py index 4718fe5a5..0c4197843 100644 --- a/docs/examples/frameworks/flask/sqlite_app.py +++ b/docs/examples/frameworks/flask/sqlite_app.py @@ -5,7 +5,7 @@ from docs.examples.shared.configs import sqlite_registry from docs.examples.shared.data import ARTICLES, CREATE_ARTICLES from sqlspec.adapters.sqlite import SqliteConfig -from sqlspec.core.statement import SQL +from sqlspec.core import SQL __all__ = ("list_articles", "main", "seed_database") diff --git a/docs/examples/frameworks/litestar/aiosqlite_app.py b/docs/examples/frameworks/litestar/aiosqlite_app.py index 92e051141..39ba0c49d 100644 --- a/docs/examples/frameworks/litestar/aiosqlite_app.py +++ b/docs/examples/frameworks/litestar/aiosqlite_app.py @@ -8,7 +8,7 @@ from docs.examples.shared.configs import aiosqlite_registry from docs.examples.shared.data import ARTICLES, CREATE_ARTICLES from sqlspec.adapters.aiosqlite import AiosqliteConfig, AiosqliteDriver -from sqlspec.core.statement import SQL +from sqlspec.core import SQL from sqlspec.extensions.litestar import SQLSpecPlugin registry = aiosqlite_registry() diff --git a/docs/examples/frameworks/litestar/duckdb_app.py b/docs/examples/frameworks/litestar/duckdb_app.py index dc9bd6bb0..3a37764d4 100644 --- a/docs/examples/frameworks/litestar/duckdb_app.py +++ b/docs/examples/frameworks/litestar/duckdb_app.py @@ -7,7 +7,7 @@ from docs.examples.shared.configs import duckdb_registry from docs.examples.shared.data import ARTICLES, CREATE_ARTICLES from sqlspec.adapters.duckdb import DuckDBConfig, DuckDBDriver -from sqlspec.core.statement import SQL +from sqlspec.core import SQL from sqlspec.extensions.litestar import SQLSpecPlugin registry = duckdb_registry() diff --git a/docs/examples/frameworks/litestar/sqlite_app.py b/docs/examples/frameworks/litestar/sqlite_app.py index 0eb9a8030..7144a7b85 100644 --- a/docs/examples/frameworks/litestar/sqlite_app.py +++ b/docs/examples/frameworks/litestar/sqlite_app.py @@ -7,7 +7,7 @@ from docs.examples.shared.configs import sqlite_registry from docs.examples.shared.data import ARTICLES, CREATE_ARTICLES from sqlspec.adapters.sqlite import SqliteConfig, SqliteDriver -from sqlspec.core.statement import SQL +from sqlspec.core import SQL from sqlspec.extensions.litestar import SQLSpecPlugin registry = sqlite_registry() diff --git a/docs/examples/frameworks/starlette/aiosqlite_app.py b/docs/examples/frameworks/starlette/aiosqlite_app.py index 595a9d7c1..2202c736f 100644 --- a/docs/examples/frameworks/starlette/aiosqlite_app.py +++ b/docs/examples/frameworks/starlette/aiosqlite_app.py @@ -10,7 +10,7 @@ from docs.examples.shared.configs import aiosqlite_registry from docs.examples.shared.data import ARTICLES, CREATE_ARTICLES from sqlspec.adapters.aiosqlite import AiosqliteConfig -from sqlspec.core.statement import SQL +from sqlspec.core import SQL __all__ = ("list_articles", "main", "seed_database") diff --git a/docs/examples/patterns/multi_tenant/router.py b/docs/examples/patterns/multi_tenant/router.py index 8447fcfee..0a403f62e 100644 --- a/docs/examples/patterns/multi_tenant/router.py +++ b/docs/examples/patterns/multi_tenant/router.py @@ -1,7 +1,7 @@ """Dispatch requests to dedicated SQLite configs per tenant.""" from sqlspec.adapters.sqlite import SqliteConfig -from sqlspec.core.statement import SQL +from sqlspec.core import SQL __all__ = ("TenantRouter", "main") diff --git a/docs/examples/shared/data.py b/docs/examples/shared/data.py index b071a57a4..1f1ef25c2 100644 --- a/docs/examples/shared/data.py +++ b/docs/examples/shared/data.py @@ -1,6 +1,6 @@ """Shared schema and sample rows for documentation examples.""" -from sqlspec.core.statement import SQL +from sqlspec.core import SQL __all__ = ("ARTICLES", "CREATE_ARTICLES") diff --git a/docs/guides/adapters/parameter-profile-registry.md b/docs/guides/adapters/parameter-profile-registry.md index 8d031d76c..b6a2aba92 100644 --- a/docs/guides/adapters/parameter-profile-registry.md +++ b/docs/guides/adapters/parameter-profile-registry.md @@ -30,7 +30,7 @@ Refer to [AGENTS.md](../../AGENTS.md) for the full checklist when touching the r ```python import sqlspec.adapters.duckdb # Triggers profile registration -from sqlspec.core.parameters import get_driver_profile, build_statement_config_from_profile +from sqlspec.core import get_driver_profile, build_statement_config_from_profile profile = get_driver_profile("duckdb") config = build_statement_config_from_profile(profile) diff --git a/docs/guides/architecture/architecture.md b/docs/guides/architecture/architecture.md index eaf437362..2caa07e36 100644 --- a/docs/guides/architecture/architecture.md +++ b/docs/guides/architecture/architecture.md @@ -223,7 +223,7 @@ The current parameter processing system uses `ParameterStyleConfig` integrated w ```python # Current parameter configuration -from sqlspec.core.parameters import ParameterStyle, ParameterStyleConfig +from sqlspec.core import ParameterStyle, ParameterStyleConfig parameter_config = ParameterStyleConfig( default_parameter_style=ParameterStyle.QMARK, diff --git a/docs/guides/architecture/data-flow.md b/docs/guides/architecture/data-flow.md index a971714bc..72002ab13 100644 --- a/docs/guides/architecture/data-flow.md +++ b/docs/guides/architecture/data-flow.md @@ -361,8 +361,8 @@ To add support for a new database using the enhanced architecture: ```python from sqlspec.driver import SyncDriverAdapterBase # or AsyncDriverAdapterBase -from sqlspec.core.parameters import ParameterStyle, ParameterStyleConfig -from sqlspec.core.statement import StatementConfig +from sqlspec.core import ParameterStyle, ParameterStyleConfig +from sqlspec.core import StatementConfig class MyDatabaseDriver(SyncDriverAdapterBase): dialect = "mydatabase" diff --git a/docs/guides/performance/mypyc.md b/docs/guides/performance/mypyc.md index 4eeb7ec35..e699554f6 100644 --- a/docs/guides/performance/mypyc.md +++ b/docs/guides/performance/mypyc.md @@ -704,7 +704,7 @@ class SQLiteDriver(SyncStorageMixin["sqlite3.Connection", "sqlite3.Row"]): ```python # ✅ DO: Use TypedParameter for type preservation -from sqlspec.core.parameters.types import TypedParameter +from sqlspec.core import TypedParameter class TypedParameter: __slots__ = ("name", "value", "type") @@ -850,11 +850,11 @@ def safe_operation(items: list[Any]) -> None: ```python # ✅ DO: Import from compiled modules -from sqlspec.core.result import SQLResult # Compiled module +from sqlspec.core import SQLResult # Compiled module # ❌ DON'T: Use circular imports or dynamic imports def get_result_class(): - from sqlspec.core.result import SQLResult # Late import + from sqlspec.core import SQLResult # Late import return SQLResult ``` diff --git a/docs/guides/quick-reference/quick-reference.md b/docs/guides/quick-reference/quick-reference.md index 8ba851c8d..7177e9906 100644 --- a/docs/guides/quick-reference/quick-reference.md +++ b/docs/guides/quick-reference/quick-reference.md @@ -31,8 +31,8 @@ orphan: true ```python from typing import Union, Optional -from sqlspec.core.filters import StatementFilter -from sqlspec.core.statement import SQL, Statement, StatementConfig +from sqlspec.core import StatementFilter +from sqlspec.core import SQL, Statement, StatementConfig from sqlspec.builder import QueryBuilder from sqlspec.typing import StatementParameters, ModelDTOT @@ -155,9 +155,9 @@ class SQLTransformContext: ```python from typing import Optional, Any from sqlspec.driver import SyncDriverAdapterBase -from sqlspec.core.parameters import ParameterStyle, ParameterStyleConfig -from sqlspec.core.statement import SQL, StatementConfig -from sqlspec.core.result import SQLResult +from sqlspec.core import ParameterStyle, ParameterStyleConfig +from sqlspec.core import SQL, StatementConfig +from sqlspec.core import SQLResult class MyDriver(SyncDriverAdapterBase): """Example driver implementation.""" @@ -412,7 +412,7 @@ from sqlspec.typing import ( Statement = Union[str, exp.Expression, SQL] # Filter types -from sqlspec.core.statement.filters import StatementFilter +from sqlspec.core import StatementFilter ``` ### StatementFilter Protocol @@ -434,7 +434,7 @@ class StatementFilter(ABC): ### Common Filters ```python -from sqlspec.core.statement.filters import ( +from sqlspec.core import ( LimitOffsetFilter, # .limit(10).offset(20) OrderByFilter, # .order_by("name", "created_at DESC") InCollectionFilter, # WHERE col IN (...) @@ -534,8 +534,8 @@ def _get_row_count(self, cursor: Any) -> int: **StatementConfig with ParameterStyleConfig:** ```python -from sqlspec.core.parameters import ParameterStyle, ParameterStyleConfig -from sqlspec.core.statement import StatementConfig +from sqlspec.core import ParameterStyle, ParameterStyleConfig +from sqlspec.core import StatementConfig # Create parameter configuration parameter_config = ParameterStyleConfig( @@ -569,8 +569,8 @@ statement_config = StatementConfig( ```python from sqlspec.driver import SyncDriverAdapterBase -from sqlspec.core.parameters import ParameterStyle, ParameterStyleConfig -from sqlspec.core.statement import StatementConfig +from sqlspec.core import ParameterStyle, ParameterStyleConfig +from sqlspec.core import StatementConfig class SqliteDriver(SyncDriverAdapterBase): """Reference implementation for SQLite.""" diff --git a/docs/reference/builder.rst b/docs/reference/builder.rst index e227cbc8a..32e5af1b2 100644 --- a/docs/reference/builder.rst +++ b/docs/reference/builder.rst @@ -521,7 +521,7 @@ The builder integrates with SQLSpec's filter system: .. code-block:: python - from sqlspec.core.filters import LimitOffsetFilter, SearchFilter, OrderByFilter + from sqlspec.core import LimitOffsetFilter, SearchFilter, OrderByFilter # Base query query = sql.select("*").from_("users") @@ -543,7 +543,7 @@ Convert builder to executable SQL: .. code-block:: python - from sqlspec.core.statement import SQL + from sqlspec.core import SQL # Build query query = sql.select("*").from_("users").limit(10) diff --git a/docs/reference/core.rst b/docs/reference/core.rst index 167d51fa4..452fcb9df 100644 --- a/docs/reference/core.rst +++ b/docs/reference/core.rst @@ -42,7 +42,7 @@ SQL Statement .. code-block:: python - from sqlspec.core.statement import SQL + from sqlspec.core import SQL # Simple SQL stmt = SQL("SELECT * FROM users") @@ -213,8 +213,8 @@ SQL Compilation .. code-block:: python - from sqlspec.core.statement import StatementConfig - from sqlspec.core.compiler import SQLProcessor + from sqlspec.core import StatementConfig + from sqlspec.core import SQLProcessor config = StatementConfig(dialect="postgres") processor = SQLProcessor(config) @@ -307,7 +307,7 @@ Built-in Filters .. code-block:: python - from sqlspec.core.filters import LimitOffsetFilter + from sqlspec.core import LimitOffsetFilter filter = LimitOffsetFilter(limit=10, offset=20) filtered_sql = filter.append_to_statement(base_sql) @@ -322,7 +322,7 @@ Built-in Filters .. code-block:: python - from sqlspec.core.filters import OrderByFilter + from sqlspec.core import OrderByFilter filter = OrderByFilter(field_name="created_at", sort_order="desc") filtered_sql = filter.append_to_statement(base_sql) @@ -337,7 +337,7 @@ Built-in Filters .. code-block:: python - from sqlspec.core.filters import SearchFilter + from sqlspec.core import SearchFilter filter = SearchFilter(field_name="name", value="John", operator="ILIKE") filtered_sql = filter.append_to_statement(base_sql) @@ -350,12 +350,12 @@ Filters can be composed and chained: .. code-block:: python - from sqlspec.core.filters import ( + from sqlspec.core import ( LimitOffsetFilter, OrderByFilter, SearchFilter ) - from sqlspec.core.statement import SQL + from sqlspec.core import SQL base_sql = SQL("SELECT * FROM users") @@ -393,9 +393,9 @@ Statement Analysis .. code-block:: python - from sqlspec.core.compiler import SQLCompiler + from sqlspec.core import SQLProcessor - compiler = SQLCompiler(dialect="postgres") + compiler = SQLProcessor(dialect="postgres") analysis = compiler.analyze(""" SELECT u.name, COUNT(o.id) as order_count @@ -421,10 +421,10 @@ Create custom filters for specific needs: .. code-block:: python - from sqlspec.core.filters import SQLFilter - from sqlspec.core.statement import SQL + from sqlspec.core import StatementFilter + from sqlspec.core import SQL - class TenantFilter(SQLFilter): + class TenantFilter(StatementFilter): def __init__(self, tenant_id: int): self.tenant_id = tenant_id diff --git a/docs/usage/configuration.rst b/docs/usage/configuration.rst index d06f8d398..5ede2c5d2 100644 --- a/docs/usage/configuration.rst +++ b/docs/usage/configuration.rst @@ -236,8 +236,8 @@ Basic Statement Config .. code-block:: python - from sqlspec.core.statement import StatementConfig - from sqlspec.core.parameters import ParameterStyle, ParameterStyleConfig + from sqlspec.core import StatementConfig + from sqlspec.core import ParameterStyle, ParameterStyleConfig statement_config = StatementConfig( dialect="postgres", # SQLGlot dialect @@ -260,7 +260,7 @@ Control how parameters are handled: .. code-block:: python - from sqlspec.core.parameters import ParameterStyle, ParameterStyleConfig + from sqlspec.core import ParameterStyle, ParameterStyleConfig param_config = ParameterStyleConfig( default_parameter_style=ParameterStyle.NUMERIC, # $1, $2, ... @@ -283,7 +283,7 @@ SQLSpec supports multiple parameter placeholder styles: .. code-block:: python - from sqlspec.core.parameters import ParameterStyle + from sqlspec.core import ParameterStyle # Question mark (SQLite, DuckDB) ParameterStyle.QMARK # WHERE id = ? @@ -326,7 +326,7 @@ Global Cache Configuration .. code-block:: python - from sqlspec.core.cache import CacheConfig, update_cache_config + from sqlspec.core import CacheConfig, update_cache_config cache_config = CacheConfig( enable_sql_cache=True, # Cache compiled SQL strings @@ -360,7 +360,7 @@ Monitor cache statistics: .. code-block:: python - from sqlspec.core.cache import get_cache_statistics, log_cache_stats + from sqlspec.core import get_cache_statistics, log_cache_stats # Get statistics stats = get_cache_statistics() @@ -375,7 +375,7 @@ Clear Cache .. code-block:: python - from sqlspec.core.cache import reset_cache_stats + from sqlspec.core import reset_cache_stats # Clear all caches and reset statistics reset_cache_stats() diff --git a/docs/usage/data_flow.rst b/docs/usage/data_flow.rst index d5e80aec9..5f2d220e9 100644 --- a/docs/usage/data_flow.rst +++ b/docs/usage/data_flow.rst @@ -62,7 +62,7 @@ The execution flow begins when you create a SQL object. SQLSpec accepts multiple .. code-block:: python - from sqlspec.core.statement import SQL + from sqlspec.core import SQL # Raw SQL string with positional parameters sql = SQL("SELECT * FROM users WHERE id = ?", 1) @@ -332,8 +332,8 @@ Configuration-Driven Processing .. code-block:: python - from sqlspec.core.statement import StatementConfig - from sqlspec.core.parameters import ParameterStyle, ParameterStyleConfig + from sqlspec.core import StatementConfig + from sqlspec.core import ParameterStyle, ParameterStyleConfig config = StatementConfig( dialect="postgres", diff --git a/sqlspec/adapters/adbc/config.py b/sqlspec/adapters/adbc/config.py index d019ee3a9..aa533bc1a 100644 --- a/sqlspec/adapters/adbc/config.py +++ b/sqlspec/adapters/adbc/config.py @@ -10,7 +10,7 @@ from sqlspec.adapters.adbc._types import AdbcConnection from sqlspec.adapters.adbc.driver import AdbcCursor, AdbcDriver, get_adbc_statement_config from sqlspec.config import ADKConfig, FastAPIConfig, FlaskConfig, LitestarConfig, NoPoolSyncConfig, StarletteConfig -from sqlspec.core.statement import StatementConfig +from sqlspec.core import StatementConfig from sqlspec.exceptions import ImproperConfigurationError from sqlspec.utils.module_loader import import_string diff --git a/sqlspec/adapters/adbc/driver.py b/sqlspec/adapters/adbc/driver.py index 7e9b8ba44..8cfa54b5d 100644 --- a/sqlspec/adapters/adbc/driver.py +++ b/sqlspec/adapters/adbc/driver.py @@ -11,17 +11,18 @@ from sqlspec.adapters.adbc.data_dictionary import AdbcDataDictionary from sqlspec.adapters.adbc.type_converter import ADBCTypeConverter -from sqlspec.core.cache import get_cache_config -from sqlspec.core.parameters import ( +from sqlspec.core import ( + SQL, DriverParameterProfile, ParameterStyle, + StatementConfig, build_null_pruning_transform, build_statement_config_from_profile, + create_arrow_result, + get_cache_config, get_driver_profile, register_driver_profile, ) -from sqlspec.core.result import create_arrow_result -from sqlspec.core.statement import SQL, StatementConfig from sqlspec.driver import SyncDriverAdapterBase from sqlspec.exceptions import ( CheckViolationError, diff --git a/sqlspec/adapters/adbc/type_converter.py b/sqlspec/adapters/adbc/type_converter.py index 54d8105a2..06ac27176 100644 --- a/sqlspec/adapters/adbc/type_converter.py +++ b/sqlspec/adapters/adbc/type_converter.py @@ -8,7 +8,7 @@ from functools import lru_cache from typing import Any, Final -from sqlspec.core.type_conversion import BaseTypeConverter +from sqlspec.core import BaseTypeConverter from sqlspec.utils.serializers import to_json ADBC_SPECIAL_CHARS: Final[frozenset[str]] = frozenset({"{", "[", "-", ":", "T", "."}) diff --git a/sqlspec/adapters/aiosqlite/config.py b/sqlspec/adapters/aiosqlite/config.py index 7ecb1fbe8..240e07032 100644 --- a/sqlspec/adapters/aiosqlite/config.py +++ b/sqlspec/adapters/aiosqlite/config.py @@ -20,7 +20,7 @@ if TYPE_CHECKING: from collections.abc import AsyncGenerator, Callable - from sqlspec.core.statement import StatementConfig + from sqlspec.core import StatementConfig __all__ = ("AiosqliteConfig", "AiosqliteConnectionParams", "AiosqliteDriverFeatures", "AiosqlitePoolParams") diff --git a/sqlspec/adapters/aiosqlite/driver.py b/sqlspec/adapters/aiosqlite/driver.py index 8fcbc1146..24338367c 100644 --- a/sqlspec/adapters/aiosqlite/driver.py +++ b/sqlspec/adapters/aiosqlite/driver.py @@ -8,11 +8,11 @@ import aiosqlite -from sqlspec.core.cache import get_cache_config -from sqlspec.core.parameters import ( +from sqlspec.core import ( DriverParameterProfile, ParameterStyle, build_statement_config_from_profile, + get_cache_config, register_driver_profile, ) from sqlspec.driver import AsyncDriverAdapterBase @@ -35,8 +35,7 @@ from contextlib import AbstractAsyncContextManager from sqlspec.adapters.aiosqlite._types import AiosqliteConnection - from sqlspec.core.result import SQLResult - from sqlspec.core.statement import SQL, StatementConfig + from sqlspec.core import SQL, SQLResult, StatementConfig from sqlspec.driver import ExecutionResult from sqlspec.driver._async import AsyncDataDictionaryBase diff --git a/sqlspec/adapters/asyncmy/config.py b/sqlspec/adapters/asyncmy/config.py index 4e9ca109f..2735e18a3 100644 --- a/sqlspec/adapters/asyncmy/config.py +++ b/sqlspec/adapters/asyncmy/config.py @@ -26,7 +26,7 @@ from asyncmy.cursors import Cursor, DictCursor # pyright: ignore from asyncmy.pool import Pool # pyright: ignore - from sqlspec.core.statement import StatementConfig + from sqlspec.core import StatementConfig __all__ = ("AsyncmyConfig", "AsyncmyConnectionParams", "AsyncmyDriverFeatures", "AsyncmyPoolParams") diff --git a/sqlspec/adapters/asyncmy/driver.py b/sqlspec/adapters/asyncmy/driver.py index d06260a57..d2794617c 100644 --- a/sqlspec/adapters/asyncmy/driver.py +++ b/sqlspec/adapters/asyncmy/driver.py @@ -11,11 +11,11 @@ from asyncmy.constants import FIELD_TYPE as ASYNC_MY_FIELD_TYPE # pyright: ignore from asyncmy.cursors import Cursor, DictCursor # pyright: ignore -from sqlspec.core.cache import get_cache_config -from sqlspec.core.parameters import ( +from sqlspec.core import ( DriverParameterProfile, ParameterStyle, build_statement_config_from_profile, + get_cache_config, register_driver_profile, ) from sqlspec.driver import AsyncDriverAdapterBase @@ -38,8 +38,7 @@ from contextlib import AbstractAsyncContextManager from sqlspec.adapters.asyncmy._types import AsyncmyConnection - from sqlspec.core.result import SQLResult - from sqlspec.core.statement import SQL, StatementConfig + from sqlspec.core import SQL, SQLResult, StatementConfig from sqlspec.driver import ExecutionResult from sqlspec.driver._async import AsyncDataDictionaryBase __all__ = ( diff --git a/sqlspec/adapters/asyncpg/config.py b/sqlspec/adapters/asyncpg/config.py index 5aad19e4f..5ec0f9384 100644 --- a/sqlspec/adapters/asyncpg/config.py +++ b/sqlspec/adapters/asyncpg/config.py @@ -26,7 +26,7 @@ from asyncio.events import AbstractEventLoop from collections.abc import AsyncGenerator, Awaitable - from sqlspec.core.statement import StatementConfig + from sqlspec.core import StatementConfig __all__ = ("AsyncpgConfig", "AsyncpgConnectionConfig", "AsyncpgDriverFeatures", "AsyncpgPoolConfig") diff --git a/sqlspec/adapters/asyncpg/driver.py b/sqlspec/adapters/asyncpg/driver.py index 897068142..3c36c8743 100644 --- a/sqlspec/adapters/asyncpg/driver.py +++ b/sqlspec/adapters/asyncpg/driver.py @@ -11,6 +11,8 @@ ParameterStyle, build_statement_config_from_profile, get_cache_config, + is_copy_from_operation, + is_copy_operation, register_driver_profile, ) from sqlspec.driver import AsyncDriverAdapterBase @@ -216,7 +218,7 @@ async def _try_special_handling(self, cursor: "AsyncpgConnection", statement: "S Returns: SQLResult if special operation was handled, None for standard execution """ - if statement.operation_type == "COPY": + if is_copy_operation(statement.operation_type): await self._handle_copy_operation(cursor, statement) return self.build_statement_result(statement, self.create_execution_result(cursor)) @@ -234,10 +236,10 @@ async def _handle_copy_operation(self, cursor: "AsyncpgConnection", statement: " metadata: dict[str, Any] = getattr(statement, "metadata", {}) sql_text = statement.sql - + sql_upper = sql_text.upper() copy_data = metadata.get("postgres_copy_data") - if copy_data: + if copy_data and is_copy_from_operation(statement.operation_type) and "FROM STDIN" in sql_upper: if isinstance(copy_data, dict): data_str = ( str(next(iter(copy_data.values()))) @@ -249,15 +251,13 @@ async def _handle_copy_operation(self, cursor: "AsyncpgConnection", statement: " else: data_str = str(copy_data) - if "FROM STDIN" in sql_text.upper(): - from io import BytesIO + from io import BytesIO - data_io = BytesIO(data_str.encode("utf-8")) - await cursor.copy_from_query(sql_text, output=data_io) - else: - await cursor.execute(sql_text) - else: - await cursor.execute(sql_text) + data_io = BytesIO(data_str.encode("utf-8")) + await cursor.copy_from_query(sql_text, output=data_io) + return + + await cursor.execute(sql_text) async def _execute_script(self, cursor: "AsyncpgConnection", statement: "SQL") -> "ExecutionResult": """Execute SQL script with statement splitting and parameter handling. diff --git a/sqlspec/adapters/bigquery/config.py b/sqlspec/adapters/bigquery/config.py index 965bb886e..ce2e9ed07 100644 --- a/sqlspec/adapters/bigquery/config.py +++ b/sqlspec/adapters/bigquery/config.py @@ -21,7 +21,7 @@ from google.api_core.client_options import ClientOptions from google.auth.credentials import Credentials - from sqlspec.core.statement import StatementConfig + from sqlspec.core import StatementConfig logger = logging.getLogger(__name__) diff --git a/sqlspec/adapters/bigquery/driver.py b/sqlspec/adapters/bigquery/driver.py index 483a90c4a..5910c2759 100644 --- a/sqlspec/adapters/bigquery/driver.py +++ b/sqlspec/adapters/bigquery/driver.py @@ -16,11 +16,14 @@ from sqlspec.adapters.bigquery._types import BigQueryConnection from sqlspec.adapters.bigquery.type_converter import BigQueryTypeConverter -from sqlspec.core import ParameterStyle, StatementConfig, create_arrow_result, get_cache_config -from sqlspec.core.parameters import ( +from sqlspec.core import ( DriverParameterProfile, + ParameterStyle, + StatementConfig, build_literal_inlining_transform, build_statement_config_from_profile, + create_arrow_result, + get_cache_config, register_driver_profile, ) from sqlspec.driver import ExecutionResult, SyncDriverAdapterBase diff --git a/sqlspec/adapters/bigquery/type_converter.py b/sqlspec/adapters/bigquery/type_converter.py index e2690c996..200bd8bc1 100644 --- a/sqlspec/adapters/bigquery/type_converter.py +++ b/sqlspec/adapters/bigquery/type_converter.py @@ -8,7 +8,7 @@ from typing import Any, Final from uuid import UUID -from sqlspec.core.type_conversion import BaseTypeConverter, convert_uuid +from sqlspec.core import BaseTypeConverter, convert_uuid try: from google.cloud.bigquery import ScalarQueryParameter diff --git a/sqlspec/adapters/duckdb/config.py b/sqlspec/adapters/duckdb/config.py index 600a844f4..3767a3f28 100644 --- a/sqlspec/adapters/duckdb/config.py +++ b/sqlspec/adapters/duckdb/config.py @@ -15,7 +15,7 @@ if TYPE_CHECKING: from collections.abc import Callable, Generator - from sqlspec.core.statement import StatementConfig + from sqlspec.core import StatementConfig __all__ = ( "DuckDBConfig", diff --git a/sqlspec/adapters/duckdb/driver.py b/sqlspec/adapters/duckdb/driver.py index ab03cb882..39b467f69 100644 --- a/sqlspec/adapters/duckdb/driver.py +++ b/sqlspec/adapters/duckdb/driver.py @@ -9,8 +9,15 @@ from sqlspec.adapters.duckdb.data_dictionary import DuckDBSyncDataDictionary from sqlspec.adapters.duckdb.type_converter import DuckDBTypeConverter -from sqlspec.core import SQL, ParameterStyle, StatementConfig, get_cache_config -from sqlspec.core.parameters import DriverParameterProfile, build_statement_config_from_profile, register_driver_profile +from sqlspec.core import ( + SQL, + DriverParameterProfile, + ParameterStyle, + StatementConfig, + build_statement_config_from_profile, + get_cache_config, + register_driver_profile, +) from sqlspec.driver import SyncDriverAdapterBase from sqlspec.exceptions import ( CheckViolationError, @@ -434,7 +441,7 @@ def select_to_arrow( import pyarrow as pa - from sqlspec.core.result import create_arrow_result + from sqlspec.core import create_arrow_result # Prepare statement config = statement_config or self.statement_config diff --git a/sqlspec/adapters/duckdb/type_converter.py b/sqlspec/adapters/duckdb/type_converter.py index 2ab776bfb..eac73d94d 100644 --- a/sqlspec/adapters/duckdb/type_converter.py +++ b/sqlspec/adapters/duckdb/type_converter.py @@ -9,7 +9,7 @@ from typing import Any, Final from uuid import UUID -from sqlspec.core.type_conversion import BaseTypeConverter, convert_uuid, format_datetime_rfc3339 +from sqlspec.core import BaseTypeConverter, convert_uuid, format_datetime_rfc3339 DUCKDB_SPECIAL_CHARS: Final[frozenset[str]] = frozenset({"-", ":", "T", ".", "[", "{"}) diff --git a/sqlspec/adapters/oracledb/config.py b/sqlspec/adapters/oracledb/config.py index 86e438723..95f75cbea 100644 --- a/sqlspec/adapters/oracledb/config.py +++ b/sqlspec/adapters/oracledb/config.py @@ -39,7 +39,7 @@ from oracledb import AuthMode - from sqlspec.core.statement import StatementConfig + from sqlspec.core import StatementConfig __all__ = ( diff --git a/sqlspec/adapters/oracledb/driver.py b/sqlspec/adapters/oracledb/driver.py index 6e7c2010c..031f822df 100644 --- a/sqlspec/adapters/oracledb/driver.py +++ b/sqlspec/adapters/oracledb/driver.py @@ -11,8 +11,16 @@ from sqlspec.adapters.oracledb._types import OracleAsyncConnection, OracleSyncConnection from sqlspec.adapters.oracledb.data_dictionary import OracleAsyncDataDictionary, OracleSyncDataDictionary from sqlspec.adapters.oracledb.type_converter import OracleTypeConverter -from sqlspec.core import SQL, ParameterStyle, StatementConfig, create_arrow_result, get_cache_config -from sqlspec.core.parameters import DriverParameterProfile, build_statement_config_from_profile, register_driver_profile +from sqlspec.core import ( + SQL, + DriverParameterProfile, + ParameterStyle, + StatementConfig, + build_statement_config_from_profile, + create_arrow_result, + get_cache_config, + register_driver_profile, +) from sqlspec.driver import ( AsyncDataDictionaryBase, AsyncDriverAdapterBase, diff --git a/sqlspec/adapters/oracledb/type_converter.py b/sqlspec/adapters/oracledb/type_converter.py index 489077fe1..dc05c511d 100644 --- a/sqlspec/adapters/oracledb/type_converter.py +++ b/sqlspec/adapters/oracledb/type_converter.py @@ -10,7 +10,7 @@ from functools import lru_cache from typing import Any, Final -from sqlspec.core.type_conversion import BaseTypeConverter +from sqlspec.core import BaseTypeConverter from sqlspec.typing import NUMPY_INSTALLED from sqlspec.utils.sync_tools import ensure_async_ diff --git a/sqlspec/adapters/psqlpy/config.py b/sqlspec/adapters/psqlpy/config.py index e4858a280..2e6929711 100644 --- a/sqlspec/adapters/psqlpy/config.py +++ b/sqlspec/adapters/psqlpy/config.py @@ -11,7 +11,7 @@ from sqlspec.adapters.psqlpy._types import PsqlpyConnection from sqlspec.adapters.psqlpy.driver import PsqlpyCursor, PsqlpyDriver, build_psqlpy_statement_config from sqlspec.config import ADKConfig, AsyncDatabaseConfig, FastAPIConfig, FlaskConfig, LitestarConfig, StarletteConfig -from sqlspec.core.statement import StatementConfig +from sqlspec.core import StatementConfig from sqlspec.typing import PGVECTOR_INSTALLED from sqlspec.utils.serializers import to_json diff --git a/sqlspec/adapters/psqlpy/driver.py b/sqlspec/adapters/psqlpy/driver.py index 981ee19db..553915c6b 100644 --- a/sqlspec/adapters/psqlpy/driver.py +++ b/sqlspec/adapters/psqlpy/driver.py @@ -15,15 +15,16 @@ from sqlspec.adapters.psqlpy.data_dictionary import PsqlpyAsyncDataDictionary from sqlspec.adapters.psqlpy.type_converter import PostgreSQLTypeConverter -from sqlspec.core.cache import get_cache_config -from sqlspec.core.parameters import ( +from sqlspec.core import ( + SQL, DriverParameterProfile, ParameterStyle, ParameterStyleConfig, + StatementConfig, build_statement_config_from_profile, + get_cache_config, register_driver_profile, ) -from sqlspec.core.statement import SQL, StatementConfig from sqlspec.driver import AsyncDriverAdapterBase from sqlspec.exceptions import ( CheckViolationError, @@ -48,7 +49,7 @@ from contextlib import AbstractAsyncContextManager from sqlspec.adapters.psqlpy._types import PsqlpyConnection - from sqlspec.core.result import SQLResult + from sqlspec.core import SQLResult from sqlspec.driver import ExecutionResult from sqlspec.driver._async import AsyncDataDictionaryBase diff --git a/sqlspec/adapters/psqlpy/type_converter.py b/sqlspec/adapters/psqlpy/type_converter.py index 5418e9824..587a06139 100644 --- a/sqlspec/adapters/psqlpy/type_converter.py +++ b/sqlspec/adapters/psqlpy/type_converter.py @@ -9,7 +9,7 @@ from functools import lru_cache from typing import Any, Final -from sqlspec.core.type_conversion import BaseTypeConverter +from sqlspec.core import BaseTypeConverter PG_SPECIFIC_REGEX: Final[re.Pattern[str]] = re.compile( r"^(?:" diff --git a/sqlspec/adapters/psycopg/config.py b/sqlspec/adapters/psycopg/config.py index 69f6b68e2..01cfb1843 100644 --- a/sqlspec/adapters/psycopg/config.py +++ b/sqlspec/adapters/psycopg/config.py @@ -33,7 +33,7 @@ if TYPE_CHECKING: from collections.abc import AsyncGenerator, Callable, Generator - from sqlspec.core.statement import StatementConfig + from sqlspec.core import StatementConfig logger = logging.getLogger("sqlspec.adapters.psycopg") diff --git a/sqlspec/adapters/psycopg/driver.py b/sqlspec/adapters/psycopg/driver.py index ae1b2ba91..434c11ef6 100644 --- a/sqlspec/adapters/psycopg/driver.py +++ b/sqlspec/adapters/psycopg/driver.py @@ -21,16 +21,20 @@ import psycopg from sqlspec.adapters.psycopg._types import PsycopgAsyncConnection, PsycopgSyncConnection -from sqlspec.core.cache import get_cache_config -from sqlspec.core.parameters import ( +from sqlspec.core import ( + SQL, DriverParameterProfile, ParameterStyle, ParameterStyleConfig, + SQLResult, + StatementConfig, build_statement_config_from_profile, + get_cache_config, + is_copy_from_operation, + is_copy_operation, + is_copy_to_operation, register_driver_profile, ) -from sqlspec.core.result import SQLResult -from sqlspec.core.statement import SQL, StatementConfig from sqlspec.driver import AsyncDriverAdapterBase, SyncDriverAdapterBase from sqlspec.exceptions import ( CheckViolationError, @@ -289,7 +293,7 @@ def _try_special_handling(self, cursor: Any, statement: "SQL") -> "SQLResult | N statement.compile() - if statement.operation_type in {"COPY_FROM", "COPY_TO"}: + if is_copy_operation(statement.operation_type): return self._handle_copy_operation(cursor, statement) return None @@ -306,12 +310,12 @@ def _handle_copy_operation(self, cursor: Any, statement: "SQL") -> "SQLResult": """ sql = statement.sql - + operation_type = statement.operation_type copy_data = statement.parameters if isinstance(copy_data, list) and len(copy_data) == 1: copy_data = copy_data[0] - if statement.operation_type == "COPY_FROM": + if is_copy_from_operation(operation_type): if isinstance(copy_data, (str, bytes)): data_file = io.StringIO(copy_data) if isinstance(copy_data, str) else io.BytesIO(copy_data) elif hasattr(copy_data, "read"): @@ -331,7 +335,7 @@ def _handle_copy_operation(self, cursor: Any, statement: "SQL") -> "SQLResult": data=None, rows_affected=rows_affected, statement=statement, metadata={"copy_operation": "FROM_STDIN"} ) - if statement.operation_type == "COPY_TO": + if is_copy_to_operation(operation_type): output_data: list[str] = [] with cursor.copy(sql) as copy_ctx: output_data.extend(row.decode() if isinstance(row, bytes) else str(row) for row in copy_ctx) @@ -657,8 +661,9 @@ async def _try_special_handling(self, cursor: Any, statement: "SQL") -> "SQLResu SQLResult if special handling was applied, None otherwise """ - sql_upper = statement.sql.strip().upper() - if sql_upper.startswith("COPY ") and ("FROM STDIN" in sql_upper or "TO STDOUT" in sql_upper): + statement.compile() + + if is_copy_operation(statement.operation_type): return await self._handle_copy_operation_async(cursor, statement) return None @@ -675,16 +680,13 @@ async def _handle_copy_operation_async(self, cursor: Any, statement: "SQL") -> " """ sql = statement.sql - + sql_upper = sql.upper() + operation_type = statement.operation_type copy_data = statement.parameters if isinstance(copy_data, list) and len(copy_data) == 1: copy_data = copy_data[0] - sql_upper = sql.upper() - is_stdin = "FROM STDIN" in sql_upper - is_stdout = "TO STDOUT" in sql_upper - - if is_stdin: + if is_copy_from_operation(operation_type) and "FROM STDIN" in sql_upper: if isinstance(copy_data, (str, bytes)): data_file = io.StringIO(copy_data) if isinstance(copy_data, str) else io.BytesIO(copy_data) elif hasattr(copy_data, "read"): @@ -704,7 +706,7 @@ async def _handle_copy_operation_async(self, cursor: Any, statement: "SQL") -> " data=None, rows_affected=rows_affected, statement=statement, metadata={"copy_operation": "FROM_STDIN"} ) - if is_stdout: + if is_copy_to_operation(operation_type) and "TO STDOUT" in sql_upper: output_data: list[str] = [] async with cursor.copy(sql) as copy_ctx: output_data.extend([row.decode() if isinstance(row, bytes) else str(row) async for row in copy_ctx]) diff --git a/sqlspec/adapters/sqlite/config.py b/sqlspec/adapters/sqlite/config.py index b2b3f389d..177ac529d 100644 --- a/sqlspec/adapters/sqlite/config.py +++ b/sqlspec/adapters/sqlite/config.py @@ -19,7 +19,7 @@ if TYPE_CHECKING: from collections.abc import Callable, Generator - from sqlspec.core.statement import StatementConfig + from sqlspec.core import StatementConfig class SqliteConnectionParams(TypedDict): diff --git a/sqlspec/adapters/sqlite/driver.py b/sqlspec/adapters/sqlite/driver.py index 4ba3d25b0..28481b54d 100644 --- a/sqlspec/adapters/sqlite/driver.py +++ b/sqlspec/adapters/sqlite/driver.py @@ -6,11 +6,11 @@ from decimal import Decimal from typing import TYPE_CHECKING, Any -from sqlspec.core.cache import get_cache_config -from sqlspec.core.parameters import ( +from sqlspec.core import ( DriverParameterProfile, ParameterStyle, build_statement_config_from_profile, + get_cache_config, register_driver_profile, ) from sqlspec.driver import SyncDriverAdapterBase @@ -33,8 +33,7 @@ from contextlib import AbstractContextManager from sqlspec.adapters.sqlite._types import SqliteConnection - from sqlspec.core.result import SQLResult - from sqlspec.core.statement import SQL, StatementConfig + from sqlspec.core import SQL, SQLResult, StatementConfig from sqlspec.driver import ExecutionResult from sqlspec.driver._sync import SyncDataDictionaryBase diff --git a/sqlspec/base.py b/sqlspec/base.py index c992a72d3..8b726b9ce 100644 --- a/sqlspec/base.py +++ b/sqlspec/base.py @@ -13,7 +13,7 @@ SyncConfigT, SyncDatabaseConfig, ) -from sqlspec.core.cache import ( +from sqlspec.core import ( CacheConfig, get_cache_config, get_cache_statistics, @@ -27,7 +27,7 @@ from contextlib import AbstractAsyncContextManager, AbstractContextManager from pathlib import Path - from sqlspec.core.statement import SQL + from sqlspec.core import SQL from sqlspec.loader import SQLFileLoader from sqlspec.typing import ConnectionT, PoolT diff --git a/sqlspec/builder/_base.py b/sqlspec/builder/_base.py index f90d3b30f..4d2440514 100644 --- a/sqlspec/builder/_base.py +++ b/sqlspec/builder/_base.py @@ -15,16 +15,21 @@ from sqlglot.optimizer import optimize from typing_extensions import Self -from sqlspec.core.cache import get_cache, get_cache_config -from sqlspec.core.hashing import hash_optimized_expression -from sqlspec.core.parameters import ParameterStyle, ParameterStyleConfig -from sqlspec.core.statement import SQL, StatementConfig +from sqlspec.core import ( + SQL, + ParameterStyle, + ParameterStyleConfig, + StatementConfig, + get_cache, + get_cache_config, + hash_optimized_expression, +) from sqlspec.exceptions import SQLBuilderError from sqlspec.utils.logging import get_logger from sqlspec.utils.type_guards import has_expression_and_parameters, has_with_method, is_expression if TYPE_CHECKING: - from sqlspec.core.result import SQLResult + from sqlspec.core import SQLResult __all__ = ("QueryBuilder", "SafeQuery") diff --git a/sqlspec/builder/_ddl.py b/sqlspec/builder/_ddl.py index 96e7ab0f1..109f02b6b 100644 --- a/sqlspec/builder/_ddl.py +++ b/sqlspec/builder/_ddl.py @@ -11,15 +11,14 @@ from sqlspec.builder._base import QueryBuilder, SafeQuery from sqlspec.builder._select import Select -from sqlspec.core.result import SQLResult -from sqlspec.core.statement import SQL +from sqlspec.core import SQL, SQLResult from sqlspec.utils.type_guards import has_sqlglot_expression, has_with_method if TYPE_CHECKING: from sqlglot.dialects.dialect import DialectType from sqlspec.builder._column import ColumnExpression - from sqlspec.core.statement import StatementConfig + from sqlspec.core import StatementConfig __all__ = ( "AlterOperation", diff --git a/sqlspec/builder/_delete.py b/sqlspec/builder/_delete.py index b0a77d4e5..632995b24 100644 --- a/sqlspec/builder/_delete.py +++ b/sqlspec/builder/_delete.py @@ -14,7 +14,7 @@ from sqlspec.builder._base import QueryBuilder, SafeQuery from sqlspec.builder._dml import DeleteFromClauseMixin from sqlspec.builder._select import ReturningClauseMixin, WhereClauseMixin -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult from sqlspec.exceptions import SQLBuilderError __all__ = ("Delete",) diff --git a/sqlspec/builder/_factory.py b/sqlspec/builder/_factory.py index d8203ebc8..d33b47481 100644 --- a/sqlspec/builder/_factory.py +++ b/sqlspec/builder/_factory.py @@ -42,7 +42,7 @@ from sqlspec.builder._parsing_utils import extract_expression, to_expression from sqlspec.builder._select import Case, Select, SubqueryBuilder, WindowFunctionBuilder from sqlspec.builder._update import Update -from sqlspec.core.statement import SQL +from sqlspec.core import SQL from sqlspec.exceptions import SQLBuilderError if TYPE_CHECKING: diff --git a/sqlspec/builder/_insert.py b/sqlspec/builder/_insert.py index 802dfae3b..fa6153947 100644 --- a/sqlspec/builder/_insert.py +++ b/sqlspec/builder/_insert.py @@ -13,7 +13,7 @@ from sqlspec.builder._dml import InsertFromSelectMixin, InsertIntoClauseMixin, InsertValuesMixin from sqlspec.builder._parsing_utils import extract_sql_object_expression from sqlspec.builder._select import ReturningClauseMixin -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult from sqlspec.exceptions import SQLBuilderError from sqlspec.utils.type_guards import has_expression_and_sql diff --git a/sqlspec/builder/_join.py b/sqlspec/builder/_join.py index bac9ef5dd..c67c79663 100644 --- a/sqlspec/builder/_join.py +++ b/sqlspec/builder/_join.py @@ -15,7 +15,7 @@ from sqlspec.utils.type_guards import has_query_builder_parameters if TYPE_CHECKING: - from sqlspec.core.statement import SQL + from sqlspec.core import SQL from sqlspec.protocols import SQLBuilderProtocol __all__ = ("JoinBuilder", "JoinClauseMixin") diff --git a/sqlspec/builder/_parsing_utils.py b/sqlspec/builder/_parsing_utils.py index 68a906059..16004cf4e 100644 --- a/sqlspec/builder/_parsing_utils.py +++ b/sqlspec/builder/_parsing_utils.py @@ -9,7 +9,7 @@ from sqlglot import exp, maybe_parse -from sqlspec.core.parameters import ParameterStyle, ParameterValidator +from sqlspec.core import ParameterStyle, ParameterValidator from sqlspec.utils.type_guards import ( has_expression_and_parameters, has_expression_and_sql, diff --git a/sqlspec/builder/_select.py b/sqlspec/builder/_select.py index bda55a004..a3bbcd63c 100644 --- a/sqlspec/builder/_select.py +++ b/sqlspec/builder/_select.py @@ -24,9 +24,7 @@ parse_table_expression, to_expression, ) -from sqlspec.core.parameters import ParameterStyle, ParameterValidator -from sqlspec.core.result import SQLResult -from sqlspec.core.statement import SQL +from sqlspec.core import SQL, ParameterStyle, ParameterValidator, SQLResult from sqlspec.exceptions import SQLBuilderError from sqlspec.utils.type_guards import ( has_expression_and_parameters, diff --git a/sqlspec/builder/_update.py b/sqlspec/builder/_update.py index ac42864d0..7800a3173 100644 --- a/sqlspec/builder/_update.py +++ b/sqlspec/builder/_update.py @@ -13,7 +13,7 @@ from sqlspec.builder._dml import UpdateFromClauseMixin, UpdateSetClauseMixin, UpdateTableClauseMixin from sqlspec.builder._join import build_join_clause from sqlspec.builder._select import ReturningClauseMixin, WhereClauseMixin -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult from sqlspec.exceptions import SQLBuilderError if TYPE_CHECKING: diff --git a/sqlspec/config.py b/sqlspec/config.py index 8039f3000..7a3f9ecd0 100644 --- a/sqlspec/config.py +++ b/sqlspec/config.py @@ -5,8 +5,7 @@ from typing_extensions import NotRequired, TypedDict -from sqlspec.core.parameters import ParameterStyle, ParameterStyleConfig -from sqlspec.core.statement import StatementConfig +from sqlspec.core import ParameterStyle, ParameterStyleConfig, StatementConfig from sqlspec.migrations.tracker import AsyncMigrationTracker, SyncMigrationTracker from sqlspec.utils.logging import get_logger diff --git a/sqlspec/core/__init__.py b/sqlspec/core/__init__.py index e0d0b32c7..1921db7a1 100644 --- a/sqlspec/core/__init__.py +++ b/sqlspec/core/__init__.py @@ -90,59 +90,201 @@ """ from sqlspec.core import filters -from sqlspec.core.cache import CacheConfig, CacheStats, MultiLevelCache, UnifiedCache, get_cache, get_cache_config -from sqlspec.core.compiler import OperationType, SQLProcessor -from sqlspec.core.filters import StatementFilter +from sqlspec.core.cache import ( + CacheConfig, + CachedStatement, + CacheKey, + CacheStats, + FiltersView, + MultiLevelCache, + ParametersView, + UnifiedCache, + canonicalize_filters, + clear_all_caches, + create_cache_key, + get_cache, + get_cache_config, + get_cache_statistics, + get_cache_stats, + get_default_cache, + get_pipeline_metrics, + log_cache_stats, + reset_cache_stats, + reset_pipeline_registry, + update_cache_config, +) +from sqlspec.core.compiler import ( + CompiledSQL, + OperationProfile, + OperationType, + SQLProcessor, + is_copy_from_operation, + is_copy_operation, + is_copy_to_operation, +) +from sqlspec.core.filters import ( + AnyCollectionFilter, + BeforeAfterFilter, + FilterTypes, + FilterTypeT, + InCollectionFilter, + LimitOffsetFilter, + NotInCollectionFilter, + OrderByFilter, + SearchFilter, + StatementFilter, + apply_filter, +) from sqlspec.core.hashing import ( hash_expression, hash_expression_node, + hash_filters, hash_optimized_expression, hash_parameters, hash_sql_statement, ) from sqlspec.core.parameters import ( + DRIVER_PARAMETER_PROFILES, + EXECUTE_MANY_MIN_ROWS, + PARAMETER_REGEX, DriverParameterProfile, ParameterConverter, + ParameterInfo, + ParameterProcessingResult, ParameterProcessor, + ParameterProfile, ParameterStyle, ParameterStyleConfig, + ParameterValidator, TypedParameter, + build_literal_inlining_transform, + build_null_pruning_transform, build_statement_config_from_profile, + collect_null_parameter_ordinals, + get_driver_profile, + is_iterable_parameters, + looks_like_execute_many, + normalize_parameter_key, register_driver_profile, + replace_null_parameters_with_literals, + replace_placeholders_with_literals, + validate_parameter_alignment, + wrap_with_type, ) from sqlspec.core.result import ArrowResult, SQLResult, StatementResult, create_arrow_result, create_sql_result -from sqlspec.core.statement import SQL, Statement, StatementConfig +from sqlspec.core.splitter import split_sql_script +from sqlspec.core.statement import ( + SQL, + ProcessedState, + Statement, + StatementConfig, + get_default_config, + get_default_parameter_config, +) +from sqlspec.core.type_conversion import ( + BaseTypeConverter, + convert_decimal, + convert_iso_date, + convert_iso_datetime, + convert_iso_time, + convert_json, + convert_uuid, + format_datetime_rfc3339, + parse_datetime_rfc3339, +) __all__ = ( + "DRIVER_PARAMETER_PROFILES", + "EXECUTE_MANY_MIN_ROWS", + "PARAMETER_REGEX", "SQL", + "AnyCollectionFilter", "ArrowResult", + "BaseTypeConverter", + "BeforeAfterFilter", "CacheConfig", + "CacheKey", "CacheStats", + "CachedStatement", + "CompiledSQL", "DriverParameterProfile", + "FilterTypeT", + "FilterTypes", + "FiltersView", + "InCollectionFilter", + "LimitOffsetFilter", "MultiLevelCache", + "NotInCollectionFilter", + "OperationProfile", "OperationType", + "OrderByFilter", "ParameterConverter", + "ParameterInfo", + "ParameterProcessingResult", "ParameterProcessor", + "ParameterProfile", "ParameterStyle", "ParameterStyleConfig", + "ParameterValidator", + "ParametersView", + "ProcessedState", "SQLProcessor", "SQLResult", + "SearchFilter", "Statement", "StatementConfig", "StatementFilter", "StatementResult", "TypedParameter", "UnifiedCache", + "apply_filter", + "build_literal_inlining_transform", + "build_null_pruning_transform", "build_statement_config_from_profile", + "canonicalize_filters", + "clear_all_caches", + "collect_null_parameter_ordinals", + "convert_decimal", + "convert_iso_date", + "convert_iso_datetime", + "convert_iso_time", + "convert_json", + "convert_uuid", "create_arrow_result", + "create_cache_key", "create_sql_result", "filters", + "format_datetime_rfc3339", "get_cache", "get_cache_config", + "get_cache_statistics", + "get_cache_stats", + "get_default_cache", + "get_default_config", + "get_default_parameter_config", + "get_driver_profile", + "get_pipeline_metrics", "hash_expression", "hash_expression_node", + "hash_filters", "hash_optimized_expression", "hash_parameters", "hash_sql_statement", + "is_copy_from_operation", + "is_copy_operation", + "is_copy_to_operation", + "is_iterable_parameters", + "log_cache_stats", + "looks_like_execute_many", + "normalize_parameter_key", + "parse_datetime_rfc3339", "register_driver_profile", + "replace_null_parameters_with_literals", + "replace_placeholders_with_literals", + "reset_cache_stats", + "reset_pipeline_registry", + "split_sql_script", + "update_cache_config", + "validate_parameter_alignment", + "wrap_with_type", ) diff --git a/sqlspec/core/compiler.py b/sqlspec/core/compiler.py index 98d86715b..b8bba8b3e 100644 --- a/sqlspec/core/compiler.py +++ b/sqlspec/core/compiler.py @@ -26,6 +26,17 @@ from sqlspec.core.statement import StatementConfig +__all__ = ( + "CompiledSQL", + "OperationProfile", + "OperationType", + "SQLProcessor", + "is_copy_from_operation", + "is_copy_operation", + "is_copy_to_operation", +) + +logger: "logging.Logger" = get_logger("sqlspec.core.compiler") OperationType = Literal[ "SELECT", "INSERT", @@ -42,11 +53,6 @@ "UNKNOWN", ] - -__all__ = ("CompiledSQL", "OperationProfile", "OperationType", "SQLProcessor") - -logger: "logging.Logger" = get_logger("sqlspec.core.compiler") - OPERATION_TYPE_MAP: "dict[type[exp.Expression], OperationType]" = { exp.Select: "SELECT", exp.Insert: "INSERT", @@ -60,6 +66,51 @@ exp.Merge: "MERGE", } +COPY_OPERATION_TYPES: "tuple[OperationType, ...]" = ("COPY", "COPY_FROM", "COPY_TO") + +COPY_FROM_OPERATION_TYPES: "tuple[OperationType, ...]" = ("COPY", "COPY_FROM") + +COPY_TO_OPERATION_TYPES: "tuple[OperationType, ...]" = ("COPY_TO",) + + +def is_copy_operation(operation_type: "OperationType") -> bool: + """Determine if the operation corresponds to any PostgreSQL COPY variant. + + Args: + operation_type: Operation type detected by the compiler. + + Returns: + True when the operation type represents COPY, COPY FROM, or COPY TO. + """ + + return operation_type in COPY_OPERATION_TYPES + + +def is_copy_from_operation(operation_type: "OperationType") -> bool: + """Check if the operation streams data into the database using COPY. + + Args: + operation_type: Operation type detected by the compiler. + + Returns: + True for COPY operations that read from client input (COPY FROM). + """ + + return operation_type in COPY_FROM_OPERATION_TYPES + + +def is_copy_to_operation(operation_type: "OperationType") -> bool: + """Check if the operation streams data out from the database using COPY. + + Args: + operation_type: Operation type detected by the compiler. + + Returns: + True for COPY operations that write to client output (COPY TO). + """ + + return operation_type in COPY_TO_OPERATION_TYPES + @mypyc_attr(allow_interpreted_subclasses=False) class OperationProfile: diff --git a/sqlspec/driver/_async.py b/sqlspec/driver/_async.py index 0ef62e912..5a44295d6 100644 --- a/sqlspec/driver/_async.py +++ b/sqlspec/driver/_async.py @@ -3,8 +3,7 @@ from abc import abstractmethod from typing import TYPE_CHECKING, Any, Final, TypeVar, overload -from sqlspec.core import SQL, Statement -from sqlspec.core.result import create_arrow_result +from sqlspec.core import SQL, Statement, create_arrow_result from sqlspec.driver._common import ( CommonDriverAttributesMixin, DataDictionaryMixin, diff --git a/sqlspec/driver/_common.py b/sqlspec/driver/_common.py index 1da5d9e9d..ac7668d25 100644 --- a/sqlspec/driver/_common.py +++ b/sqlspec/driver/_common.py @@ -8,9 +8,18 @@ from sqlglot import exp from sqlspec.builder import QueryBuilder -from sqlspec.core import SQL, ParameterStyle, SQLResult, Statement, StatementConfig, TypedParameter -from sqlspec.core.cache import CachedStatement, get_cache, get_cache_config -from sqlspec.core.splitter import split_sql_script +from sqlspec.core import ( + SQL, + CachedStatement, + ParameterStyle, + SQLResult, + Statement, + StatementConfig, + TypedParameter, + get_cache, + get_cache_config, + split_sql_script, +) from sqlspec.exceptions import ImproperConfigurationError, NotFoundError from sqlspec.utils.logging import get_logger from sqlspec.utils.type_guards import is_statement_filter @@ -18,7 +27,7 @@ if TYPE_CHECKING: from collections.abc import Sequence - from sqlspec.core.filters import FilterTypeT, StatementFilter + from sqlspec.core import FilterTypeT, StatementFilter from sqlspec.typing import StatementParameters diff --git a/sqlspec/driver/mixins/_sql_translator.py b/sqlspec/driver/mixins/_sql_translator.py index d449edc53..138fbc004 100644 --- a/sqlspec/driver/mixins/_sql_translator.py +++ b/sqlspec/driver/mixins/_sql_translator.py @@ -6,7 +6,7 @@ from sqlglot import exp, parse_one from sqlglot.dialects.dialect import DialectType -from sqlspec.core.statement import SQL, Statement +from sqlspec.core import SQL, Statement from sqlspec.exceptions import SQLConversionError __all__ = ("SQLTranslatorMixin",) diff --git a/sqlspec/extensions/aiosql/adapter.py b/sqlspec/extensions/aiosql/adapter.py index 4d2243ec7..4ccf022d3 100644 --- a/sqlspec/extensions/aiosql/adapter.py +++ b/sqlspec/extensions/aiosql/adapter.py @@ -10,8 +10,7 @@ from contextlib import contextmanager from typing import Any, ClassVar, Generic, TypeVar -from sqlspec.core.result import SQLResult -from sqlspec.core.statement import SQL, StatementConfig +from sqlspec.core import SQL, SQLResult, StatementConfig from sqlspec.driver import AsyncDriverAdapterBase, SyncDriverAdapterBase from sqlspec.typing import AiosqlAsyncProtocol, AiosqlParamType, AiosqlSQLOperationType, AiosqlSyncProtocol from sqlspec.utils.module_loader import ensure_aiosql diff --git a/sqlspec/extensions/fastapi/extension.py b/sqlspec/extensions/fastapi/extension.py index fcd020d33..bba7ea8aa 100644 --- a/sqlspec/extensions/fastapi/extension.py +++ b/sqlspec/extensions/fastapi/extension.py @@ -11,7 +11,7 @@ from collections.abc import Callable from sqlspec.config import AsyncDatabaseConfig, SyncDatabaseConfig - from sqlspec.core.filters import FilterTypes + from sqlspec.core import FilterTypes from sqlspec.driver import AsyncDriverAdapterBase, SyncDriverAdapterBase from sqlspec.extensions.fastapi.providers import DependencyDefaults, FilterConfig diff --git a/sqlspec/extensions/fastapi/providers.py b/sqlspec/extensions/fastapi/providers.py index 178b9c42a..28f4f3fc6 100644 --- a/sqlspec/extensions/fastapi/providers.py +++ b/sqlspec/extensions/fastapi/providers.py @@ -13,7 +13,7 @@ from fastapi.exceptions import RequestValidationError from typing_extensions import NotRequired, TypedDict -from sqlspec.core.filters import ( +from sqlspec.core import ( BeforeAfterFilter, FilterTypes, InCollectionFilter, diff --git a/sqlspec/extensions/litestar/providers.py b/sqlspec/extensions/litestar/providers.py index 8e0bbbd8d..fe87c1516 100644 --- a/sqlspec/extensions/litestar/providers.py +++ b/sqlspec/extensions/litestar/providers.py @@ -14,7 +14,7 @@ from litestar.params import Dependency, Parameter from typing_extensions import NotRequired -from sqlspec.core.filters import ( +from sqlspec.core import ( BeforeAfterFilter, FilterTypes, InCollectionFilter, diff --git a/sqlspec/loader.py b/sqlspec/loader.py index b2e62bf7d..8a1fee962 100644 --- a/sqlspec/loader.py +++ b/sqlspec/loader.py @@ -12,8 +12,7 @@ from typing import TYPE_CHECKING, Any, Final from urllib.parse import unquote, urlparse -from sqlspec.core.cache import get_cache, get_cache_config -from sqlspec.core.statement import SQL +from sqlspec.core import SQL, get_cache, get_cache_config from sqlspec.exceptions import SQLFileNotFoundError, SQLFileParseError, StorageOperationFailedError from sqlspec.storage.registry import storage_registry as default_storage_registry from sqlspec.utils.correlation import CorrelationContext diff --git a/sqlspec/migrations/runner.py b/sqlspec/migrations/runner.py index c30f7d637..8ee04b0d8 100644 --- a/sqlspec/migrations/runner.py +++ b/sqlspec/migrations/runner.py @@ -10,7 +10,7 @@ from pathlib import Path from typing import TYPE_CHECKING, Any, Literal, Union, cast, overload -from sqlspec.core.statement import SQL +from sqlspec.core import SQL from sqlspec.migrations.context import MigrationContext from sqlspec.migrations.loaders import get_migration_loader from sqlspec.utils.logging import get_logger diff --git a/sqlspec/utils/type_guards.py b/sqlspec/utils/type_guards.py index 68ae0c002..81c4094ec 100644 --- a/sqlspec/utils/type_guards.py +++ b/sqlspec/utils/type_guards.py @@ -32,7 +32,7 @@ from sqlspec._typing import AttrsInstanceStub, BaseModelStub, DTODataStub, StructStub from sqlspec.builder import Select - from sqlspec.core.filters import LimitOffsetFilter, StatementFilter + from sqlspec.core import LimitOffsetFilter, StatementFilter from sqlspec.protocols import ( BytesConvertibleProtocol, DictProtocol, @@ -154,7 +154,7 @@ def is_statement_filter(obj: Any) -> "TypeGuard[StatementFilter]": Returns: True if the object is a StatementFilter, False otherwise """ - from sqlspec.core.filters import StatementFilter as FilterProtocol + from sqlspec.core import StatementFilter as FilterProtocol return isinstance(obj, FilterProtocol) @@ -168,7 +168,7 @@ def is_limit_offset_filter(obj: Any) -> "TypeGuard[LimitOffsetFilter]": Returns: True if the object is a LimitOffsetFilter, False otherwise """ - from sqlspec.core.filters import LimitOffsetFilter + from sqlspec.core import LimitOffsetFilter return isinstance(obj, LimitOffsetFilter) @@ -1223,7 +1223,7 @@ def is_typed_parameter(obj: Any) -> "TypeGuard[Any]": Returns: True if the object is a TypedParameter, False otherwise """ - from sqlspec.core.parameters import TypedParameter + from sqlspec.core import TypedParameter return isinstance(obj, TypedParameter) diff --git a/tests/integration/test_adapters/test_adbc/test_adbc_arrow_features.py b/tests/integration/test_adapters/test_adbc/test_adbc_arrow_features.py index efed5a881..c9fcd7c38 100644 --- a/tests/integration/test_adapters/test_adbc/test_adbc_arrow_features.py +++ b/tests/integration/test_adapters/test_adbc/test_adbc_arrow_features.py @@ -6,7 +6,7 @@ from pytest_databases.docker.postgres import PostgresService from sqlspec.adapters.adbc import AdbcConfig, AdbcDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult from tests.integration.test_adapters.test_adbc.conftest import xfail_if_driver_missing diff --git a/tests/integration/test_adapters/test_adbc/test_adbc_backends.py b/tests/integration/test_adapters/test_adbc/test_adbc_backends.py index 7078e9b84..0179d8971 100644 --- a/tests/integration/test_adapters/test_adbc/test_adbc_backends.py +++ b/tests/integration/test_adapters/test_adbc/test_adbc_backends.py @@ -7,7 +7,7 @@ from pytest_databases.docker.postgres import PostgresService from sqlspec.adapters.adbc import AdbcConfig, AdbcDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult from tests.integration.test_adapters.test_adbc.conftest import xfail_if_driver_missing diff --git a/tests/integration/test_adapters/test_adbc/test_adbc_driver.py b/tests/integration/test_adapters/test_adbc/test_adbc_driver.py index 4c05a3e75..d670be664 100644 --- a/tests/integration/test_adapters/test_adbc/test_adbc_driver.py +++ b/tests/integration/test_adapters/test_adbc/test_adbc_driver.py @@ -5,7 +5,7 @@ import pytest from sqlspec.adapters.adbc import AdbcDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult from tests.integration.test_adapters.test_adbc.conftest import xfail_if_driver_missing ParamStyle = Literal["tuple_binds", "dict_binds", "named_binds"] diff --git a/tests/integration/test_adapters/test_adbc/test_adbc_edge_cases.py b/tests/integration/test_adapters/test_adbc/test_adbc_edge_cases.py index bc670f4ef..fc3821d21 100644 --- a/tests/integration/test_adapters/test_adbc/test_adbc_edge_cases.py +++ b/tests/integration/test_adapters/test_adbc/test_adbc_edge_cases.py @@ -7,7 +7,7 @@ from pytest_databases.docker.postgres import PostgresService from sqlspec.adapters.adbc import AdbcConfig, AdbcDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult from tests.integration.test_adapters.test_adbc.conftest import xfail_if_driver_missing # xdist_group is assigned per test based on database backend to enable parallel execution diff --git a/tests/integration/test_adapters/test_adbc/test_adbc_results.py b/tests/integration/test_adapters/test_adbc/test_adbc_results.py index 2c2992196..8d6249587 100644 --- a/tests/integration/test_adapters/test_adbc/test_adbc_results.py +++ b/tests/integration/test_adapters/test_adbc/test_adbc_results.py @@ -6,7 +6,7 @@ from pytest_databases.docker.postgres import PostgresService from sqlspec.adapters.adbc import AdbcConfig, AdbcDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult from tests.integration.test_adapters.test_adbc.conftest import xfail_if_driver_missing diff --git a/tests/integration/test_adapters/test_adbc/test_parameter_styles.py b/tests/integration/test_adapters/test_adbc/test_parameter_styles.py index c1509052e..a951ba8d8 100644 --- a/tests/integration/test_adapters/test_adbc/test_parameter_styles.py +++ b/tests/integration/test_adapters/test_adbc/test_parameter_styles.py @@ -13,7 +13,7 @@ from pytest_databases.docker.postgres import PostgresService from sqlspec.adapters.adbc import AdbcConfig, AdbcDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult from sqlspec.exceptions import SQLSpecError from tests.integration.test_adapters.test_adbc.conftest import xfail_if_driver_missing @@ -579,7 +579,7 @@ def test_adbc_ast_transformer_validation_fixed(adbc_postgresql_session: AdbcDriv """ from sqlglot import parse_one - from sqlspec.core.parameters import replace_null_parameters_with_literals + from sqlspec.core import replace_null_parameters_with_literals # Create a test case with parameter count mismatch original_sql = "INSERT INTO bug_test (id, col1) VALUES ($1, $2)" diff --git a/tests/integration/test_adapters/test_aiosqlite/test_connection.py b/tests/integration/test_adapters/test_aiosqlite/test_connection.py index 3594f239c..c1605df04 100644 --- a/tests/integration/test_adapters/test_aiosqlite/test_connection.py +++ b/tests/integration/test_adapters/test_aiosqlite/test_connection.py @@ -9,7 +9,7 @@ import pytest from sqlspec.adapters.aiosqlite import AiosqliteConfig, AiosqliteDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("sqlite") diff --git a/tests/integration/test_adapters/test_aiosqlite/test_driver.py b/tests/integration/test_adapters/test_aiosqlite/test_driver.py index a506aed7a..cee20e9e6 100644 --- a/tests/integration/test_adapters/test_aiosqlite/test_driver.py +++ b/tests/integration/test_adapters/test_aiosqlite/test_driver.py @@ -8,8 +8,7 @@ import pytest from sqlspec.adapters.aiosqlite import AiosqliteDriver -from sqlspec.core.result import SQLResult -from sqlspec.core.statement import SQL +from sqlspec.core import SQL, SQLResult pytestmark = pytest.mark.xdist_group("sqlite") ParamStyle = Literal["tuple_binds", "dict_binds", "named_binds"] @@ -366,7 +365,7 @@ async def test_aiosqlite_sqlite_specific_features(aiosqlite_session: AiosqliteDr except Exception: pass - from sqlspec.core.statement import StatementConfig + from sqlspec.core import StatementConfig non_strict_config = StatementConfig(enable_parsing=False, enable_validation=False) diff --git a/tests/integration/test_adapters/test_aiosqlite/test_parameter_styles.py b/tests/integration/test_adapters/test_aiosqlite/test_parameter_styles.py index 80225adad..8f832bdd0 100644 --- a/tests/integration/test_adapters/test_aiosqlite/test_parameter_styles.py +++ b/tests/integration/test_adapters/test_aiosqlite/test_parameter_styles.py @@ -7,7 +7,7 @@ import pytest from sqlspec.adapters.aiosqlite.config import AiosqliteConfig -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("sqlite") diff --git a/tests/integration/test_adapters/test_aiosqlite/test_pooling.py b/tests/integration/test_adapters/test_aiosqlite/test_pooling.py index 19ad26ab2..954e6079f 100644 --- a/tests/integration/test_adapters/test_aiosqlite/test_pooling.py +++ b/tests/integration/test_adapters/test_aiosqlite/test_pooling.py @@ -9,7 +9,7 @@ import pytest from sqlspec.adapters.aiosqlite.config import AiosqliteConfig -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("sqlite") @@ -121,7 +121,7 @@ async def test_file_database_pooling_enabled() -> None: async def test_pooling_with_core_round_3(aiosqlite_config: AiosqliteConfig) -> None: """Test pooling integration.""" - from sqlspec.core.statement import SQL + from sqlspec.core import SQL create_sql = SQL(""" CREATE TABLE IF NOT EXISTS pool_core_test ( diff --git a/tests/integration/test_adapters/test_asyncmy/test_asyncmy_features.py b/tests/integration/test_adapters/test_asyncmy/test_asyncmy_features.py index 086257165..d963059cb 100644 --- a/tests/integration/test_adapters/test_asyncmy/test_asyncmy_features.py +++ b/tests/integration/test_adapters/test_asyncmy/test_asyncmy_features.py @@ -14,8 +14,7 @@ from pytest_databases.docker.mysql import MySQLService from sqlspec.adapters.asyncmy import AsyncmyConfig, AsyncmyDriver, asyncmy_statement_config -from sqlspec.core.result import SQLResult -from sqlspec.core.statement import SQL +from sqlspec.core import SQL, SQLResult pytestmark = pytest.mark.xdist_group("mysql") diff --git a/tests/integration/test_adapters/test_asyncmy/test_config.py b/tests/integration/test_adapters/test_asyncmy/test_config.py index a4d2bfacb..400baadfc 100644 --- a/tests/integration/test_adapters/test_asyncmy/test_config.py +++ b/tests/integration/test_adapters/test_asyncmy/test_config.py @@ -10,7 +10,7 @@ AsyncmyDriverFeatures, AsyncmyPoolParams, ) -from sqlspec.core.statement import StatementConfig +from sqlspec.core import StatementConfig pytestmark = pytest.mark.xdist_group("mysql") diff --git a/tests/integration/test_adapters/test_asyncmy/test_driver.py b/tests/integration/test_adapters/test_asyncmy/test_driver.py index 0d0d5bfd9..d79ba0807 100644 --- a/tests/integration/test_adapters/test_asyncmy/test_driver.py +++ b/tests/integration/test_adapters/test_asyncmy/test_driver.py @@ -12,8 +12,7 @@ from pytest_databases.docker.mysql import MySQLService from sqlspec.adapters.asyncmy import AsyncmyConfig, AsyncmyDriver -from sqlspec.core.result import SQLResult -from sqlspec.core.statement import SQL +from sqlspec.core import SQL, SQLResult from sqlspec.utils.serializers import from_json, to_json ParamStyle = Literal["tuple_binds", "dict_binds", "named_binds"] diff --git a/tests/integration/test_adapters/test_asyncmy/test_parameter_styles.py b/tests/integration/test_adapters/test_asyncmy/test_parameter_styles.py index 5f1b9c6c7..e1dfaf0ed 100644 --- a/tests/integration/test_adapters/test_asyncmy/test_parameter_styles.py +++ b/tests/integration/test_adapters/test_asyncmy/test_parameter_styles.py @@ -18,8 +18,7 @@ from pytest_databases.docker.mysql import MySQLService from sqlspec.adapters.asyncmy import AsyncmyConfig, AsyncmyDriver, asyncmy_statement_config -from sqlspec.core.result import SQLResult -from sqlspec.core.statement import SQL +from sqlspec.core import SQL, SQLResult pytestmark = pytest.mark.xdist_group("mysql") diff --git a/tests/integration/test_adapters/test_asyncpg/test_driver.py b/tests/integration/test_adapters/test_asyncpg/test_driver.py index 19a201d1a..4151383c9 100644 --- a/tests/integration/test_adapters/test_asyncpg/test_driver.py +++ b/tests/integration/test_adapters/test_asyncpg/test_driver.py @@ -7,7 +7,7 @@ from pytest_databases.docker.postgres import PostgresService from sqlspec.adapters.asyncpg import AsyncpgConfig, AsyncpgDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult ParamStyle = Literal["tuple_binds", "dict_binds", "named_binds"] diff --git a/tests/integration/test_adapters/test_asyncpg/test_execute_many.py b/tests/integration/test_adapters/test_asyncpg/test_execute_many.py index 83403ae05..61ee67a80 100644 --- a/tests/integration/test_adapters/test_asyncpg/test_execute_many.py +++ b/tests/integration/test_adapters/test_asyncpg/test_execute_many.py @@ -5,7 +5,7 @@ import pytest from sqlspec.adapters.asyncpg import AsyncpgDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("postgres") @@ -165,7 +165,7 @@ async def test_asyncpg_execute_many_large_batch(asyncpg_batch_session: AsyncpgDr async def test_asyncpg_execute_many_with_sql_object(asyncpg_batch_session: AsyncpgDriver) -> None: """Test execute_many with SQL object on AsyncPG.""" - from sqlspec.core.statement import SQL + from sqlspec.core import SQL parameters = [("SQL Obj 1", 111, "SOB"), ("SQL Obj 2", 222, "SOB"), ("SQL Obj 3", 333, "SOB")] diff --git a/tests/integration/test_adapters/test_asyncpg/test_merge.py b/tests/integration/test_adapters/test_asyncpg/test_merge.py index 8b4be0092..4acd5fcbf 100644 --- a/tests/integration/test_adapters/test_asyncpg/test_merge.py +++ b/tests/integration/test_adapters/test_asyncpg/test_merge.py @@ -16,7 +16,7 @@ from sqlspec import sql from sqlspec.adapters.asyncpg.driver import AsyncpgDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = [pytest.mark.asyncpg, pytest.mark.integration, pytest.mark.xdist_group("postgres")] diff --git a/tests/integration/test_adapters/test_asyncpg/test_merge_bulk.py b/tests/integration/test_adapters/test_asyncpg/test_merge_bulk.py index 155eeaddd..e59753e95 100644 --- a/tests/integration/test_adapters/test_asyncpg/test_merge_bulk.py +++ b/tests/integration/test_adapters/test_asyncpg/test_merge_bulk.py @@ -16,7 +16,7 @@ from sqlspec import sql from sqlspec.adapters.asyncpg.driver import AsyncpgDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = [pytest.mark.asyncpg, pytest.mark.integration, pytest.mark.xdist_group("postgres")] diff --git a/tests/integration/test_adapters/test_asyncpg/test_parameter_styles.py b/tests/integration/test_adapters/test_asyncpg/test_parameter_styles.py index 824cf24ca..bcd335b24 100644 --- a/tests/integration/test_adapters/test_asyncpg/test_parameter_styles.py +++ b/tests/integration/test_adapters/test_asyncpg/test_parameter_styles.py @@ -9,7 +9,7 @@ import pytest from sqlspec.adapters.asyncpg import AsyncpgDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("postgres") @@ -157,7 +157,7 @@ async def test_asyncpg_parameter_with_any_array(asyncpg_parameters_session: Asyn async def test_asyncpg_parameter_with_sql_object(asyncpg_parameters_session: AsyncpgDriver) -> None: """Test parameters with SQL object.""" - from sqlspec.core.statement import SQL + from sqlspec.core import SQL sql_obj = SQL("SELECT * FROM test_parameters WHERE value > $1", [150]) result = await asyncpg_parameters_session.execute(sql_obj) diff --git a/tests/integration/test_adapters/test_bigquery/test_bigquery_features.py b/tests/integration/test_adapters/test_bigquery/test_bigquery_features.py index 3ab331e55..c7c7fba2b 100644 --- a/tests/integration/test_adapters/test_bigquery/test_bigquery_features.py +++ b/tests/integration/test_adapters/test_bigquery/test_bigquery_features.py @@ -3,7 +3,7 @@ import pytest from sqlspec.adapters.bigquery import BigQueryDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("bigquery") diff --git a/tests/integration/test_adapters/test_bigquery/test_config.py b/tests/integration/test_adapters/test_bigquery/test_config.py index 39530ae1d..c6abc74d9 100644 --- a/tests/integration/test_adapters/test_bigquery/test_config.py +++ b/tests/integration/test_adapters/test_bigquery/test_config.py @@ -6,7 +6,7 @@ from pytest_databases.docker.bigquery import BigQueryService from sqlspec.adapters.bigquery import BigQueryConfig, BigQueryDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("bigquery") diff --git a/tests/integration/test_adapters/test_bigquery/test_connection.py b/tests/integration/test_adapters/test_bigquery/test_connection.py index 9b102bdf3..78ff8642f 100644 --- a/tests/integration/test_adapters/test_bigquery/test_connection.py +++ b/tests/integration/test_adapters/test_bigquery/test_connection.py @@ -3,7 +3,7 @@ import pytest from sqlspec.adapters.bigquery import BigQueryConfig -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("bigquery") diff --git a/tests/integration/test_adapters/test_bigquery/test_driver.py b/tests/integration/test_adapters/test_bigquery/test_driver.py index ea6a068dc..b2a37bcfe 100644 --- a/tests/integration/test_adapters/test_bigquery/test_driver.py +++ b/tests/integration/test_adapters/test_bigquery/test_driver.py @@ -8,7 +8,7 @@ from pytest_databases.docker.bigquery import BigQueryService from sqlspec.adapters.bigquery import BigQueryDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult ParamStyle = Literal["tuple_binds", "dict_binds", "named_binds"] diff --git a/tests/integration/test_adapters/test_duckdb/test_connection.py b/tests/integration/test_adapters/test_duckdb/test_connection.py index e9e879e3e..5a12464a4 100644 --- a/tests/integration/test_adapters/test_duckdb/test_connection.py +++ b/tests/integration/test_adapters/test_duckdb/test_connection.py @@ -11,7 +11,7 @@ import pytest from sqlspec.adapters.duckdb import DuckDBConfig, DuckDBConnection -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("duckdb") diff --git a/tests/integration/test_adapters/test_duckdb/test_driver.py b/tests/integration/test_adapters/test_duckdb/test_driver.py index e59bf3189..2a76a8fc9 100644 --- a/tests/integration/test_adapters/test_duckdb/test_driver.py +++ b/tests/integration/test_adapters/test_duckdb/test_driver.py @@ -6,7 +6,7 @@ import pytest from sqlspec.adapters.duckdb import DuckDBDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("duckdb") diff --git a/tests/integration/test_adapters/test_duckdb/test_execute_many.py b/tests/integration/test_adapters/test_duckdb/test_execute_many.py index 265fa352e..509e2cc19 100644 --- a/tests/integration/test_adapters/test_duckdb/test_execute_many.py +++ b/tests/integration/test_adapters/test_duckdb/test_execute_many.py @@ -5,7 +5,7 @@ import pytest from sqlspec.adapters.duckdb import DuckDBDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("duckdb") @@ -165,7 +165,7 @@ def test_duckdb_execute_many_large_batch(duckdb_batch_session: DuckDBDriver) -> def test_duckdb_execute_many_with_sql_object(duckdb_batch_session: DuckDBDriver) -> None: """Test execute_many with SQL object on DuckDB.""" - from sqlspec.core.statement import SQL + from sqlspec.core import SQL parameters = [(10, "SQL Obj 1", 111, "SOB"), (20, "SQL Obj 2", 222, "SOB"), (30, "SQL Obj 3", 333, "SOB")] diff --git a/tests/integration/test_adapters/test_duckdb/test_mixed_parameter_styles.py b/tests/integration/test_adapters/test_duckdb/test_mixed_parameter_styles.py index 732407cdc..9fdcf1a7f 100644 --- a/tests/integration/test_adapters/test_duckdb/test_mixed_parameter_styles.py +++ b/tests/integration/test_adapters/test_duckdb/test_mixed_parameter_styles.py @@ -5,7 +5,7 @@ import pytest from sqlspec.adapters.duckdb import DuckDBConfig, DuckDBDriver -from sqlspec.core.statement import SQL +from sqlspec.core import SQL from tests.integration.test_adapters.test_duckdb.utils import get_unique_table_name pytestmark = pytest.mark.xdist_group("duckdb") diff --git a/tests/integration/test_adapters/test_duckdb/test_parameter_styles.py b/tests/integration/test_adapters/test_duckdb/test_parameter_styles.py index a1a2f446e..bff8a6cd3 100644 --- a/tests/integration/test_adapters/test_duckdb/test_parameter_styles.py +++ b/tests/integration/test_adapters/test_duckdb/test_parameter_styles.py @@ -9,7 +9,7 @@ import pytest from sqlspec.adapters.duckdb import DuckDBConfig, DuckDBDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("duckdb") @@ -174,7 +174,7 @@ def test_duckdb_parameter_with_in_clause(duckdb_parameters_session: DuckDBDriver def test_duckdb_parameter_with_sql_object(duckdb_parameters_session: DuckDBDriver) -> None: """Test parameters with SQL object.""" - from sqlspec.core.statement import SQL + from sqlspec.core import SQL sql_obj = SQL("SELECT * FROM test_parameters WHERE value > ?", [150]) result = duckdb_parameters_session.execute(sql_obj) diff --git a/tests/integration/test_adapters/test_oracledb/test_driver_async.py b/tests/integration/test_adapters/test_oracledb/test_driver_async.py index 53e59dea5..e69de5761 100644 --- a/tests/integration/test_adapters/test_oracledb/test_driver_async.py +++ b/tests/integration/test_adapters/test_oracledb/test_driver_async.py @@ -6,7 +6,7 @@ import pytest from sqlspec.adapters.oracledb import OracleAsyncConfig, OracleAsyncDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = [pytest.mark.xdist_group("oracle"), pytest.mark.asyncio(loop_scope="function")] diff --git a/tests/integration/test_adapters/test_oracledb/test_driver_sync.py b/tests/integration/test_adapters/test_oracledb/test_driver_sync.py index a5472d79b..4b85c37be 100644 --- a/tests/integration/test_adapters/test_oracledb/test_driver_sync.py +++ b/tests/integration/test_adapters/test_oracledb/test_driver_sync.py @@ -6,7 +6,7 @@ import pytest from sqlspec.adapters.oracledb import OracleSyncConfig, OracleSyncDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("oracle") diff --git a/tests/integration/test_adapters/test_oracledb/test_execute_many.py b/tests/integration/test_adapters/test_oracledb/test_execute_many.py index 824ba6913..9ae1980fe 100644 --- a/tests/integration/test_adapters/test_oracledb/test_execute_many.py +++ b/tests/integration/test_adapters/test_oracledb/test_execute_many.py @@ -5,7 +5,7 @@ import pytest from sqlspec.adapters.oracledb import OracleAsyncDriver, OracleSyncDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult BatchParameters = list[tuple[Any, ...]] | list[dict[str, Any]] | list[list[Any]] pytestmark = pytest.mark.xdist_group("oracle") diff --git a/tests/integration/test_adapters/test_oracledb/test_merge.py b/tests/integration/test_adapters/test_oracledb/test_merge.py index da1e896a0..31ceebf36 100644 --- a/tests/integration/test_adapters/test_oracledb/test_merge.py +++ b/tests/integration/test_adapters/test_oracledb/test_merge.py @@ -7,7 +7,7 @@ from sqlspec import sql from sqlspec.adapters.oracledb import OracleAsyncConfig, OracleAsyncDriver, OracleSyncConfig, OracleSyncDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("oracle") diff --git a/tests/integration/test_adapters/test_oracledb/test_merge_bulk.py b/tests/integration/test_adapters/test_oracledb/test_merge_bulk.py index cd1ad28b1..22c359999 100644 --- a/tests/integration/test_adapters/test_oracledb/test_merge_bulk.py +++ b/tests/integration/test_adapters/test_oracledb/test_merge_bulk.py @@ -16,7 +16,7 @@ from sqlspec import sql from sqlspec.adapters.oracledb.driver import OracleAsyncDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = [pytest.mark.oracle, pytest.mark.integration, pytest.mark.xdist_group("oracle")] diff --git a/tests/integration/test_adapters/test_oracledb/test_oracle_features.py b/tests/integration/test_adapters/test_oracledb/test_oracle_features.py index 6b6f0c1dc..af7b418b6 100644 --- a/tests/integration/test_adapters/test_oracledb/test_oracle_features.py +++ b/tests/integration/test_adapters/test_oracledb/test_oracle_features.py @@ -6,8 +6,7 @@ import pytest from sqlspec.adapters.oracledb import OracleAsyncDriver, OracleSyncDriver -from sqlspec.core.result import SQLResult -from sqlspec.core.statement import SQL, StatementConfig +from sqlspec.core import SQL, SQLResult, StatementConfig def _lower_keys(row: dict[str, object]) -> dict[str, object]: diff --git a/tests/integration/test_adapters/test_oracledb/test_parameter_styles.py b/tests/integration/test_adapters/test_oracledb/test_parameter_styles.py index ef3a3ceb8..155b292c6 100644 --- a/tests/integration/test_adapters/test_oracledb/test_parameter_styles.py +++ b/tests/integration/test_adapters/test_oracledb/test_parameter_styles.py @@ -5,7 +5,7 @@ import pytest from sqlspec.adapters.oracledb import OracleAsyncDriver, OracleSyncDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult def _lower_dict(data: dict[str, Any]) -> dict[str, Any]: diff --git a/tests/integration/test_adapters/test_psqlpy/test_connection.py b/tests/integration/test_adapters/test_psqlpy/test_connection.py index 3b2bd86ec..c6f0079bb 100644 --- a/tests/integration/test_adapters/test_psqlpy/test_connection.py +++ b/tests/integration/test_adapters/test_psqlpy/test_connection.py @@ -7,7 +7,7 @@ import pytest from sqlspec.adapters.psqlpy.config import PsqlpyConfig -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult if TYPE_CHECKING: pass @@ -69,7 +69,7 @@ async def test_connection_error_handling(psqlpy_config: PsqlpyConfig) -> None: async def test_connection_with_core_round_3(psqlpy_config: PsqlpyConfig) -> None: """Test connection integration.""" - from sqlspec.core.statement import SQL + from sqlspec.core import SQL test_sql = SQL("SELECT $1::text as test_value") diff --git a/tests/integration/test_adapters/test_psqlpy/test_driver.py b/tests/integration/test_adapters/test_psqlpy/test_driver.py index ac5f002b4..e323bd900 100644 --- a/tests/integration/test_adapters/test_psqlpy/test_driver.py +++ b/tests/integration/test_adapters/test_psqlpy/test_driver.py @@ -7,8 +7,7 @@ import pytest from sqlspec.adapters.psqlpy import PsqlpyDriver -from sqlspec.core.result import SQLResult -from sqlspec.core.statement import SQL +from sqlspec.core import SQL, SQLResult if TYPE_CHECKING: pass diff --git a/tests/integration/test_adapters/test_psqlpy/test_merge_bulk.py b/tests/integration/test_adapters/test_psqlpy/test_merge_bulk.py index d0a3e96fa..79cea0f51 100644 --- a/tests/integration/test_adapters/test_psqlpy/test_merge_bulk.py +++ b/tests/integration/test_adapters/test_psqlpy/test_merge_bulk.py @@ -15,7 +15,7 @@ from sqlspec import sql from sqlspec.adapters.psqlpy.driver import PsqlpyDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = [pytest.mark.xdist_group("postgres"), pytest.mark.psqlpy, pytest.mark.integration] diff --git a/tests/integration/test_adapters/test_psqlpy/test_parameter_styles.py b/tests/integration/test_adapters/test_psqlpy/test_parameter_styles.py index 1a978151f..f5250e093 100644 --- a/tests/integration/test_adapters/test_psqlpy/test_parameter_styles.py +++ b/tests/integration/test_adapters/test_psqlpy/test_parameter_styles.py @@ -10,8 +10,7 @@ import pytest from sqlspec.adapters.psqlpy import PsqlpyDriver -from sqlspec.core.result import SQLResult -from sqlspec.core.statement import SQL +from sqlspec.core import SQL, SQLResult pytestmark = pytest.mark.xdist_group("postgres") diff --git a/tests/integration/test_adapters/test_psqlpy/test_psqlpy_features.py b/tests/integration/test_adapters/test_psqlpy/test_psqlpy_features.py index a142768e2..b7485ce26 100644 --- a/tests/integration/test_adapters/test_psqlpy/test_psqlpy_features.py +++ b/tests/integration/test_adapters/test_psqlpy/test_psqlpy_features.py @@ -5,8 +5,7 @@ import pytest from sqlspec.adapters.psqlpy import PsqlpyDriver -from sqlspec.core.result import SQLResult -from sqlspec.core.statement import SQL +from sqlspec.core import SQL, SQLResult pytestmark = pytest.mark.xdist_group("postgres") diff --git a/tests/integration/test_adapters/test_psycopg/test_async_copy.py b/tests/integration/test_adapters/test_psycopg/test_async_copy.py index 0e6de6d72..bc0888b9f 100644 --- a/tests/integration/test_adapters/test_psycopg/test_async_copy.py +++ b/tests/integration/test_adapters/test_psycopg/test_async_copy.py @@ -8,7 +8,7 @@ from pytest_databases.docker.postgres import PostgresService from sqlspec.adapters.psycopg import PsycopgAsyncConfig, PsycopgAsyncDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("postgres") diff --git a/tests/integration/test_adapters/test_psycopg/test_driver.py b/tests/integration/test_adapters/test_psycopg/test_driver.py index 47522edbc..50c42e9a6 100644 --- a/tests/integration/test_adapters/test_psycopg/test_driver.py +++ b/tests/integration/test_adapters/test_psycopg/test_driver.py @@ -6,7 +6,7 @@ import pytest from sqlspec.adapters.psycopg import PsycopgSyncConfig, PsycopgSyncDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult ParamStyle = Literal["tuple_binds", "dict_binds", "named_binds"] diff --git a/tests/integration/test_adapters/test_psycopg/test_execute_many.py b/tests/integration/test_adapters/test_psycopg/test_execute_many.py index b9967a381..29937da4c 100644 --- a/tests/integration/test_adapters/test_psycopg/test_execute_many.py +++ b/tests/integration/test_adapters/test_psycopg/test_execute_many.py @@ -7,7 +7,7 @@ from sqlspec.adapters.psycopg import PsycopgSyncConfig, PsycopgSyncDriver from sqlspec.adapters.psycopg.driver import psycopg_statement_config -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("postgres") @@ -182,7 +182,7 @@ def test_psycopg_execute_many_large_batch(psycopg_batch_session: PsycopgSyncDriv def test_psycopg_execute_many_with_sql_object(psycopg_batch_session: PsycopgSyncDriver) -> None: """Test execute_many with SQL object on Psycopg.""" - from sqlspec.core.statement import SQL + from sqlspec.core import SQL parameters = [("SQL Obj 1", 111, "SOB"), ("SQL Obj 2", 222, "SOB"), ("SQL Obj 3", 333, "SOB")] diff --git a/tests/integration/test_adapters/test_psycopg/test_merge_bulk.py b/tests/integration/test_adapters/test_psycopg/test_merge_bulk.py index 518c4b3cd..c47a5b654 100644 --- a/tests/integration/test_adapters/test_psycopg/test_merge_bulk.py +++ b/tests/integration/test_adapters/test_psycopg/test_merge_bulk.py @@ -16,7 +16,7 @@ from sqlspec import sql from sqlspec.adapters.psycopg.driver import PsycopgSyncDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = [pytest.mark.psycopg, pytest.mark.integration, pytest.mark.xdist_group("postgres")] diff --git a/tests/integration/test_adapters/test_psycopg/test_parameter_styles.py b/tests/integration/test_adapters/test_psycopg/test_parameter_styles.py index dd243dc31..b240ca628 100644 --- a/tests/integration/test_adapters/test_psycopg/test_parameter_styles.py +++ b/tests/integration/test_adapters/test_psycopg/test_parameter_styles.py @@ -8,7 +8,7 @@ from pytest_databases.docker.postgres import PostgresService from sqlspec.adapters.psycopg import PsycopgSyncConfig, PsycopgSyncDriver, psycopg_statement_config -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("postgres") @@ -191,7 +191,7 @@ def test_psycopg_parameter_with_any_array(psycopg_parameters_session: PsycopgSyn def test_psycopg_parameter_with_sql_object(psycopg_parameters_session: PsycopgSyncDriver) -> None: """Test parameters with SQL object.""" - from sqlspec.core.statement import SQL + from sqlspec.core import SQL sql_obj = SQL("SELECT * FROM test_parameters WHERE value > %s", [150]) result = psycopg_parameters_session.execute(sql_obj) diff --git a/tests/integration/test_adapters/test_sqlite/test_driver.py b/tests/integration/test_adapters/test_sqlite/test_driver.py index 420ab9cd0..79a73b59d 100644 --- a/tests/integration/test_adapters/test_sqlite/test_driver.py +++ b/tests/integration/test_adapters/test_sqlite/test_driver.py @@ -6,7 +6,7 @@ import pytest from sqlspec.adapters.sqlite import SqliteDriver -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("sqlite") ParamStyle = Literal["tuple_binds", "dict_binds", "named_binds"] diff --git a/tests/integration/test_adapters/test_sqlite/test_parameter_styles.py b/tests/integration/test_adapters/test_sqlite/test_parameter_styles.py index 48b985d89..b7ce1f7db 100644 --- a/tests/integration/test_adapters/test_sqlite/test_parameter_styles.py +++ b/tests/integration/test_adapters/test_sqlite/test_parameter_styles.py @@ -8,8 +8,7 @@ import pytest from sqlspec.adapters.sqlite import SqliteConfig, SqliteDriver -from sqlspec.core.result import SQLResult -from sqlspec.core.statement import SQL +from sqlspec.core import SQL, SQLResult pytestmark = pytest.mark.xdist_group("sqlite") diff --git a/tests/integration/test_adapters/test_sqlite/test_pooling.py b/tests/integration/test_adapters/test_sqlite/test_pooling.py index c637e4cb6..2fd6359e0 100644 --- a/tests/integration/test_adapters/test_sqlite/test_pooling.py +++ b/tests/integration/test_adapters/test_sqlite/test_pooling.py @@ -6,7 +6,7 @@ import pytest from sqlspec.adapters.sqlite.config import SqliteConfig -from sqlspec.core.result import SQLResult +from sqlspec.core import SQLResult pytestmark = pytest.mark.xdist_group("sqlite") diff --git a/tests/integration/test_adapters/test_sqlite/test_query_mixin.py b/tests/integration/test_adapters/test_sqlite/test_query_mixin.py index ff99d6dfb..044c0c279 100644 --- a/tests/integration/test_adapters/test_sqlite/test_query_mixin.py +++ b/tests/integration/test_adapters/test_sqlite/test_query_mixin.py @@ -5,7 +5,7 @@ import pytest from sqlspec.adapters.sqlite import SqliteDriver -from sqlspec.core.statement import SQL +from sqlspec.core import SQL from sqlspec.exceptions import NotFoundError pytestmark = pytest.mark.xdist_group("sqlite") diff --git a/tests/integration/test_extensions/test_fastapi/test_fastapi_filters_integration.py b/tests/integration/test_extensions/test_fastapi/test_fastapi_filters_integration.py index 0c877ea16..1a387567e 100644 --- a/tests/integration/test_extensions/test_fastapi/test_fastapi_filters_integration.py +++ b/tests/integration/test_extensions/test_fastapi/test_fastapi_filters_integration.py @@ -10,7 +10,7 @@ from sqlspec.adapters.aiosqlite import AiosqliteConfig, AiosqliteDriver from sqlspec.base import SQLSpec -from sqlspec.core.filters import BeforeAfterFilter, FilterTypes, LimitOffsetFilter, OrderByFilter +from sqlspec.core import BeforeAfterFilter, FilterTypes, LimitOffsetFilter, OrderByFilter from sqlspec.extensions.fastapi import SQLSpecPlugin from sqlspec.extensions.fastapi.providers import dep_cache diff --git a/tests/integration/test_loader/test_file_system_loading.py b/tests/integration/test_loader/test_file_system_loading.py index f06abf3b8..eab7fb78c 100644 --- a/tests/integration/test_loader/test_file_system_loading.py +++ b/tests/integration/test_loader/test_file_system_loading.py @@ -17,7 +17,7 @@ import pytest -from sqlspec.core.statement import SQL +from sqlspec.core import SQL from sqlspec.exceptions import SQLFileNotFoundError, SQLFileParseError from sqlspec.loader import SQLFileLoader diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 9c493e256..ea8b606e5 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -13,9 +13,7 @@ import pytest -from sqlspec.core.cache import UnifiedCache -from sqlspec.core.parameters import ParameterStyle, ParameterStyleConfig, TypedParameter -from sqlspec.core.statement import SQL, StatementConfig +from sqlspec.core import SQL, ParameterStyle, ParameterStyleConfig, StatementConfig, TypedParameter, UnifiedCache from sqlspec.driver import ( AsyncDataDictionaryBase, AsyncDriverAdapterBase, @@ -189,7 +187,7 @@ def cache_config_disabled() -> dict[str, Any]: def mock_unified_cache() -> UnifiedCache: """Mock unified cache for testing cache behavior.""" - from sqlspec.core.cache import get_default_cache + from sqlspec.core import get_default_cache return get_default_cache() @@ -605,7 +603,7 @@ def __init__( driver_features: dict[str, Any] | None = None, ) -> None: if statement_config is None: - from sqlspec.core.parameters import ParameterStyleConfig + from sqlspec.core import ParameterStyleConfig parameter_config = ParameterStyleConfig( default_parameter_style=ParameterStyle.QMARK, @@ -713,7 +711,7 @@ def __init__( driver_features: dict[str, Any] | None = None, ) -> None: if statement_config is None: - from sqlspec.core.parameters import ParameterStyleConfig + from sqlspec.core import ParameterStyleConfig parameter_config = ParameterStyleConfig( default_parameter_style=ParameterStyle.QMARK, diff --git a/tests/unit/test_adapters/conftest.py b/tests/unit/test_adapters/conftest.py index ed098dc12..49b79916c 100644 --- a/tests/unit/test_adapters/conftest.py +++ b/tests/unit/test_adapters/conftest.py @@ -5,8 +5,7 @@ import pytest -from sqlspec.core.parameters import ParameterStyle, ParameterStyleConfig -from sqlspec.core.statement import SQL, StatementConfig +from sqlspec.core import SQL, ParameterStyle, ParameterStyleConfig, StatementConfig from sqlspec.driver import ( AsyncDataDictionaryBase, AsyncDriverAdapterBase, diff --git a/tests/unit/test_adapters/test_adapter_implementations.py b/tests/unit/test_adapters/test_adapter_implementations.py index a2d187222..07d417763 100644 --- a/tests/unit/test_adapters/test_adapter_implementations.py +++ b/tests/unit/test_adapters/test_adapter_implementations.py @@ -7,9 +7,7 @@ import pytest from sqlspec.adapters.sqlite.driver import SqliteDriver -from sqlspec.core.parameters import ParameterStyle, ParameterStyleConfig -from sqlspec.core.result import SQLResult -from sqlspec.core.statement import SQL, StatementConfig +from sqlspec.core import SQL, ParameterStyle, ParameterStyleConfig, SQLResult, StatementConfig from sqlspec.driver import ExecutionResult from sqlspec.exceptions import SQLSpecError @@ -181,7 +179,7 @@ def test_sqlite_driver_real_implementation() -> None: connection.execute("INSERT INTO users (name) VALUES ('test_user')") connection.commit() - from sqlspec.core.parameters import ParameterStyleConfig + from sqlspec.core import ParameterStyleConfig simple_config = StatementConfig( dialect="sqlite", @@ -241,7 +239,7 @@ def test_sqlite_driver_exception_handling() -> None: """Test SQLite driver exception handling.""" connection = sqlite3.connect(":memory:") - from sqlspec.core.parameters import ParameterStyleConfig + from sqlspec.core import ParameterStyleConfig simple_config = StatementConfig( dialect="sqlite", @@ -273,7 +271,7 @@ def test_sqlite_driver_cursor_management() -> None: """Test SQLite driver cursor management.""" connection = sqlite3.connect(":memory:") - from sqlspec.core.parameters import ParameterStyleConfig + from sqlspec.core import ParameterStyleConfig simple_config = StatementConfig( dialect="sqlite", @@ -352,7 +350,7 @@ def test_adapter_parameter_handling( def test_execution_result_creation() -> None: """Test ExecutionResult creation and properties.""" - from sqlspec.core.parameters import ParameterStyleConfig + from sqlspec.core import ParameterStyleConfig from sqlspec.driver._common import CommonDriverAttributesMixin config = StatementConfig( @@ -395,7 +393,7 @@ def test_execution_result_creation() -> None: def test_sql_result_building() -> None: """Test SQLResult building from ExecutionResult.""" - from sqlspec.core.parameters import ParameterStyleConfig + from sqlspec.core import ParameterStyleConfig from sqlspec.driver._common import CommonDriverAttributesMixin config = StatementConfig( diff --git a/tests/unit/test_adapters/test_async_adapters.py b/tests/unit/test_adapters/test_async_adapters.py index 1975aa65c..5b9155c1d 100644 --- a/tests/unit/test_adapters/test_async_adapters.py +++ b/tests/unit/test_adapters/test_async_adapters.py @@ -6,9 +6,7 @@ import pytest -from sqlspec.core.parameters import ParameterStyle, ParameterStyleConfig -from sqlspec.core.result import SQLResult -from sqlspec.core.statement import SQL, StatementConfig +from sqlspec.core import SQL, ParameterStyle, ParameterStyleConfig, SQLResult, StatementConfig from sqlspec.driver import ExecutionResult from sqlspec.exceptions import NotFoundError, SQLSpecError from tests.unit.test_adapters.conftest import MockAsyncConnection, MockAsyncCursor, MockAsyncDriver diff --git a/tests/unit/test_adapters/test_sync_adapters.py b/tests/unit/test_adapters/test_sync_adapters.py index f2ffc36c6..6f8dc44a4 100644 --- a/tests/unit/test_adapters/test_sync_adapters.py +++ b/tests/unit/test_adapters/test_sync_adapters.py @@ -6,9 +6,7 @@ import pytest -from sqlspec.core.parameters import ParameterStyle, ParameterStyleConfig -from sqlspec.core.result import SQLResult -from sqlspec.core.statement import SQL, StatementConfig +from sqlspec.core import SQL, ParameterStyle, ParameterStyleConfig, SQLResult, StatementConfig from sqlspec.driver import ExecutionResult from sqlspec.exceptions import NotFoundError, SQLSpecError from tests.unit.test_adapters.conftest import MockSyncConnection, MockSyncDriver diff --git a/tests/unit/test_arrow_result.py b/tests/unit/test_arrow_result.py index 1f9e68d2b..c312d9ae3 100644 --- a/tests/unit/test_arrow_result.py +++ b/tests/unit/test_arrow_result.py @@ -4,7 +4,7 @@ import pytest -from sqlspec.core.statement import SQL +from sqlspec.core import SQL from sqlspec.typing import PYARROW_INSTALLED pytestmark = pytest.mark.skipif(not PYARROW_INSTALLED, reason="pyarrow not installed") @@ -24,7 +24,7 @@ def sample_arrow_table(): @pytest.fixture def arrow_result(sample_arrow_table): """Create an ArrowResult with sample data.""" - from sqlspec.core.result import ArrowResult + from sqlspec.core import ArrowResult stmt = SQL("SELECT * FROM users") return ArrowResult(statement=stmt, data=sample_arrow_table, rows_affected=3) @@ -92,8 +92,7 @@ def test_arrow_result_to_pandas_with_null_values() -> None: pandas = pytest.importorskip("pandas") import pyarrow as pa - from sqlspec.core.result import ArrowResult - from sqlspec.core.statement import SQL + from sqlspec.core import SQL, ArrowResult data: dict[str, Any] = { "id": [1, 2, 3], @@ -114,8 +113,7 @@ def test_arrow_result_empty_table() -> None: """Test ArrowResult methods with empty table.""" import pyarrow as pa - from sqlspec.core.result import ArrowResult - from sqlspec.core.statement import SQL + from sqlspec.core import SQL, ArrowResult empty_table = pa.Table.from_pydict(cast(dict[str, Any], {})) stmt = SQL("SELECT * FROM users WHERE 1=0") @@ -128,8 +126,7 @@ def test_arrow_result_empty_table() -> None: def test_arrow_result_methods_with_none_data_raise() -> None: """Test that methods raise ValueError when data is None.""" - from sqlspec.core.result import ArrowResult - from sqlspec.core.statement import SQL + from sqlspec.core import SQL, ArrowResult stmt = SQL("SELECT * FROM users") result = ArrowResult(statement=stmt, data=None) diff --git a/tests/unit/test_base/test_sql_integration.py b/tests/unit/test_base/test_sql_integration.py index e9fc0cd97..6e5dd347d 100644 --- a/tests/unit/test_base/test_sql_integration.py +++ b/tests/unit/test_base/test_sql_integration.py @@ -13,7 +13,7 @@ import pytest from sqlspec.base import SQLSpec -from sqlspec.core.statement import SQL +from sqlspec.core import SQL from sqlspec.exceptions import SQLFileNotFoundError from sqlspec.loader import SQLFileLoader diff --git a/tests/unit/test_base/test_sqlspec_class.py b/tests/unit/test_base/test_sqlspec_class.py index 1d28893c8..3774ea3ca 100644 --- a/tests/unit/test_base/test_sqlspec_class.py +++ b/tests/unit/test_base/test_sqlspec_class.py @@ -22,7 +22,7 @@ import pytest from sqlspec.base import SQLSpec -from sqlspec.core.cache import CacheConfig +from sqlspec.core import CacheConfig pytestmark = pytest.mark.xdist_group("base") diff --git a/tests/unit/test_core/test_cache.py b/tests/unit/test_core/test_cache.py index ef071c277..29eba0df8 100644 --- a/tests/unit/test_core/test_cache.py +++ b/tests/unit/test_core/test_cache.py @@ -22,7 +22,7 @@ import pytest -from sqlspec.core.cache import ( +from sqlspec.core import ( CacheConfig, CacheKey, CacheStats, diff --git a/tests/unit/test_core/test_compiler.py b/tests/unit/test_core/test_compiler.py index 8b8424466..8921f8c61 100644 --- a/tests/unit/test_core/test_compiler.py +++ b/tests/unit/test_core/test_compiler.py @@ -26,9 +26,18 @@ from sqlglot import expressions as exp from sqlglot.errors import ParseError -from sqlspec.core.compiler import CompiledSQL, OperationType, SQLProcessor -from sqlspec.core.parameters import ParameterProcessor, ParameterStyle, ParameterStyleConfig -from sqlspec.core.statement import StatementConfig +from sqlspec.core import ( + CompiledSQL, + OperationType, + ParameterProcessor, + ParameterStyle, + ParameterStyleConfig, + SQLProcessor, + StatementConfig, + is_copy_from_operation, + is_copy_operation, + is_copy_to_operation, +) pytestmark = pytest.mark.xdist_group("core") @@ -353,6 +362,22 @@ def test_operation_type_detection_via_ast( assert detected_type in ["SELECT", "INSERT", "UPDATE", "DELETE", "COPY", "EXECUTE", "SCRIPT", "DDL", "UNKNOWN"] +def test_copy_operation_helpers() -> None: + """Ensure COPY helper predicates cover all variants.""" + + assert is_copy_operation("COPY") + assert is_copy_operation("COPY_FROM") + assert is_copy_operation("COPY_TO") + assert not is_copy_operation("SELECT") + + assert is_copy_from_operation("COPY") + assert is_copy_from_operation("COPY_FROM") + assert not is_copy_from_operation("COPY_TO") + + assert is_copy_to_operation("COPY_TO") + assert not is_copy_to_operation("COPY") + + def test_single_pass_processing( basic_statement_config: "StatementConfig", sample_sql_queries: "dict[str, str]" ) -> None: diff --git a/tests/unit/test_core/test_filters.py b/tests/unit/test_core/test_filters.py index cbc2a9845..6a15041ba 100644 --- a/tests/unit/test_core/test_filters.py +++ b/tests/unit/test_core/test_filters.py @@ -8,7 +8,8 @@ import pytest -from sqlspec.core.filters import ( +from sqlspec.core import ( + SQL, AnyCollectionFilter, BeforeAfterFilter, InCollectionFilter, @@ -18,7 +19,6 @@ SearchFilter, apply_filter, ) -from sqlspec.core.statement import SQL from sqlspec.driver._common import CommonDriverAttributesMixin pytestmark = pytest.mark.xdist_group("core") diff --git a/tests/unit/test_core/test_hashing.py b/tests/unit/test_core/test_hashing.py index 8264e95f0..3fff6357a 100644 --- a/tests/unit/test_core/test_hashing.py +++ b/tests/unit/test_core/test_hashing.py @@ -12,12 +12,12 @@ import pytest from sqlglot import exp, parse_one -from sqlspec.core.filters import StatementFilter +from sqlspec.core import StatementFilter +from sqlspec.core.hashing import _hash_value if TYPE_CHECKING: - from sqlspec.core.statement import SQL -from sqlspec.core.hashing import ( - _hash_value, + from sqlspec.core import SQL +from sqlspec.core import ( hash_expression, hash_expression_node, hash_filters, @@ -171,7 +171,7 @@ def test_hash_parameters_mixed() -> None: def test_hash_parameters_with_typed_parameters() -> None: """Test hash_parameters with TypedParameter objects.""" - from sqlspec.core.parameters import TypedParameter + from sqlspec.core import TypedParameter typed_param = TypedParameter("test_value", str, "test_semantic") params = [typed_param, "regular_param"] @@ -556,7 +556,7 @@ def test_hash_expression_node_dialects(dialect: str) -> None: def test_hash_parameters_edge_cases() -> None: """Test hash_parameters with various edge cases.""" - from sqlspec.core.parameters import TypedParameter + from sqlspec.core import TypedParameter typed_param_with_list = TypedParameter([1, 2, 3], list, "list_param") typed_param_with_dict = TypedParameter({"key": "value"}, dict, "dict_param") diff --git a/tests/unit/test_core/test_parameters.py b/tests/unit/test_core/test_parameters.py index 837019894..80f96aa6d 100644 --- a/tests/unit/test_core/test_parameters.py +++ b/tests/unit/test_core/test_parameters.py @@ -18,7 +18,7 @@ import pytest import sqlglot -from sqlspec.core.parameters import ( +from sqlspec.core import ( DRIVER_PARAMETER_PROFILES, DriverParameterProfile, ParameterConverter, diff --git a/tests/unit/test_core/test_result.py b/tests/unit/test_core/test_result.py index 1e83975fe..ce913784d 100644 --- a/tests/unit/test_core/test_result.py +++ b/tests/unit/test_core/test_result.py @@ -4,8 +4,7 @@ import pytest -from sqlspec.core.result import SQLResult, create_sql_result -from sqlspec.core.statement import SQL +from sqlspec.core import SQL, SQLResult, create_sql_result pytestmark = pytest.mark.xdist_group("core") diff --git a/tests/unit/test_core/test_statement.py b/tests/unit/test_core/test_statement.py index 16b076b5c..536b27518 100644 --- a/tests/unit/test_core/test_statement.py +++ b/tests/unit/test_core/test_statement.py @@ -22,15 +22,17 @@ import pytest from sqlglot import expressions as exp -from sqlspec.core.cache import get_pipeline_metrics, reset_pipeline_registry -from sqlspec.core.compiler import OperationType -from sqlspec.core.parameters import ParameterStyle, ParameterStyleConfig -from sqlspec.core.statement import ( +from sqlspec.core import ( SQL, + OperationType, + ParameterStyle, + ParameterStyleConfig, ProcessedState, StatementConfig, get_default_config, get_default_parameter_config, + get_pipeline_metrics, + reset_pipeline_registry, ) from sqlspec.typing import Empty @@ -247,7 +249,7 @@ def test_sql_single_pass_processing_triggered_by_sql_property() -> None: stmt = SQL("SELECT * FROM users") with patch("sqlspec.core.statement.compile_with_shared_pipeline") as mock_compile: - from sqlspec.core.compiler import CompiledSQL + from sqlspec.core import CompiledSQL mock_compiled = CompiledSQL( compiled_sql="SELECT * FROM users", @@ -276,7 +278,7 @@ def test_sql_single_pass_processing_triggered_by_parameters_property() -> None: stmt = SQL("SELECT * FROM users WHERE id = ?", 1) with patch("sqlspec.core.statement.compile_with_shared_pipeline") as mock_compile: - from sqlspec.core.compiler import CompiledSQL + from sqlspec.core import CompiledSQL mock_compiled = CompiledSQL( compiled_sql="SELECT * FROM users WHERE id = ?", @@ -298,7 +300,7 @@ def test_sql_single_pass_processing_triggered_by_operation_type_property() -> No stmt = SQL("INSERT INTO users (name) VALUES ('john')") with patch("sqlspec.core.statement.compile_with_shared_pipeline") as mock_compile: - from sqlspec.core.compiler import CompiledSQL + from sqlspec.core import CompiledSQL mock_compiled = CompiledSQL( compiled_sql="INSERT INTO users (name) VALUES ('john')", @@ -341,7 +343,7 @@ def test_sql_expression_caching_enabled() -> None: with patch("sqlspec.core.statement.compile_with_shared_pipeline") as mock_compile: expr = exp.select("*").from_("users") - from sqlspec.core.compiler import CompiledSQL + from sqlspec.core import CompiledSQL mock_compiled = CompiledSQL( compiled_sql="SELECT * FROM users", execution_parameters={}, operation_type="SELECT", expression=expr @@ -368,7 +370,7 @@ def test_sql_expression_caching_disabled() -> None: with patch("sqlspec.core.statement.compile_with_shared_pipeline") as mock_compile: expr = exp.select("*").from_("users") - from sqlspec.core.compiler import CompiledSQL + from sqlspec.core import CompiledSQL mock_compiled = CompiledSQL( compiled_sql="SELECT * FROM users", execution_parameters={}, operation_type="SELECT", expression=expr @@ -438,7 +440,7 @@ def test_sql_parameters_property_returns_processed_parameters() -> None: stmt = SQL("SELECT * FROM users WHERE id = ?", 1) with patch("sqlspec.core.statement.compile_with_shared_pipeline") as mock_compile: - from sqlspec.core.compiler import CompiledSQL + from sqlspec.core import CompiledSQL mock_compiled = CompiledSQL( compiled_sql="SELECT * FROM users WHERE id = ?", @@ -481,7 +483,7 @@ def test_sql_operation_type_detection(sql_statement: str, expected_operation_typ stmt = SQL(sql_statement) with patch("sqlspec.core.statement.compile_with_shared_pipeline") as mock_compile: - from sqlspec.core.compiler import CompiledSQL + from sqlspec.core import CompiledSQL mock_compiled = CompiledSQL( compiled_sql=sql_statement, @@ -498,7 +500,7 @@ def test_sql_operation_type_detection(sql_statement: str, expected_operation_typ def test_sql_returns_rows_detection() -> None: """Test SQL.returns_rows() method for different operation types.""" - from sqlspec.core.statement import ProcessedState + from sqlspec.core import ProcessedState select_stmt = SQL("SELECT * FROM users") select_stmt._processed_state = ProcessedState( @@ -603,7 +605,7 @@ def test_sql_compile_method_compatibility() -> None: stmt = SQL("SELECT * FROM users WHERE id = ?", 1) with patch("sqlspec.core.statement.compile_with_shared_pipeline") as mock_compile: - from sqlspec.core.compiler import CompiledSQL + from sqlspec.core import CompiledSQL mock_compiled = CompiledSQL( compiled_sql="SELECT * FROM users WHERE id = ?", @@ -659,7 +661,7 @@ def test_sql_validation_errors_property_compatibility() -> None: stmt = SQL("SELECT * FROM users") with patch("sqlspec.core.statement.compile_with_shared_pipeline") as mock_compile: - from sqlspec.core.compiler import CompiledSQL + from sqlspec.core import CompiledSQL mock_compiled = CompiledSQL( compiled_sql="SELECT * FROM users", @@ -707,7 +709,7 @@ def test_sql_single_parse_guarantee() -> None: stmt = SQL("SELECT * FROM users WHERE id = ?", 1) with patch("sqlspec.core.statement.compile_with_shared_pipeline") as mock_compile: - from sqlspec.core.compiler import CompiledSQL + from sqlspec.core import CompiledSQL mock_compiled = CompiledSQL( compiled_sql="SELECT * FROM users WHERE id = ?", @@ -745,7 +747,7 @@ def test_sql_processing_caching_performance() -> None: stmt = SQL("SELECT * FROM users") with patch("sqlspec.core.statement.compile_with_shared_pipeline") as mock_compile: - from sqlspec.core.compiler import CompiledSQL + from sqlspec.core import CompiledSQL mock_compiled = CompiledSQL( compiled_sql="SELECT * FROM users", @@ -967,7 +969,7 @@ def test_sql_processing_state_stability() -> None: stmt = SQL("SELECT * FROM users") with patch("sqlspec.core.statement.compile_with_shared_pipeline") as mock_compile: - from sqlspec.core.compiler import CompiledSQL + from sqlspec.core import CompiledSQL mock_compiled = CompiledSQL( compiled_sql="SELECT * FROM users", diff --git a/tests/unit/test_extensions/test_fastapi/test_providers.py b/tests/unit/test_extensions/test_fastapi/test_providers.py index 806e19c5b..9aa6fe7b3 100644 --- a/tests/unit/test_extensions/test_fastapi/test_providers.py +++ b/tests/unit/test_extensions/test_fastapi/test_providers.py @@ -3,7 +3,7 @@ import datetime from uuid import UUID, uuid4 -from sqlspec.core.filters import ( +from sqlspec.core import ( BeforeAfterFilter, InCollectionFilter, LimitOffsetFilter, diff --git a/tests/unit/test_loader/test_fixtures_directory_loading.py b/tests/unit/test_loader/test_fixtures_directory_loading.py index c54b9c8d1..d97d35220 100644 --- a/tests/unit/test_loader/test_fixtures_directory_loading.py +++ b/tests/unit/test_loader/test_fixtures_directory_loading.py @@ -14,7 +14,7 @@ import pytest -from sqlspec.core.statement import SQL +from sqlspec.core import SQL from sqlspec.loader import SQLFileLoader try: diff --git a/tests/unit/test_loader/test_loading_patterns.py b/tests/unit/test_loader/test_loading_patterns.py index 1c10c292a..8896933c5 100644 --- a/tests/unit/test_loader/test_loading_patterns.py +++ b/tests/unit/test_loader/test_loading_patterns.py @@ -15,7 +15,7 @@ import pytest -from sqlspec.core.statement import SQL +from sqlspec.core import SQL from sqlspec.exceptions import SQLFileNotFoundError, SQLFileParseError from sqlspec.loader import SQLFileLoader diff --git a/tests/unit/test_loader/test_sql_file_loader.py b/tests/unit/test_loader/test_sql_file_loader.py index fbc399740..7de136c51 100644 --- a/tests/unit/test_loader/test_sql_file_loader.py +++ b/tests/unit/test_loader/test_sql_file_loader.py @@ -16,7 +16,7 @@ import pytest -from sqlspec.core.statement import SQL +from sqlspec.core import SQL from sqlspec.exceptions import SQLFileNotFoundError, SQLFileParseError from sqlspec.loader import CachedSQLFile, NamedStatement, SQLFile, SQLFileLoader @@ -945,7 +945,7 @@ def fixture_integration_path() -> Path: def test_load_and_execute_fixture_queries(fixture_integration_path: Path) -> None: """Test loading and creating SQL objects from fixture queries.""" - from sqlspec.core.statement import SQL + from sqlspec.core import SQL from sqlspec.loader import SQLFileLoader fixture_file = fixture_integration_path / "init.sql" @@ -983,7 +983,7 @@ def test_fixture_query_metadata_preservation(fixture_integration_path: Path) -> def test_fixture_parameter_extraction(fixture_integration_path: Path) -> None: """Test parameter extraction from fixture queries.""" - from sqlspec.core.statement import SQL + from sqlspec.core import SQL from sqlspec.loader import SQLFileLoader fixture_file = fixture_integration_path / "postgres" / "collection-database_details.sql" diff --git a/tests/unit/test_sql_factory.py b/tests/unit/test_sql_factory.py index 3afd379ff..475679971 100644 --- a/tests/unit/test_sql_factory.py +++ b/tests/unit/test_sql_factory.py @@ -7,7 +7,7 @@ from sqlspec import sql from sqlspec.builder import SQLFactory -from sqlspec.core.statement import SQL +from sqlspec.core import SQL from sqlspec.exceptions import SQLBuilderError pytestmark = pytest.mark.xdist_group("builder") diff --git a/tests/unit/test_type_conversion.py b/tests/unit/test_type_conversion.py index bb322878b..e70b9defd 100644 --- a/tests/unit/test_type_conversion.py +++ b/tests/unit/test_type_conversion.py @@ -10,7 +10,7 @@ import pytest -from sqlspec.core.type_conversion import ( +from sqlspec.core import ( BaseTypeConverter, convert_decimal, convert_iso_date,