deev 1.2.0__tar.gz → 1.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {deev-1.2.0/src/deev.egg-info → deev-1.2.2}/PKG-INFO +1 -1
- {deev-1.2.0 → deev-1.2.2}/pyproject.toml +1 -1
- {deev-1.2.0 → deev-1.2.2}/src/deev/__init__.py +2 -2
- {deev-1.2.0 → deev-1.2.2}/src/deev/mongodb/MongoTableAdapter.py +27 -8
- {deev-1.2.0 → deev-1.2.2}/src/deev/utils.py +1 -1
- {deev-1.2.0 → deev-1.2.2/src/deev.egg-info}/PKG-INFO +1 -1
- {deev-1.2.0 → deev-1.2.2}/LICENSE +0 -0
- {deev-1.2.0 → deev-1.2.2}/README.md +0 -0
- {deev-1.2.0 → deev-1.2.2}/setup.cfg +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/_ImmutableMixin.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/_MigrationData.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/common/ConnectionString.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/common/DbConnection.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/common/DbContext.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/common/DbCursor.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/common/DbError.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/common/DbMigrator.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/common/DbParams.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/common/DbTableAdapter.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/common/DbTransactionContext.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/common/DbTypeMapper.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/common/__init__.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/db_migrate.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/entities.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/mongodb/MongoProxyConnection.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/mongodb/MongoProxyCursor.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/mongodb/MongoTransactionContext.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/mongodb/MongoTypeMapper.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/mongodb/__init__.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/mysql/MysqlProxyConnection.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/mysql/MysqlProxyCursor.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/mysql/MysqlTableAdapter.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/mysql/MysqlTransactionContext.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/mysql/MysqlTypeMapper.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/mysql/__init__.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/py.typed +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/sqlite/SqliteProxyConnection.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/sqlite/SqliteProxyCursor.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/sqlite/SqliteTableAdapter.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/sqlite/SqliteTransactionContext.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/sqlite/SqliteTypeMapper.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/sqlite/__init__.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/translation.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev/validation.py +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev.egg-info/SOURCES.txt +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev.egg-info/dependency_links.txt +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev.egg-info/entry_points.txt +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev.egg-info/requires.txt +0 -0
- {deev-1.2.0 → deev-1.2.2}/src/deev.egg-info/top_level.txt +0 -0
|
@@ -11,8 +11,8 @@ from .utils import connect
|
|
|
11
11
|
from . import common, entities, mongodb, mysql, translation, utils, validation
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
__version__ = '1.2.
|
|
15
|
-
__commit__ = '
|
|
14
|
+
__version__ = '1.2.2'
|
|
15
|
+
__commit__ = '96178a5'
|
|
16
16
|
__all__ = [
|
|
17
17
|
'__version__', '__commit__',
|
|
18
18
|
'ConnectionString',
|
|
@@ -87,14 +87,14 @@ class MongoTableAdapter(Generic[TEntity]):
|
|
|
87
87
|
"""Return the table/collection name (from explicit override or entity spec)."""
|
|
88
88
|
return self.__table_name if self.__table_name is not None else self.__entity_spec.table_name
|
|
89
89
|
|
|
90
|
-
def __get_database(self):
|
|
90
|
+
def __get_database(self) -> pymongo.database.Database[Any]:
|
|
91
91
|
"""Return the pymongo database from the cursor's session."""
|
|
92
92
|
mongo_session = getattr(self.__context.cursor(), 'mongo_session', None) # type: ignore[union-attr]
|
|
93
93
|
if mongo_session is None:
|
|
94
94
|
raise DbError('Cursor does not have a mongo_session attribute.')
|
|
95
95
|
return mongo_session._client[self.__database_name] # type: ignore[attr-defined]
|
|
96
96
|
|
|
97
|
-
def _get_collection(self) -> pymongo.collection.Collection:
|
|
97
|
+
def _get_collection(self) -> pymongo.collection.Collection[Any]:
|
|
98
98
|
"""Get the MongoDB collection for this adapter."""
|
|
99
99
|
db = self.__get_database()
|
|
100
100
|
return db[self.__get_collection_name()]
|
|
@@ -103,12 +103,31 @@ class MongoTableAdapter(Generic[TEntity]):
|
|
|
103
103
|
"""Utility method for creating the target table."""
|
|
104
104
|
self.__deferred_init()
|
|
105
105
|
collection_name = self.__get_collection_name()
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
connection = cast(pymongo.MongoClient[Any], getattr(self.__context, 'mongo_connection', None))
|
|
107
|
+
db = connection.get_database(self.__database_name)
|
|
108
|
+
mongo_session = getattr(self.__context.cursor(), 'mongo_session', None)
|
|
109
|
+
if collection_name not in db.list_collection_names():
|
|
110
|
+
collection: pymongo.collection.Collection[Any]
|
|
111
|
+
if len(self.primary_key) > 0:
|
|
112
|
+
collection = db[collection_name]
|
|
113
|
+
else:
|
|
114
|
+
collection = db.create_collection(
|
|
115
|
+
name=collection_name,
|
|
116
|
+
session=mongo_session,
|
|
117
|
+
check_exists=True
|
|
118
|
+
# TODO: implement validation as much as is possible between entity spec and mongodb
|
|
119
|
+
# validator=
|
|
120
|
+
# validationLevel=
|
|
121
|
+
# validationAction=
|
|
122
|
+
)
|
|
123
|
+
collection.create_index(
|
|
124
|
+
{
|
|
125
|
+
k: 1
|
|
126
|
+
for k in self.primary_key
|
|
127
|
+
},
|
|
128
|
+
session=mongo_session,
|
|
129
|
+
unique=True
|
|
130
|
+
)
|
|
112
131
|
|
|
113
132
|
def commit(self) -> None:
|
|
114
133
|
self.__context.commit()
|
|
@@ -26,7 +26,7 @@ def connect(connectionstring: ConnectionString | str) -> DbConnection:
|
|
|
26
26
|
import pymongo
|
|
27
27
|
if connectionstring.database is None:
|
|
28
28
|
raise DbError(f'ConnectionString is missing `database` component: {connectionstring}')
|
|
29
|
-
mongo_uri = f'mongodb://{connectionstring.user}:{connectionstring.password}@{connectionstring.server}'
|
|
29
|
+
mongo_uri = f'mongodb://{connectionstring.user}:{connectionstring.password}@{connectionstring.server}/{connectionstring.database}'
|
|
30
30
|
return MongoProxyConnection(
|
|
31
31
|
pymongo.MongoClient(mongo_uri),
|
|
32
32
|
database_name=connectionstring.database
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|