shotgrid-orm 0.3.2__tar.gz → 0.3.3__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.
- {shotgrid_orm-0.3.2/src/shotgrid_orm.egg-info → shotgrid_orm-0.3.3}/PKG-INFO +1 -1
- {shotgrid_orm-0.3.2 → shotgrid_orm-0.3.3}/pyproject.toml +1 -1
- {shotgrid_orm-0.3.2 → shotgrid_orm-0.3.3}/src/shotgrid_orm/sgtypes.py +2 -0
- {shotgrid_orm-0.3.2 → shotgrid_orm-0.3.3/src/shotgrid_orm.egg-info}/PKG-INFO +1 -1
- {shotgrid_orm-0.3.2 → shotgrid_orm-0.3.3}/tests/test_sgorm.py +59 -0
- {shotgrid_orm-0.3.2 → shotgrid_orm-0.3.3}/LICENSE +0 -0
- {shotgrid_orm-0.3.2 → shotgrid_orm-0.3.3}/README.md +0 -0
- {shotgrid_orm-0.3.2 → shotgrid_orm-0.3.3}/setup.cfg +0 -0
- {shotgrid_orm-0.3.2 → shotgrid_orm-0.3.3}/src/shotgrid_orm/__init__.py +0 -0
- {shotgrid_orm-0.3.2 → shotgrid_orm-0.3.3}/src/shotgrid_orm/classes.py +0 -0
- {shotgrid_orm-0.3.2 → shotgrid_orm-0.3.3}/src/shotgrid_orm.egg-info/SOURCES.txt +0 -0
- {shotgrid_orm-0.3.2 → shotgrid_orm-0.3.3}/src/shotgrid_orm.egg-info/dependency_links.txt +0 -0
- {shotgrid_orm-0.3.2 → shotgrid_orm-0.3.3}/src/shotgrid_orm.egg-info/requires.txt +0 -0
- {shotgrid_orm-0.3.2 → shotgrid_orm-0.3.3}/src/shotgrid_orm.egg-info/top_level.txt +0 -0
- {shotgrid_orm-0.3.2 → shotgrid_orm-0.3.3}/tests/test_createdb.py +0 -0
- {shotgrid_orm-0.3.2 → shotgrid_orm-0.3.3}/tests/test_createscript.py +0 -0
- {shotgrid_orm-0.3.2 → shotgrid_orm-0.3.3}/tests/test_index.py +0 -0
- {shotgrid_orm-0.3.2 → shotgrid_orm-0.3.3}/tests/test_model.py +0 -0
|
@@ -36,6 +36,7 @@ sg_types = {
|
|
|
36
36
|
"currency": {"hint": Mapped[float], "type": mapped_column(Float)},
|
|
37
37
|
"date": {"hint": Mapped[str], "type": mapped_column(String)},
|
|
38
38
|
"date_time": {"hint": Mapped[datetime], "type": mapped_column(DateTime)},
|
|
39
|
+
"duration": {"hint": Mapped[int], "type": mapped_column(Integer)},
|
|
39
40
|
# NOTE: Entity types are stored as integer IDs. Relationship mappings are handled
|
|
40
41
|
# in classes.py by creating _id and _type fields for polymorphic associations.
|
|
41
42
|
# Full SQLAlchemy relationship() support could be added in future versions.
|
|
@@ -71,6 +72,7 @@ sg_types_optional = {
|
|
|
71
72
|
"currency": {"hint": Mapped[Optional[float]], "type": mapped_column(Float)},
|
|
72
73
|
"date": {"hint": Mapped[Optional[str]], "type": mapped_column(String)},
|
|
73
74
|
"date_time": {"hint": Mapped[Optional[datetime]], "type": mapped_column(DateTime)},
|
|
75
|
+
"duration": {"hint": Mapped[Optional[int]], "type": mapped_column(Integer)},
|
|
74
76
|
# NOTE: Entity types are stored as integer IDs. Relationship mappings are handled
|
|
75
77
|
# in classes.py by creating _id and _type fields for polymorphic associations.
|
|
76
78
|
"entity": {"hint": Mapped[Optional[int]], "type": mapped_column(Integer)},
|
|
@@ -276,3 +276,62 @@ def test_entity_field_fk_enforced_in_db(sg_orm, test_db_path):
|
|
|
276
276
|
asset_fks = inspector.get_foreign_keys("Asset")
|
|
277
277
|
entity_source_fks = [fk for fk in asset_fks if "entity_source_id" in fk["constrained_columns"]]
|
|
278
278
|
assert len(entity_source_fks) == 0, "Asset.entity_source_id must NOT have a FK (polymorphic field)"
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def test_duration_field_type(tmp_path):
|
|
282
|
+
"""duration fields are numeric (integer minutes) and persist as Integer columns."""
|
|
283
|
+
import json
|
|
284
|
+
|
|
285
|
+
from sqlalchemy.types import Integer
|
|
286
|
+
|
|
287
|
+
schema = {
|
|
288
|
+
"Task": {
|
|
289
|
+
"name": {"visible": True},
|
|
290
|
+
"fields": {
|
|
291
|
+
"id": {
|
|
292
|
+
"data_type": {"value": "number"},
|
|
293
|
+
"editable": False,
|
|
294
|
+
"entity_type": {"value": "Task"},
|
|
295
|
+
"mandatory": {"value": False},
|
|
296
|
+
"name": {"value": "id"},
|
|
297
|
+
"properties": {"default_value": {"value": None}},
|
|
298
|
+
"unique": False,
|
|
299
|
+
"visible": {"value": True},
|
|
300
|
+
},
|
|
301
|
+
"duration": {
|
|
302
|
+
"data_type": {"value": "duration"},
|
|
303
|
+
"editable": True,
|
|
304
|
+
"entity_type": {"value": "Task"},
|
|
305
|
+
"mandatory": {"value": False},
|
|
306
|
+
"name": {"value": "duration"},
|
|
307
|
+
"properties": {"default_value": {"value": None}},
|
|
308
|
+
"unique": False,
|
|
309
|
+
"visible": {"value": True},
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
schema_path = tmp_path / "schema.json"
|
|
316
|
+
schema_path.write_text(json.dumps(schema))
|
|
317
|
+
|
|
318
|
+
orm = SGORM(sg_schema_type=SchemaType.JSON_FILE, sg_schema_source=str(schema_path), echo=False)
|
|
319
|
+
Task = orm["Task"]
|
|
320
|
+
assert Task is not None
|
|
321
|
+
assert hasattr(Task, "duration")
|
|
322
|
+
|
|
323
|
+
engine = create_engine("sqlite+pysqlite:///:memory:", echo=False)
|
|
324
|
+
orm.Base.metadata.create_all(engine)
|
|
325
|
+
|
|
326
|
+
# Duration column must map to an integer type.
|
|
327
|
+
duration_col = next(c for c in Task.__table__.columns if c.name == "duration")
|
|
328
|
+
assert isinstance(duration_col.type, Integer)
|
|
329
|
+
|
|
330
|
+
# Round-trip a value to ensure persistence works.
|
|
331
|
+
session = Session(engine)
|
|
332
|
+
task = Task(id=1, duration=120)
|
|
333
|
+
session.add(task)
|
|
334
|
+
session.commit()
|
|
335
|
+
retrieved = session.get(Task, 1)
|
|
336
|
+
assert retrieved.duration == 120
|
|
337
|
+
session.close()
|
|
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
|