Releases: huntfx/ftrack-query
Releases · huntfx/ftrack-query
2.0 Update
Improvements
- Rewrote module around new statements syntax
- Added a subquery method
- Added
__and__/__or__support - Added basic
group_bysupport - Type hints
Changes
in_()now takes a single parameter rather than attempting to guess the input
Deprecations
- Removed
ftrack_query.entityand other__getattr__methods, replaced withftrack_query.attr(entity.parent.taskis nowattr('parent.task')) - Removed
Comparison.__call__(because primary keys had to be hardcoded -attr('value')('x')is no longer mapped toattr('value') == 'x') - Removed ability to join queries with or (too complex and not useful -
select('Task').where(name='Task 1') | select('Task').where(name='Task 2')will no longer evaluate to'select from Task where (name is "Task 1" or name is "Task 2")') - Removed
Session.get()override (the type won't automatically default toTypedContextany more) - Removed
keys()method on an entity type (since it wasn't a clean implementation) - Removed the custom logger and merged with the default one
Bug fixes and custom exceptions
Improvements
- Raises
UnboundSessionErrorif attempting to execute a query with no attached session.
Fixes
- Fix error when using
in_()without any arguments or with an empty generator.
Change component cleanup method to an option
Changes
- The
clean_components()method has been moved to.options(remove_components=True)
Fix bug when reusing create statements
Fixes
- Fix bug where reusing create statements would result in duplicate values.
Improved statements
Features
- Add
attrfunction to use with comparisons (attr('x.y')is replacingentity.x.y) - Add
.options()method on queries to set the page size or attach a new session - Add
FTRACK_API_PAGE_SIZEenvironment variable to set the page size globally, and apage_sizeparameter toFTrackQuery()to set it for the entire session - Add
session.select()as shorthand forsession.execute(select())
Improvements
.in_()now supports any data types- Generators are now automatically unpacked when passed to
in_() - Subqueries will not attempt to remap any values (it was confusing behaviour)
New statement syntax
Features
- Added
select,update,deleteandcreatestatements to work in a similar way toSQLAlchemy. - Rewrote subquery support - subqueries will be used when the API allows for it, otherwise an error will be raised (the old way would automatically execute the query).
Improvements
- Add a
clean_components()method when building adeletestatement, which will automatically remove matching components from every location. - Stop automatically executing the query when checking for truthiness.
- Allow the use of
order_byfor sorting, and also acceptasc/descas strings. - Added a
containsmethod, which is the equivelant of.like(f'%{val}%').
Automatically execute query objects in comparisons
Improvements
- Any query objects passed into comparisons will now be executed.
The following is now valid:
session.Episode.where(project=query)- Executesquery.one().
session.Episode.where(entity.project == query)- Executesquery.one().
session.Episode.where(entity.project.in_(query))- Executesquery.all().
session.Episode.where(entity.project.in_(query, query))- Executesquery.one()on each.
Improve populate behaviour
Improvements
- Accept lists in populate function -
session.populate(item, (entity.name, entity.project.name))is now valid
Improvement to primary key query
Fixes
- If the primary key query finds multiple entities with different capitalisation, return the one exactly matching the input
Remove ftrack_api modules as class attributes
Changes
- Remove
FTrackQuery.exc(ftrack_api.exception) - Remove
FTrackQuery.symbol(ftrack_api.symbol) - Remove
FTrackQuery.Entity(ftrack_api.entity.base.Entity)