Skip to content

Conversation

@sawaca96
Copy link
Owner

No description provided.

Comment on lines +34 to +41
# async sqlalchemy doesn't support relationship
# It raise 'greenlet_spawn has not been called; can't call await_() here. Was IO attempted in an unexpected place?' # noqa E501
result = await self._session.execute(
sa.select(models.Batch)
.where(models.Batch.id == id)
.options(selectinload(models.Batch.allocations))
)
return result.scalar_one()
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async sqlalchemy에서 mapping한 객체의 relationship fetch을 지원하지 않아서 execute로 수정했습니다.

self.eta = eta
self.purchased_quantity = qty
self.allocations: set[OrderLine] = set()
id: UUID = field(default_factory=uuid4)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default_factory를 사용하기 위해서 dataclass로 변경했습니다.

모델은 kw_only를 사용하도록 했습니다.

@sawaca96 sawaca96 merged commit aea2c72 into main Jan 23, 2023
@sawaca96 sawaca96 deleted the ch06 branch January 23, 2023 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants