# Path: simplesqlite/_func.py
# def validate_table_name(name: str) -> None:
#     """
#     :param str name: Table name to validate.
#     :raises NameValidationError: |raises_validate_table_name|
#     """
# 
#     try:
#         validate_sqlite_table_name(name)
#     except ValidationError as e:
#         if e.reason == ErrorReason.RESERVED_NAME and e.reusable_name:
#             pass
#         else:
#             raise NameValidationError(e)
# 
# Path: simplesqlite/_validator.py
# def validate_sqlite_attr_name(name: str) -> None:
#     """
#     :param str name: Name to validate.
#     :raises pathvalidate.ValidationError:
#         - If the ``name`` includes unprintable character(s).
#         - |raises_sqlite_keywords|
#     """
# 
#     if not name:
#         raise ValidationError(["null name"], reason=ErrorReason.NULL_NAME)
# 
#     if __RE_INVALID_CHARS.search(name):
#         raise ValidationError(["unprintable character found"], reason=ErrorReason.INVALID_CHARACTER)
# 
#     name = name.upper()
# 
#     if name in __SQLITE_INVALID_RESERVED_KEYWORDS_ATTR:
#         raise ValidationError(
#             [f"'{name}' is a reserved keyword by sqlite"],
#             reason=ErrorReason.RESERVED_NAME,
#             reusable_name=False,
#         )
# 
#     if name in __SQLITE_VALID_RESERVED_KEYWORDS_ATTR:
#         raise ValidationError(
#             [f"'{name}' is a reserved keyword by sqlite"],
#             reason=ErrorReason.RESERVED_NAME,
#             reusable_name=True,
#         )
# 
# Path: simplesqlite/error.py
# class SqlSyntaxError(Exception):
#     """
#     Exception raised when a SQLite query syntax is invalid.
#     """


import abc
import re
import typepy
    import hashlib
from typing import Any, List, Optional, Sequence, Union
from pathvalidate import ascii_symbols, unprintable_ascii_chars
from pathvalidate.error import ErrorReason, ValidationError
from ._func import validate_table_name
from ._validator import validate_sqlite_attr_name
from .error import SqlSyntaxError
        **b)** the ``value`` is |None| and the ``cmp_operator`` is not ``"="``/``"!="``.

    :Examples:
        >>> from simplesqlite.query import Where
        >>> Where("key", "hoge")
        "key = 'hoge'"
        >>> Where("value", 1, cmp_operator=">")
        'value > 1'
    """

    __VALID_CMP_OPERATORS = ("=", "==", "!=", "<>", ">", ">=", "<", "<=")

    @property
    def key(self) -> str:
        return self._value

    @property
    def value(self) -> str:
        return self.__rhs

    def __init__(self, key: str, value: Any, cmp_operator: str = "=") -> None:
        super().__init__(key)

        self.__rhs = value
        self.__cmp_operator = cmp_operator

        if not self.__cmp_operator:
            raise SqlSyntaxError("cmp_operator required")

        if self.__cmp_operator not in self.__VALID_CMP_OPERATORS:

# Path: simplesqlite/_func.py
# def validate_table_name(name: str) -> None:
#     """
#     :param str name: Table name to validate.
#     :raises NameValidationError: |raises_validate_table_name|
#     """
# 
#     try:
#         validate_sqlite_table_name(name)
#     except ValidationError as e:
#         if e.reason == ErrorReason.RESERVED_NAME and e.reusable_name:
#             pass
#         else:
#             raise NameValidationError(e)
# 
# Path: simplesqlite/_validator.py
# def validate_sqlite_attr_name(name: str) -> None:
#     """
#     :param str name: Name to validate.
#     :raises pathvalidate.ValidationError:
#         - If the ``name`` includes unprintable character(s).
#         - |raises_sqlite_keywords|
#     """
# 
#     if not name:
#         raise ValidationError(["null name"], reason=ErrorReason.NULL_NAME)
# 
#     if __RE_INVALID_CHARS.search(name):
#         raise ValidationError(["unprintable character found"], reason=ErrorReason.INVALID_CHARACTER)
# 
#     name = name.upper()
# 
#     if name in __SQLITE_INVALID_RESERVED_KEYWORDS_ATTR:
#         raise ValidationError(
#             [f"'{name}' is a reserved keyword by sqlite"],
#             reason=ErrorReason.RESERVED_NAME,
#             reusable_name=False,
#         )
# 
#     if name in __SQLITE_VALID_RESERVED_KEYWORDS_ATTR:
#         raise ValidationError(
#             [f"'{name}' is a reserved keyword by sqlite"],
#             reason=ErrorReason.RESERVED_NAME,
#             reusable_name=True,
#         )
# 
# Path: simplesqlite/error.py
# class SqlSyntaxError(Exception):
#     """
#     Exception raised when a SQLite query syntax is invalid.
#     """


# Path: simplesqlite/query.py
import abc
import re
import typepy
    import hashlib
from typing import Any, List, Optional, Sequence, Union
from pathvalidate import ascii_symbols, unprintable_ascii_chars
from pathvalidate.error import ErrorReason, ValidationError
from ._func import validate_table_name
from ._validator import validate_sqlite_attr_name
from .error import SqlSyntaxError

        **b)** the ``value`` is |None| and the ``cmp_operator`` is not ``"="``/``"!="``.

    :Examples:
        >>> from simplesqlite.query import Where
        >>> Where("key", "hoge")
        "key = 'hoge'"
        >>> Where("value", 1, cmp_operator=">")
        'value > 1'
    """

    __VALID_CMP_OPERATORS = ("=", "==", "!=", "<>", ">", ">=", "<", "<=")

    @property
    def key(self) -> str:
        return self._value

    @property
    def value(self) -> str:
        return self.__rhs

    def __init__(self, key: str, value: Any, cmp_operator: str = "=") -> None:
        super().__init__(key)

        self.__rhs = value
        self.__cmp_operator = cmp_operator

        if not self.__cmp_operator:
            raise SqlSyntaxError("cmp_operator required")

        if self.__cmp_operator not in self.__VALID_CMP_OPERATORS:

            raise SqlSyntaxError(f"operator not supported: {self.__cmp_operator}")