diff --git a/nitro_datastore/__init__.py b/nitro_datastore/__init__.py index 496ca7d..03a40fd 100644 --- a/nitro_datastore/__init__.py +++ b/nitro_datastore/__init__.py @@ -18,5 +18,5 @@ from nitro_datastore.datastore import NitroDataStore from nitro_datastore.query_builder import QueryBuilder -__version__ = "1.0.1" +__version__ = "1.0.2" __all__ = ["NitroDataStore", "QueryBuilder"] diff --git a/nitro_datastore/datastore.py b/nitro_datastore/datastore.py index 8632768..b1f9b18 100644 --- a/nitro_datastore/datastore.py +++ b/nitro_datastore/datastore.py @@ -1027,13 +1027,17 @@ def filter_list(self, path: str, predicate: Callable[[Any], bool]) -> List[Any]: return [] return [item for item in value if predicate(item)] + def _wrap_value(self, value: Any) -> Any: + """Wrap dicts in NitroDataStore, including dicts inside lists.""" + if isinstance(value, dict): + return NitroDataStore(value) + elif isinstance(value, list): + return [self._wrap_value(item) for item in value] + return value + def __getitem__(self, key: str) -> Any: """Dictionary-style access: data['key']""" - result = self._data[key] - # Wrap nested dicts in NitroDataStore for chained access - if isinstance(result, dict): - return NitroDataStore(result) - return result + return self._wrap_value(self._data[key]) def __setitem__(self, key: str, value: Any) -> None: """Dictionary-style assignment: data['key'] = value""" @@ -1052,17 +1056,12 @@ def __contains__(self, key: str) -> bool: def __getattr__(self, name: str) -> Any: """Dot notation access: data.key""" if name.startswith("_"): - # Allow access to private attributes raise AttributeError( f"'{type(self).__name__}' object has no attribute '{name}'" ) if name in self._data: - result = self._data[name] - # Wrap nested dicts in NitroDataStore for chained access - if isinstance(result, dict): - return NitroDataStore(result) - return result + return self._wrap_value(self._data[name]) raise AttributeError(f"'{type(self).__name__}' has no attribute '{name}'") diff --git a/pyproject.toml b/pyproject.toml index a8062b5..f2e8129 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "nitro-datastore" -version = "1.0.1" +version = "1.0.2" description = "Schema-agnostic JSON data store with dot notation, chainable queries, bulk operations, and built-in security features" readme = "README.md" authors = [