Skip to content

3.10: Added computedValues #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions arango/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ def create_collection(
smart_join_attribute: Optional[str] = None,
write_concern: Optional[int] = None,
schema: Optional[Json] = None,
computedValues: Optional[Jsons] = None,
) -> Result[StandardCollection]:
"""Create a new collection.

Expand Down Expand Up @@ -1010,6 +1011,12 @@ def create_collection(
for documents. See ArangoDB documentation for more information on
document schema validation.
:type schema: dict
:param computedValues: Array of computed values for the new collection
enabling default values to new documents or the maintenance of
auxiliary attributes for search queries. Available in ArangoDB
version 3.10 or greater. See ArangoDB documentation for more
information on computed values.
:type computedValues: list
:return: Standard collection API wrapper.
:rtype: arango.collection.StandardCollection
:raise arango.exceptions.CollectionCreateError: If create fails.
Expand Down Expand Up @@ -1043,6 +1050,8 @@ def create_collection(
data["writeConcern"] = write_concern
if schema is not None:
data["schema"] = schema
if computedValues is not None:
data["computedValues"] = computedValues

params: Params = {}
if sync_replication is not None:
Expand Down
14 changes: 14 additions & 0 deletions arango/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,20 @@ def format_collection(body: Json) -> Json:
if "schema" in body:
result["schema"] = body["schema"]

# New in 3.10
if "computedValues" in body:
result["computedValues"] = [
{
"name": cv["name"],
"expression": cv["expression"],
"overwrite": cv["overwrite"],
"computedOn": cv["computedOn"],
"keepNull": cv["keepNull"],
"failOnWarning": cv["failOnWarning"],
}
for cv in body["computedValues"]
]

return verify_format(body, result)


Expand Down