error when inserting multiple rows
- Langage dominant
- Python
- Étoiles
- 1.4k
- Forks
- 170
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
This was the error I was getting when I posted #250, however that issue is about something else so I thought preferable to create a new issue.
I'm getting the exception below **sometimes** when running insert with multiple values.
What's odd is I don't seem to always get it but I can't work out what's correlating with the exception happening. I never get it with single value inserts.
```
cur = await conn.execute(sa_subjects.insert().values(values))
File "/home/samuel/code/socket-server/env/lib/python3.6/site-packages/aiopg/utils.py", line 72, in __await__
resp = yield from self._coro
File "/home/samuel/code/socket-server/env/lib/python3.6/site-packages/aiopg/sa/connection.py", line 88, in _execute
compiled_parameters = [compiled.construct_params(dp)]
File "/home/samuel/code/socket-server/env/lib/python3.6/site-packages/aiopg/sa/engine.py", line 25, in construct_params
pd[column.key] = self._exec_default(column.default)
File "/home/samuel/code/socket-server/env/lib/python3.6/site-packages/aiopg/sa/engine.py", line 35, in _exec_default
return default.arg
AttributeError: 'Sequence' object has no attribute 'arg'
```
If I print `default` I get:
```python
Sequence('subject_id_seq', metadata=MetaData(bind=None))
```
This appears to be the sequence object I created on the primary key field of the table.
`Sequence` doesn't have an `arg` field, it looks like `_exec_default` is expecting a `ColumnDefault` not Sequence, I can't work out why it's receiving a `Sequence` not `ColumnDefault` sometimes.
The table is very simple, just
```python
class Subject(Base):
__tablename__ = 'subjects'
id = Column(Integer, Sequence('subject_id_seq'), primary_key=True, nullable=False)
name = Column(String(63), nullable=False, index=True)
category = Column(String(63), nullable=False, index=True)
__table_args__ = (
UniqueConstraint('name', 'category', name='_subject_name_cat'),
)
sa_subjects = Subject.__table__
```
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.