uriyyo / fastapi-pagination

FastAPI pagination 📖
https://uriyyo-fastapi-pagination.netlify.app/
MIT License
1.21k stars 137 forks source link

_should_unwrap_scalars incorrectly returns True for CompoundSelect #1358

Closed fraser-langton closed 1 week ago

fraser-langton commented 1 week ago

When using a CompoundSelect (from a union) in fastapi_pagination.ext.sqlalchemy._should_unwrap_scalars returns True as query.column_descriptions raises AttributeError

This was a particularly nasty bug for me to troubleshoot because the shape of the data was different I thought I had written the query wrong, the model wrong, or something else.

As an immediate fix I would perhaps suggest checking query is of type Selectable then at least it would fail explicitly instead of defaulting to some behaviour that isn't clear? To at least stop someone else in future being as confused as me.

uriyyo commented 1 week ago

Hi @fraser-langton,

Thanks for such a well-described issue!

uriyyo commented 1 week ago

Hi @fraser-langton,

New version 0.12.32 has been released, this issue should be fixed now.

uriyyo commented 1 week ago

Hi @fraser-langton,

Can I close the issue? Is everything okay on your side?

fraser-langton commented 1 week ago

@uriyyo yep thanks!