@@ -212,7 +212,7 @@ def _setup_collection(self, *, collection: str) -> None:
212212 self ._collections_by_name [collection ] = self ._db [sanitized_collection ]
213213 return
214214
215- new_collection : Collection [dict [str , Any ]] = self ._db .create_collection (name = collection )
215+ new_collection : Collection [dict [str , Any ]] = self ._db .create_collection (name = sanitized_collection )
216216
217217 # Index for efficient key lookups
218218 _ = new_collection .create_index (keys = "key" )
@@ -224,9 +224,7 @@ def _setup_collection(self, *, collection: str) -> None:
224224
225225 @override
226226 def _get_managed_entry (self , * , key : str , collection : str ) -> ManagedEntry | None :
227- sanitized_collection = self ._sanitize_collection (collection = collection )
228-
229- if doc := self ._collections_by_name [sanitized_collection ].find_one (filter = {"key" : key }):
227+ if doc := self ._collections_by_name [collection ].find_one (filter = {"key" : key }):
230228 try :
231229 return self ._adapter .load_dict (data = doc )
232230 except DeserializationError :
@@ -239,10 +237,8 @@ def _get_managed_entries(self, *, collection: str, keys: Sequence[str]) -> list[
239237 if not keys :
240238 return []
241239
242- sanitized_collection = self ._sanitize_collection (collection = collection )
243-
244240 # Use find with $in operator to get multiple documents at once
245- cursor = self ._collections_by_name [sanitized_collection ].find (filter = {"key" : {"$in" : keys }})
241+ cursor = self ._collections_by_name [collection ].find (filter = {"key" : {"$in" : keys }})
246242
247243 managed_entries_by_key : dict [str , ManagedEntry | None ] = dict .fromkeys (keys )
248244
@@ -259,12 +255,10 @@ def _get_managed_entries(self, *, collection: str, keys: Sequence[str]) -> list[
259255 def _put_managed_entry (self , * , key : str , collection : str , managed_entry : ManagedEntry ) -> None :
260256 mongo_doc = self ._adapter .dump_dict (entry = managed_entry )
261257
262- sanitized_collection = self ._sanitize_collection (collection = collection )
263-
264258 try :
265259 # Ensure that the value is serializable to JSON
266260 _ = managed_entry .value_as_json
267- _ = self ._collections_by_name [sanitized_collection ].update_one (
261+ _ = self ._collections_by_name [collection ].update_one (
268262 filter = {"key" : key }, update = {"$set" : {"key" : key , ** mongo_doc }}, upsert = True
269263 )
270264 except InvalidDocument as e :
@@ -285,8 +279,6 @@ def _put_managed_entries(
285279 if not keys :
286280 return
287281
288- sanitized_collection = self ._sanitize_collection (collection = collection )
289-
290282 operations : list [UpdateOne ] = []
291283 for key , managed_entry in zip (keys , managed_entries , strict = True ):
292284 mongo_doc = self ._adapter .dump_dict (entry = managed_entry )
@@ -295,13 +287,11 @@ def _put_managed_entries(
295287 UpdateOne (filter = {"key" : key }, update = {"$set" : {"collection" : collection , "key" : key , ** mongo_doc }}, upsert = True )
296288 )
297289
298- _ = self ._collections_by_name [sanitized_collection ].bulk_write (operations ) # pyright: ignore[reportUnknownMemberType]
290+ _ = self ._collections_by_name [collection ].bulk_write (operations ) # pyright: ignore[reportUnknownMemberType]
299291
300292 @override
301293 def _delete_managed_entry (self , * , key : str , collection : str ) -> bool :
302- sanitized_collection = self ._sanitize_collection (collection = collection )
303-
304- result : DeleteResult = self ._collections_by_name [sanitized_collection ].delete_one (filter = {"key" : key })
294+ result : DeleteResult = self ._collections_by_name [collection ].delete_one (filter = {"key" : key })
305295 return bool (result .deleted_count )
306296
307297 @override
0 commit comments