Skip to content

Commit c5bf9c6

Browse files
author
Sergio García Prado
committed
ISSUE #51
* Remove ordering constraint.
1 parent 4b23aa5 commit c5bf9c6

File tree

5 files changed

+11
-25
lines changed

5 files changed

+11
-25
lines changed

packages/core/minos-microservice-saga/minos/saga/executions/repositories/database/impl.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def __init__(self, *args, database_key: Optional[tuple[str]] = None, **kwargs):
3838

3939
async def _setup(self) -> None:
4040
await super()._setup()
41-
4241
operation = self.database_operation_factory.build_create()
4342
await self.execute_on_database(operation)
4443

packages/core/minos-microservice-saga/minos/saga/executions/saga.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def __init__(
8686
self.user = user
8787

8888
@classmethod
89-
def from_raw(cls, raw: Union[dict[str, Any], Iterable[Any], SagaExecution], **kwargs) -> SagaExecution:
89+
def from_raw(cls, raw: Union[dict[str, Any], SagaExecution], **kwargs) -> SagaExecution:
9090
"""Build a new instance from a raw representation.
9191
9292
:param raw: The raw representation of the instance.
@@ -96,20 +96,7 @@ def from_raw(cls, raw: Union[dict[str, Any], Iterable[Any], SagaExecution], **kw
9696
if isinstance(raw, cls):
9797
return raw
9898

99-
if isinstance(raw, dict):
100-
raw = raw.copy()
101-
else:
102-
keys = [
103-
"uuid",
104-
"definition",
105-
"status",
106-
"executed_steps",
107-
"paused_step",
108-
"context",
109-
"already_rollback",
110-
"user",
111-
]
112-
raw = dict(zip(keys, raw))
99+
raw = dict(raw)
113100

114101
current = raw | kwargs
115102
current["definition"] = Saga.from_raw(current["definition"])

packages/core/minos-microservice-saga/tests/test_saga/test_executions/test_saga/test_raw.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ def test_from_raw(self):
3535
observed = SagaExecution.from_raw(expected)
3636
self.assertEqual(expected, observed)
3737

38-
def test_from_raw_iterable(self):
39-
with patch.object(uuid, "uuid4", return_value=UUID("a74d9d6d-290a-492e-afcc-70607958f65d")):
40-
expected = SagaExecution.from_definition(ADD_ORDER, user=self.user)
41-
observed = SagaExecution.from_raw(expected.raw.values())
42-
self.assertEqual(expected, observed)
43-
4438
def test_from_raw_without_user(self):
4539
with patch.object(uuid, "uuid4", return_value=UUID("a74d9d6d-290a-492e-afcc-70607958f65d")):
4640
expected = SagaExecution.from_definition(ADD_ORDER)

packages/plugins/minos-database-aiopg/minos/plugins/aiopg/clients.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
OperationalError,
2828
ProgrammingError,
2929
)
30+
from psycopg2.extras import (
31+
DictCursor,
32+
)
3033

3134
from minos.common import (
3235
CircuitBreakerMixin,
@@ -180,7 +183,7 @@ async def _execute_cursor(self, operation: str, parameters: dict):
180183
if not await self.is_connected():
181184
await self.recreate()
182185

183-
self._cursor = await self._connection.cursor(timeout=self._cursor_timeout)
186+
self._cursor = await self._connection.cursor(timeout=self._cursor_timeout, cursor_factory=DictCursor)
184187
try:
185188
await self._cursor.execute(operation=operation, parameters=parameters)
186189
except OperationalError as exc:

packages/plugins/minos-database-aiopg/tests/test_aiopg/test_clients.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
OperationalError,
1616
ProgrammingError,
1717
)
18+
from psycopg2.extras import (
19+
DictRow,
20+
)
1821

1922
from minos.common import (
2023
ConnectionException,
@@ -171,7 +174,7 @@ async def test_fetch_one(self):
171174
async with AiopgDatabaseClient.from_config(self.config) as client:
172175
await client.execute(self.operation)
173176
observed = await client.fetch_one()
174-
self.assertIsInstance(observed, tuple)
177+
self.assertIsInstance(observed, DictRow)
175178

176179
async def test_fetch_one_raises_programming_empty(self):
177180
async with AiopgDatabaseClient.from_config(self.config) as client:
@@ -199,7 +202,7 @@ async def test_fetch_all(self):
199202

200203
self.assertGreater(len(observed), 0)
201204
for obs in observed:
202-
self.assertIsInstance(obs, tuple)
205+
self.assertIsInstance(obs, DictRow)
203206

204207

205208
if __name__ == "__main__":

0 commit comments

Comments
 (0)