TypeDAL 3.6.0__tar.gz → 3.7.0__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.
Potentially problematic release.
This version of TypeDAL might be problematic. Click here for more details.
- {typedal-3.6.0 → typedal-3.7.0}/.gitignore +1 -0
- {typedal-3.6.0 → typedal-3.7.0}/CHANGELOG.md +6 -0
- {typedal-3.6.0 → typedal-3.7.0}/PKG-INFO +23 -1
- {typedal-3.6.0 → typedal-3.7.0}/README.md +22 -0
- {typedal-3.6.0 → typedal-3.7.0}/src/typedal/__about__.py +1 -1
- {typedal-3.6.0 → typedal-3.7.0}/src/typedal/helpers.py +30 -1
- {typedal-3.6.0 → typedal-3.7.0}/tests/test_helpers.py +32 -1
- typedal-3.6.0/htmlcov/.gitignore +0 -2
- typedal-3.6.0/htmlcov/class_index.html +0 -563
- typedal-3.6.0/htmlcov/coverage_html.js +0 -624
- typedal-3.6.0/htmlcov/coverage_html_cb_da166b87.js +0 -717
- typedal-3.6.0/htmlcov/d_0ccc93afd6526b6c___about___py.html +0 -105
- typedal-3.6.0/htmlcov/d_0ccc93afd6526b6c___init___py.html +0 -110
- typedal-3.6.0/htmlcov/d_0ccc93afd6526b6c_caching_py.html +0 -504
- typedal-3.6.0/htmlcov/d_0ccc93afd6526b6c_cli_py.html +0 -683
- typedal-3.6.0/htmlcov/d_0ccc93afd6526b6c_config_py.html +0 -457
- typedal-3.6.0/htmlcov/d_0ccc93afd6526b6c_core_py.html +0 -2905
- typedal-3.6.0/htmlcov/d_0ccc93afd6526b6c_fields_py.html +0 -339
- typedal-3.6.0/htmlcov/d_0ccc93afd6526b6c_for_py4web_py.html +0 -154
- typedal-3.6.0/htmlcov/d_0ccc93afd6526b6c_for_web2py_py.html +0 -169
- typedal-3.6.0/htmlcov/d_0ccc93afd6526b6c_helpers_py.html +0 -364
- typedal-3.6.0/htmlcov/d_0ccc93afd6526b6c_mixins_py.html +0 -269
- typedal-3.6.0/htmlcov/d_0ccc93afd6526b6c_types_py.html +0 -325
- typedal-3.6.0/htmlcov/d_0ccc93afd6526b6c_web2py_py4web_shared_py.html +0 -141
- typedal-3.6.0/htmlcov/d_18c616467159315a_as_json_py.html +0 -172
- typedal-3.6.0/htmlcov/favicon_32.png +0 -0
- typedal-3.6.0/htmlcov/favicon_32_cb_58284776.png +0 -0
- typedal-3.6.0/htmlcov/function_index.html +0 -2571
- typedal-3.6.0/htmlcov/index.html +0 -202
- typedal-3.6.0/htmlcov/keybd_closed.png +0 -0
- typedal-3.6.0/htmlcov/keybd_closed_cb_ce680311.png +0 -0
- typedal-3.6.0/htmlcov/keybd_open.png +0 -0
- typedal-3.6.0/htmlcov/status.json +0 -1
- typedal-3.6.0/htmlcov/style.css +0 -309
- typedal-3.6.0/htmlcov/style_cb_8e611ae1.css +0 -337
- typedal-3.6.0/htmlcov/z_0ccc93afd6526b6c___about___py.html +0 -105
- typedal-3.6.0/htmlcov/z_0ccc93afd6526b6c___init___py.html +0 -110
- typedal-3.6.0/htmlcov/z_0ccc93afd6526b6c_caching_py.html +0 -504
- typedal-3.6.0/htmlcov/z_0ccc93afd6526b6c_cli_py.html +0 -715
- typedal-3.6.0/htmlcov/z_0ccc93afd6526b6c_config_py.html +0 -457
- typedal-3.6.0/htmlcov/z_0ccc93afd6526b6c_core_py.html +0 -2971
- typedal-3.6.0/htmlcov/z_0ccc93afd6526b6c_fields_py.html +0 -339
- typedal-3.6.0/htmlcov/z_0ccc93afd6526b6c_for_py4web_py.html +0 -154
- typedal-3.6.0/htmlcov/z_0ccc93afd6526b6c_for_web2py_py.html +0 -169
- typedal-3.6.0/htmlcov/z_0ccc93afd6526b6c_helpers_py.html +0 -373
- typedal-3.6.0/htmlcov/z_0ccc93afd6526b6c_mixins_py.html +0 -269
- typedal-3.6.0/htmlcov/z_0ccc93afd6526b6c_types_py.html +0 -349
- typedal-3.6.0/htmlcov/z_0ccc93afd6526b6c_web2py_py4web_shared_py.html +0 -141
- typedal-3.6.0/htmlcov/z_18c616467159315a_as_json_py.html +0 -172
- {typedal-3.6.0 → typedal-3.7.0}/.github/workflows/su6.yml +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/.readthedocs.yml +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/coverage.svg +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/docs/1_getting_started.md +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/docs/2_defining_tables.md +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/docs/3_building_queries.md +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/docs/4_relationships.md +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/docs/5_py4web.md +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/docs/6_migrations.md +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/docs/7_mixins.md +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/docs/css/code_blocks.css +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/docs/index.md +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/docs/requirements.txt +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/example_new.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/example_old.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/mkdocs.yml +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/pyproject.toml +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/src/typedal/__init__.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/src/typedal/caching.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/src/typedal/cli.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/src/typedal/config.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/src/typedal/core.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/src/typedal/fields.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/src/typedal/for_py4web.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/src/typedal/for_web2py.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/src/typedal/mixins.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/src/typedal/py.typed +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/src/typedal/serializers/as_json.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/src/typedal/types.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/src/typedal/web2py_py4web_shared.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/__init__.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/configs/simple.toml +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/configs/valid.env +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/configs/valid.toml +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/test_cli.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/test_config.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/test_docs_examples.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/test_json.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/test_main.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/test_mixins.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/test_mypy.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/test_orm.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/test_py4web.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/test_query_builder.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/test_relationships.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/test_row.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/test_stats.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/test_table.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/test_web2py.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/test_xx_others.py +0 -0
- {typedal-3.6.0 → typedal-3.7.0}/tests/timings.py +0 -0
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
<!--next-version-placeholder-->
|
|
4
4
|
|
|
5
|
+
## v3.7.0 (2024-08-17)
|
|
6
|
+
|
|
7
|
+
### Feature
|
|
8
|
+
|
|
9
|
+
* Add get_db, get_table, get_field helpers to get pydal objects back from typedal ([`2363e9d`](https://github.com/trialandsuccess/TypeDAL/commit/2363e9d3f15eb4500a0d5bc8354bf0326161bd1e))
|
|
10
|
+
|
|
5
11
|
## v3.6.0 (2024-08-05)
|
|
6
12
|
|
|
7
13
|
### Feature
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: TypeDAL
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.7.0
|
|
4
4
|
Summary: Typing support for PyDAL
|
|
5
5
|
Project-URL: Documentation, https://typedal.readthedocs.io/
|
|
6
6
|
Project-URL: Issues, https://github.com/trialandsuccess/TypeDAL/issues
|
|
@@ -301,6 +301,28 @@ row: TableName = db.table_name(id=1)
|
|
|
301
301
|
|
|
302
302
|
See [2. Defining Tables](https://typedal.readthedocs.io/en/stable/2_defining_tables/)
|
|
303
303
|
|
|
304
|
+
### Helpers
|
|
305
|
+
|
|
306
|
+
TypeDAL provides some utility functions to interact with the underlying pyDAL objects:
|
|
307
|
+
|
|
308
|
+
- **`get_db(TableName)`**:
|
|
309
|
+
Retrieve the DAL instance associated with a given TypedTable or pyDAL Table.
|
|
310
|
+
|
|
311
|
+
- **`get_table(TableName)`**:
|
|
312
|
+
Access the original PyDAL Table from a TypedTable instance (`db.table_name`).
|
|
313
|
+
|
|
314
|
+
- **`get_field(TableName.fieldname)`**:
|
|
315
|
+
Get the pyDAL Field from a TypedField. This ensures compatibility when interacting directly with PyDAL.
|
|
316
|
+
|
|
317
|
+
These helpers are useful for scenarios where direct access to the PyDAL objects is needed while still using TypeDAL.
|
|
318
|
+
An example of this is when you need to do a `db.commit()` but you can't import `db` directly:
|
|
319
|
+
|
|
320
|
+
```python
|
|
321
|
+
MyTable.insert(...)
|
|
322
|
+
db = get_db(MyTable)
|
|
323
|
+
db.commit() # this is usually done automatically but sometimes you want to manually commit.
|
|
324
|
+
```
|
|
325
|
+
|
|
304
326
|
## Caveats
|
|
305
327
|
|
|
306
328
|
- This package depends heavily on the current implementation of annotations (which are computed when the class is
|
|
@@ -247,6 +247,28 @@ row: TableName = db.table_name(id=1)
|
|
|
247
247
|
|
|
248
248
|
See [2. Defining Tables](https://typedal.readthedocs.io/en/stable/2_defining_tables/)
|
|
249
249
|
|
|
250
|
+
### Helpers
|
|
251
|
+
|
|
252
|
+
TypeDAL provides some utility functions to interact with the underlying pyDAL objects:
|
|
253
|
+
|
|
254
|
+
- **`get_db(TableName)`**:
|
|
255
|
+
Retrieve the DAL instance associated with a given TypedTable or pyDAL Table.
|
|
256
|
+
|
|
257
|
+
- **`get_table(TableName)`**:
|
|
258
|
+
Access the original PyDAL Table from a TypedTable instance (`db.table_name`).
|
|
259
|
+
|
|
260
|
+
- **`get_field(TableName.fieldname)`**:
|
|
261
|
+
Get the pyDAL Field from a TypedField. This ensures compatibility when interacting directly with PyDAL.
|
|
262
|
+
|
|
263
|
+
These helpers are useful for scenarios where direct access to the PyDAL objects is needed while still using TypeDAL.
|
|
264
|
+
An example of this is when you need to do a `db.commit()` but you can't import `db` directly:
|
|
265
|
+
|
|
266
|
+
```python
|
|
267
|
+
MyTable.insert(...)
|
|
268
|
+
db = get_db(MyTable)
|
|
269
|
+
db.commit() # this is usually done automatically but sometimes you want to manually commit.
|
|
270
|
+
```
|
|
271
|
+
|
|
250
272
|
## Caveats
|
|
251
273
|
|
|
252
274
|
- This package depends heavily on the current implementation of annotations (which are computed when the class is
|
|
@@ -10,7 +10,12 @@ import typing
|
|
|
10
10
|
from collections import ChainMap
|
|
11
11
|
from typing import Any
|
|
12
12
|
|
|
13
|
-
from
|
|
13
|
+
from pydal import DAL
|
|
14
|
+
|
|
15
|
+
from .types import AnyDict, Field, Table
|
|
16
|
+
|
|
17
|
+
if typing.TYPE_CHECKING:
|
|
18
|
+
from . import TypeDAL, TypedField, TypedTable # noqa: F401
|
|
14
19
|
|
|
15
20
|
T = typing.TypeVar("T")
|
|
16
21
|
|
|
@@ -274,3 +279,27 @@ def utcnow() -> dt.datetime:
|
|
|
274
279
|
"""
|
|
275
280
|
# return dt.datetime.now(dt.UTC)
|
|
276
281
|
return dt.datetime.now(dt.timezone.utc)
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
def get_db(table: "TypedTable | Table") -> "DAL":
|
|
285
|
+
"""
|
|
286
|
+
Get the underlying DAL instance for a pydal or typedal table.
|
|
287
|
+
"""
|
|
288
|
+
return typing.cast("DAL", table._db)
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
def get_table(table: "TypedTable | Table") -> "Table":
|
|
292
|
+
"""
|
|
293
|
+
Get the underlying pydal table for a typedal table.
|
|
294
|
+
"""
|
|
295
|
+
return typing.cast("Table", table._table)
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
def get_field(field: "TypedField[typing.Any] | Field") -> "Field":
|
|
299
|
+
"""
|
|
300
|
+
Get the underlying pydal field from a typedal field.
|
|
301
|
+
"""
|
|
302
|
+
return typing.cast(
|
|
303
|
+
"Field",
|
|
304
|
+
field, # Table.field already is a Field, but cast to make sure the editor knows this too.
|
|
305
|
+
)
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import typing
|
|
2
2
|
from datetime import datetime, timedelta
|
|
3
3
|
|
|
4
|
+
import pydal
|
|
4
5
|
import pytest
|
|
6
|
+
from pydal import DAL
|
|
5
7
|
|
|
6
8
|
from src.typedal.caching import get_expire
|
|
7
9
|
from src.typedal.helpers import (
|
|
@@ -16,8 +18,10 @@ from src.typedal.helpers import (
|
|
|
16
18
|
mktable,
|
|
17
19
|
origin_is_subclass,
|
|
18
20
|
to_snake,
|
|
19
|
-
unwrap_type,
|
|
21
|
+
unwrap_type, get_db, get_table, get_field,
|
|
20
22
|
)
|
|
23
|
+
from typedal import TypeDAL, TypedTable
|
|
24
|
+
from typedal.types import Field
|
|
21
25
|
|
|
22
26
|
|
|
23
27
|
def test_is_union():
|
|
@@ -175,3 +179,30 @@ def test_match_strings():
|
|
|
175
179
|
string_list = ["file1.txt", "file2.jpg", "file3.txt", "file4.png"]
|
|
176
180
|
expected_matches = []
|
|
177
181
|
assert sorted(match_strings(patterns, string_list)) == sorted(expected_matches)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
database = TypeDAL("sqlite:memory")
|
|
185
|
+
assert database._db_uid
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
@database.define()
|
|
189
|
+
class TestGetFunctions(TypedTable):
|
|
190
|
+
string: str
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def test_get_functions():
|
|
194
|
+
db = get_db(TestGetFunctions)
|
|
195
|
+
assert isinstance(db, DAL)
|
|
196
|
+
assert db._db_uid == database._db_uid
|
|
197
|
+
db = get_db(db.test_get_functions)
|
|
198
|
+
assert db._db_uid == database._db_uid
|
|
199
|
+
table = get_table(TestGetFunctions)
|
|
200
|
+
assert hasattr(table, "string")
|
|
201
|
+
assert issubclass(TestGetFunctions, TypedTable)
|
|
202
|
+
assert isinstance(table, pydal.objects.Table)
|
|
203
|
+
assert not isinstance(table, TypedTable)
|
|
204
|
+
field = get_field(TestGetFunctions.string)
|
|
205
|
+
print(
|
|
206
|
+
type(field)
|
|
207
|
+
)
|
|
208
|
+
assert isinstance(field, Field)
|
typedal-3.6.0/htmlcov/.gitignore
DELETED