Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "queryme"
version = "0.2.1"
version = "0.2.2"
description = "Shared query toolkit for the Zablab platform — descriptor schema, validator, compiler. Consumed by every DB-bearing microservice."
requires-python = ">=3.11"
dependencies = [
Expand Down
2 changes: 1 addition & 1 deletion src/queryme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@
"validate_against_schema",
]

__version__ = "0.2.1"
__version__ = "0.2.2"
18 changes: 14 additions & 4 deletions src/queryme/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from __future__ import annotations

from collections.abc import Callable
from typing import Any, cast

from sqlalchemy import (
Expand Down Expand Up @@ -68,14 +69,23 @@ def __init__(self, issues: list[ValidationIssue]) -> None:
# Type mapping (closed set per schema.ColumnType)
# ---------------------------------------------------------------------------


_TYPE_MAP: dict[ColumnType, type[TypeEngine[Any]]] = {
# Factories rather than raw classes so we can pass constructor flags
# where needed. ``Uuid(as_uuid=False)`` makes the synthetic column
# accept and emit string UUIDs, which is what JSON callers send and
# what HTTP responses serialise to anyway — saves every service from
# coercing both sides. Result rows for the underlying real PG column
# (declared as ``Uuid(as_uuid=True)`` in the service's models) flow
# through the same way because the synthetic column type only
# influences bind/result processing on the synthetic ``Table``, not
# the actual DB-side column.
_TypeFactory = Callable[[], TypeEngine[Any]]
_TYPE_FACTORIES: dict[ColumnType, _TypeFactory] = {
"string": String,
"text": Text,
"integer": Integer,
"float": Float,
"boolean": Boolean,
"uuid": Uuid,
"uuid": lambda: Uuid(as_uuid=False),
"datetime": DateTime,
"date": Date,
"json": JSON,
Expand Down Expand Up @@ -181,7 +191,7 @@ def _build_table(metadata: MetaData, table_def: TableDef) -> Table:
because joins are explicit in the descriptor."""
cols: list[Column[Any]] = []
for c in table_def.columns:
sa_type = _TYPE_MAP[c.type]()
sa_type = _TYPE_FACTORIES[c.type]()
cols.append(
Column(c.name, sa_type, nullable=c.nullable, primary_key=c.primary)
)
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading