Skip to content

Commit 26e3008

Browse files
authored
fix: Rename precondition. (#112)
1 parent a6fdcec commit 26e3008

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,19 @@ written_events = await client.write_events(
105105

106106
*Note that according to the CloudEvents standard, event IDs must be of type string.*
107107

108-
#### Using the `isEventQlTrue` precondition
108+
#### Using the `isEventQlQueryTrue` precondition
109109

110-
If you want to write events depending on an EventQL query, import the `IsEventQlTrue` class and pass it as a list of preconditions in the second argument:
110+
If you want to write events depending on an EventQL query, import the `IsEventQlQueryTrue` class and pass it as a list of preconditions in the second argument:
111111

112112
```python
113-
from eventsourcingdb import IsEventQlTrue
113+
from eventsourcingdb import IsEventQlQueryTrue
114114

115115
written_events = await client.write_events(
116116
events = [
117117
# events
118118
],
119119
preconditions = [
120-
IsEventQlTrue('FROM e IN events WHERE e.type == "io.eventsourcingdb.library.book-borrowed" PROJECT INTO COUNT() < 10')
120+
IsEventQlQueryTrue('FROM e IN events WHERE e.type == "io.eventsourcingdb.library.book-borrowed" PROJECT INTO COUNT() < 10')
121121
],
122122
)
123123
```

eventsourcingdb/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
)
1111
from .read_event_types import EventType
1212
from .read_events import IfEventIsMissingDuringRead, Order, ReadEventsOptions, ReadFromLatestEvent
13-
from .write_events import IsEventQlTrue, IsSubjectOnEventId, IsSubjectPristine, Precondition
13+
from .write_events import IsEventQlQueryTrue, IsSubjectOnEventId, IsSubjectPristine, Precondition
1414

1515
__all__ = [
1616
"Bound",
@@ -25,7 +25,7 @@
2525
"IfEventIsMissingDuringObserve",
2626
"IfEventIsMissingDuringRead",
2727
"InternalError",
28-
"IsEventQlTrue",
28+
"IsEventQlQueryTrue",
2929
"IsSubjectOnEventId",
3030
"IsSubjectPristine",
3131
"ObserveEventsOptions",

eventsourcingdb/write_events/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from .preconditions import IsEventQlTrue, IsSubjectOnEventId, IsSubjectPristine, Precondition
1+
from .preconditions import IsEventQlQueryTrue, IsSubjectOnEventId, IsSubjectPristine, Precondition
22

33
__all__ = [
4-
"IsEventQlTrue",
4+
"IsEventQlQueryTrue",
55
"IsSubjectOnEventId",
66
"IsSubjectPristine",
77
"Precondition",

eventsourcingdb/write_events/preconditions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ def to_json(self) -> dict[str, Any]:
2929
}
3030

3131
@dataclass
32-
class IsEventQlTrue(Precondition):
32+
class IsEventQlQueryTrue(Precondition):
3333
query: str
3434

3535
def to_json(self) -> dict[str, Any]:
3636
return {
37-
'type': 'isEventQlTrue',
37+
'type': 'isEventQlQueryTrue',
3838
'payload': {
3939
'query': self.query
4040
}

tests/test_write_events.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from aiohttp import ClientConnectorDNSError
33

4-
from eventsourcingdb import EventCandidate, IsEventQlTrue, IsSubjectOnEventId, IsSubjectPristine, ServerError
4+
from eventsourcingdb import EventCandidate, IsEventQlQueryTrue, IsSubjectOnEventId, IsSubjectPristine, ServerError
55

66
from .conftest import TestData
77
from .shared.database import Database
@@ -206,7 +206,7 @@ async def test_is_event_ql_true_precondition_works(
206206
source=test_data.TEST_SOURCE_STRING, subject="/", type="com.foo.bar", data={}
207207
)
208208
],
209-
[IsEventQlTrue("FROM e IN events PROJECT INTO COUNT() > 0")]
209+
[IsEventQlQueryTrue("FROM e IN events PROJECT INTO COUNT() > 0")]
210210
)
211211

212212
@staticmethod
@@ -235,7 +235,7 @@ async def test_is_event_ql_true_precondition_fails(
235235
data={},
236236
)
237237
],
238-
[IsEventQlTrue("FROM e IN events PROJECT INTO COUNT() == 0")]
238+
[IsEventQlQueryTrue("FROM e IN events PROJECT INTO COUNT() == 0")]
239239
)
240240

241241
@staticmethod

0 commit comments

Comments
 (0)