IndexError: tuple index out of range
0x1618 opened this issue · comments
Environment:
- Python version: 3.11.2
- Flask-SQLAlchemy version: 3.0.5
- SQLAlchemy version: 2.0.19
class Bans(db.Model):
__tablename__ = 'bans'
uuid = db.Column(db.String(36), primary_key=True)
reason = db.Column(db.String(255), nullable=False)
ip = db.Column(db.String(255), nullable=True)
user = db.Column(db.String(36), db.ForeignKey('users.uuid'))
expires = db.Column(db.Integer(), nullable=False)
Bans.query.filter_by(ip=ip).filter(Bans.expires > current_timestamp).first()
File "/******lib/python3.11/site-packages/sqlalchemy/orm/query.py", line 2747, in first
return self.limit(1)._iter().first() # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/******lib/python3.11/site-packages/sqlalchemy/engine/result.py", line 1803, in first
return self._only_one_row(
^^^^^^^^^^^^^^^^^^^
File "/******lib/python3.11/site-packages/sqlalchemy/engine/result.py", line 757, in _only_one_row
row: Optional[_InterimRowType[Any]] = onerow(hard_close=True)
^^^^^^^^^^^^^^^^^^^^^^^
File "/******lib/python3.11/site-packages/sqlalchemy/engine/result.py", line 1690, in _fetchone_impl
return self._real_result._fetchone_impl(hard_close=hard_close)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/******lib/python3.11/site-packages/sqlalchemy/engine/result.py", line 2282, in _fetchone_impl
row = next(self.iterator, _NO_ROW)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/******lib/python3.11/site-packages/sqlalchemy/orm/loading.py", line 195, in chunks
rows = [proc(row) for row in fetch]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/******lib/python3.11/site-packages/sqlalchemy/orm/loading.py", line 195, in <listcomp>
rows = [proc(row) for row in fetch]
^^^^^^^^^
File "/******lib/python3.11/site-packages/sqlalchemy/orm/loading.py", line 1101, in _instance
_populate_full(
File "/******lib/python3.11/site-packages/sqlalchemy/orm/loading.py", line 1288, in _populate_full
dict_[key] = getter(row)
^^^^^^^^^^^
File "lib/sqlalchemy/cyextension/resultproxy.pyx", line 48, in sqlalchemy.cyextension.resultproxy.BaseRow.__getitem__
IndexError: tuple index out of range
It happens randomly.
This error is entirely in SQLAlchemy, the traceback does not mention Flask-SQLAlchemy.