diff --git a/test/collection/test_config.py b/test/collection/test_config.py index 360a0d138..fa02a918e 100644 --- a/test/collection/test_config.py +++ b/test/collection/test_config.py @@ -14,6 +14,7 @@ Vectorizers, _AsyncReplicationConfig, _CollectionConfigCreate, + _CollectionConfigUpdate, _GenerativeProvider, _ReplicationConfig, _ReplicationConfigUpdate, @@ -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 = { @@ -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" diff --git a/weaviate/collections/classes/config.py b/weaviate/collections/classes/config.py index 390578756..7b088ae72 100644 --- a/weaviate/collections/classes/config.py +++ b/weaviate/collections/classes/config.py @@ -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( @@ -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(