Skip to content

Commit 8473ca4

Browse files
committed
Fix
1 parent 345af00 commit 8473ca4

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

poetry.lock

+17-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ toml = "^0.10.2"
4040
aiopg = { version = "^1.4.0", optional = true }
4141
databases = { version = "^0.9.0", optional = true }
4242
asyncpg = { version = "^0.29.0", optional = true }
43+
sqlparse = { version = "^0.5.1", optional = true }
4344

4445
[tool.poetry.group.dev.dependencies]
4546
black = "^24.4.2"
@@ -52,7 +53,7 @@ pytest-cov = "^5.0.0"
5253
pytest-asyncio = "^0.23.6"
5354

5455
[tool.poetry.extras]
55-
postgres = ["aiopg", "databases", "asyncpg"]
56+
postgres = ["aiopg", "databases", "asyncpg", "sqlparse"]
5657

5758

5859
[tool.isort]

src/flux/builtins/postgres.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from dataclasses import dataclass, field
44

55
try:
6+
import sqlparse
67
from databases import Database
78
from databases.core import Connection, Transaction
89
except ImportError as e:
@@ -193,7 +194,9 @@ async def apply_migration(self, content: str):
193194
up and down migrations so should not register or unregister the
194195
migration hash.
195196
"""
196-
await self._conn.execute(content)
197+
statements = sqlparse.split(content)
198+
for statement in statements:
199+
await self._conn.execute(statement.strip())
197200

198201
async def get_applied_migrations(self) -> set[AppliedMigration]:
199202
"""

0 commit comments

Comments
 (0)