Skip to content
Open
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
22 changes: 22 additions & 0 deletions test/collection/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Vectorizers,
_AsyncReplicationConfig,
_CollectionConfigCreate,
_CollectionConfigUpdate,
_GenerativeProvider,
_ReplicationConfig,
_ReplicationConfigUpdate,
Expand All @@ -30,6 +31,7 @@
VectorDistances,
)
from weaviate.collections.classes.config_vectors import _VectorConfigCreate
from weaviate.collections.classes.config_object_ttl import ObjectTTLConfigUpdate
from weaviate.exceptions import WeaviateInsertInvalidPropertyError

DEFAULTS = {
Expand Down Expand Up @@ -3529,3 +3531,23 @@ def test_reconfigure_inverted_index_without_stopword_presets_leaves_existing(sel
}
merged = rc.merge_with_existing(existing)
assert merged["stopwordPresets"] == {"fr": ["le", "la"]}


def test_object_ttl_update_uses_server_schema_key():
stored = {
"objectTtlConfig": {
"enabled": True,
"deleteOn": "expiresAt",
"defaultTtl": 3600,
"filterExpiredObjects": False,
}
}
update = _CollectionConfigUpdate(
object_ttl_config=ObjectTTLConfigUpdate(enabled=True, filterExpiredObjects=True)
)
merged = update.merge_with_existing(stored)

assert "objectTTLConfig" not in merged
assert merged["objectTtlConfig"]["filterExpiredObjects"] is True
assert merged["objectTtlConfig"]["defaultTtl"] == 3600
assert merged["objectTtlConfig"]["deleteOn"] == "expiresAt"
9 changes: 5 additions & 4 deletions weaviate/collections/classes/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,7 @@ class _CollectionConfigUpdate(_ConfigUpdateModel):
invertedIndexConfig: Optional[InvertedIndexConfigUpdate] = Field(
default=None, alias="inverted_index_config"
)
objectTTLConfig: Optional[ObjectTTLConfigUpdate] = Field(
objectTtlConfig: Optional[ObjectTTLConfigUpdate] = Field(
default=None, alias="object_ttl_config"
)
replicationConfig: Optional[ReplicationConfigUpdate] = Field(
Expand Down Expand Up @@ -1745,10 +1745,11 @@ def merge_with_existing(self, schema: Dict[str, Any]) -> Dict[str, Any]:
schema["multiTenancyConfig"] = self.multiTenancyConfig.merge_with_existing(
schema["multiTenancyConfig"]
)
if self.objectTTLConfig is not None:
schema["objectTTLConfig"] = self.objectTTLConfig.merge_with_existing(
schema.get("objectTTLConfig", {})
if self.objectTtlConfig is not None:
schema["objectTtlConfig"] = self.objectTtlConfig.merge_with_existing(
schema.get("objectTtlConfig") or schema.get("objectTTLConfig") or {}
)
schema.pop("objectTTLConfig", None)
if self.vectorIndexConfig is not None:
self.__check_quantizers(self.vectorIndexConfig.quantizer, schema["vectorIndexConfig"])
schema["vectorIndexConfig"] = self.vectorIndexConfig.merge_with_existing(
Expand Down
Loading