potiuk opened a new pull request, #77108:
URL: https://github.com/apache/airflow/pull/77108

   mysqlclient 2.3.1 binds only an exact `str` as a string and falls back to 
`str()` for any subclass. Airflow and the Task SDK bind `(str, Enum)` values 
straight to string columns, and the ones without a `__str__` are written by 
member name: the CI environment upgrade in #76884 fails ~430 MySQL tests with 
`Data too long for column 'state'`, from `UPDATE task_instance SET state` with 
the generated Task SDK `TaskInstanceState` (no `__str__`), and `Data too long 
for column 'type'` from `CallbackType`.
   
   The fix is at the connection: a `connect` handler on the `mysqldb` driver 
gives the connection an encoder map whose `__missing__` encodes any `str` 
subclass by its value. mysqlclient looks the encoder up with 
`PyObject_GetItem`, so the subclass is honoured; other types still reach the 
driver's own fallback, and on mysqlclient < 2.3.1 the map is never consulted 
for `str` subclasses.
   
   This is complementary to #76927, which gives four core enums a `__str__`: 
that does not cover the Task SDK's generated enums or any future one, which 
this does. Both can go in.
   
   The PR also updates a common.ai test for sqlglot 30.31 (also in #76884), 
which now parses `TABLE <name>` as `SELECT * FROM <name>` and so reports the 
table instead of flagging it; the guard stays for older sqlglot.
   
   Tested:
   - New unit tests for the encoder map.
   - In breeze on MySQL 8.0 with mysqlclient 2.3.1 installed: 
`test_task_command.py::TestCliTasks::test_test` and 
`test_backfills.py::TestGetBackfill` (failing in #76884) pass, with the new 
tests (6 passed).
   - `test_sql_validation.py` passes with sqlglot 30.29.0 and 30.31.0.
   
   related: #76884, #76927
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (Claude Opus 5)
   
   Generated-by: Claude Code (Claude Opus 5) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01NyQq9U7i5HhjDgrQ9qd3gq
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to