-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disallow multiple identity fields in aggregates
Protean can only work with a single identity field for now. It is not clear if composite keys are good from a DDD perspective.
- Loading branch information
Showing
5 changed files
with
57 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import pytest | ||
|
||
from protean.exceptions import NotSupportedError | ||
from protean.fields import String | ||
|
||
|
||
def test_exception_on_multiple_identifiers(test_domain): | ||
with pytest.raises(NotSupportedError) as exc: | ||
|
||
@test_domain.event_sourced_aggregate | ||
class Person: | ||
email = String(identifier=True) | ||
username = String(identifier=True) | ||
|
||
assert "Only one identifier field is allowed" in exc.value.args[0]["_entity"][0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters