Coverage for src / lexigram / contracts / data / sql / sql.py: 12%
17 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-19 05:41 +0800
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-19 05:41 +0800
1"""SQL identifier exceptions.
3This module contains only exception types for SQL identifier handling.
4The concrete identifier implementations have been moved to lexigram-sql.
5"""
7from __future__ import annotations
9from typing import Any
11from lexigram.contracts.exceptions.domain import ValidationError
14class InvalidIdentifierError(ValidationError):
15 """Raised when an SQL identifier fails validation.
17 Attributes:
18 identifier: The offending identifier string.
19 """
21 _code = "LEX_ERR_DB_010"
23 def __init__(
24 self, message: str, identifier: str | None = None, **kwargs: Any
25 ) -> None:
26 super().__init__(
27 message=message,
28 details={"identifier": identifier},
29 **kwargs,
30 )
31 self.identifier = identifier
34# Placeholder for RawSQL type that may be used elsewhere
35class RawSQL:
36 """Raw SQL string that bypasses validation.
38 This is a marker type for SQL that should not be validated or quoted.
40 Warning:
41 Never pass user-supplied values directly into this query string.
42 Always use parameterized queries or the provided binding mechanisms
43 to prevent SQL injection vulnerabilities.
45 Attributes:
46 sql: The raw SQL string.
47 """
49 __slots__ = ("_sql",)
51 def __init__(self, sql: str) -> None:
52 self._sql = sql
54 def __str__(self) -> str:
55 return self._sql
57 def __repr__(self) -> str:
58 return f"RawSQL({self._sql!r})"
61__all__ = [
62 "InvalidIdentifierError",
63 "RawSQL",
64]