crate / crate/sqlalchemy-cratedb
SQLAlchemy: Investigate `CompileError: Unconsumed column names`
- Dominant language
- Python
- Stars
- 9
- Forks
- 4
- Avg merge
- 6d 12h
- Merged PRs (30d)
- 3
Description
### Introduction
Within the CrateDB-specific statement compiler for SQLAlchemy, there is a patch to support CrateDB's container data types `OBJECT` and `ARRAY`. It is located at `CrateCompilerSA20.visit_update()`.
### About
Parts of the patch remove a sanity check of SQLAlchemy, but that is currently needed to make things work. It can easily reproduced like this.
```
./bin/test -t test_nested_object_change_tracking
```
```python
[...]
File "/path/to/sqlalchemy/sql/compiler.py", line 703, in __init__
self.string = self.process(self.statement, **compile_kwargs)
File "/path/to/sqlalchemy/sql/compiler.py", line 748, in process
return obj._compiler_dispatch(self, **kwargs)
File "/path/to/sqlalchemy/sql/visitors.py", line 143, in _compiler_dispatch
return meth(self, **kw) # type: ignore # noqa: E501
File "/path/to/crate-python/src/crate/client/sqlalchemy/compat/core20.py", line 97, in visit_update
crud_params_struct = _get_crud_params(
File "/path/to/crate-python/src/crate/client/sqlalchemy/compat/core20.py", line 405, in _get_crud_params
raise exc.CompileError(
sqlalchemy.exc.CompileError: Unconsumed column names: characters_name, data['nested']
```
### Discussion references
We've observed it, and talked about it before.
- https://github.com/crate/crate-python/pull/391#pullrequestreview-989026539
- https://github.com/crate/sqlalchemy-cratedb/issues/74
- https://github.com/crate/crate-python/pull/488#discussion_r1064326427
### Code references
The patch is the same for all support adapters.
https://github.com/crate/crate-python/blob/183a116afb62ee94717193303fb6dd7bb8821e58/src/crate/client/sqlalchemy/compat/core10.py#L223-L252
https://github.com/crate/crate-python/blob/183a116afb62ee94717193303fb6dd7bb8821e58/src/crate/client/sqlalchemy/compat/core14.py#L295-L324
https://github.com/crate/crate-python/blob/2ee91d52f6e07659c54337fe6bb08caf114e7469/src/crate/client/sqlalchemy/compat/core20.py#L392-L421
Contributor guide
Assessment
This issue has not been assessed yet.