Metadata-Version: 2.4
Name: sqlrules-mysql
Version: 1.0.0
Summary: MySQL/MariaDB dialect plugin for SQLRules (REGEXP, JSON, full-text).
Project-URL: Homepage, https://github.com/eddiethedean/sqlrules
Project-URL: Repository, https://github.com/eddiethedean/sqlrules
Project-URL: Issues, https://github.com/eddiethedean/sqlrules/issues
Author: SQLRules Contributors
License-Expression: MIT
License-File: LICENSE
Keywords: mariadb,mysql,pydantic,sqlalchemy,sqlrules
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: sqlalchemy<3,>=2.0
Requires-Dist: sqlrules<2,>=1
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == 'dev'
Description-Content-Type: text/markdown

# sqlrules-mysql

MySQL / MariaDB dialect plugin for [SQLRules](https://github.com/eddiethedean/sqlrules).

## Install

```bash
pip install sqlrules-mysql
```

## Usage

```python
from typing import Annotated, Any

from pydantic import BaseModel, Field

from sqlrules import Compiler, FullTextMatch, JsonContains
from sqlrules_mysql import MysqlPlugin

class RowFilter(BaseModel):
    name: Annotated[str, Field(pattern=r"^A")]
    meta: Annotated[dict[str, Any], JsonContains({"active": True})]
    body: Annotated[str, FullTextMatch("sqlrules")]

compiler = Compiler(plugins=[MysqlPlugin()], dialect="mysql")
```

## Operators

| IR operator | Notes |
|---|---|
| `pattern` | `REGEXP` (case-insensitive under typical collations) |
| `type_check` | Shape/type predicates from `TypeSpec` (partial matrix) |
| `json_contains` | `JSON_CONTAINS(column, payload) = 1` |
| `json_has_key` | `JSON_CONTAINS_PATH(column, 'one', '$.key') = 1` |
| `fulltext_match` | `MATCH(column) AGAINST (value)` — requires a FULLTEXT index |

## Security note

`pattern` / `fulltext_match` values are bound parameters, but evaluation cost
is engine-dependent. Prefer static/allowlisted patterns and queries from
untrusted input. See
[SECURITY](https://sqlrules.readthedocs.io/en/latest/SECURITY.html).
