Skip to content

Releases: huntfx/ftrack-query

2.0 Update

25 Jun 14:52

Choose a tag to compare

Improvements

  • Rewrote module around new statements syntax
  • Added a subquery method
  • Added __and__ / __or__ support
  • Added basic group_by support
  • Type hints

Changes

  • in_() now takes a single parameter rather than attempting to guess the input

Deprecations

  • Removed ftrack_query.entity and other __getattr__ methods, replaced with ftrack_query.attr (entity.parent.task is now attr('parent.task'))
  • Removed Comparison.__call__ (because primary keys had to be hardcoded - attr('value')('x') is no longer mapped to attr('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 to TypedContext any 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

09 Feb 18:10

Choose a tag to compare

Improvements

  • Raises UnboundSessionError if 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

10 Oct 13:41

Choose a tag to compare

Changes

  • The clean_components() method has been moved to .options(remove_components=True)

Fix bug when reusing create statements

10 Oct 10:42

Choose a tag to compare

Fixes

  • Fix bug where reusing create statements would result in duplicate values.

Improved statements

30 Aug 10:39

Choose a tag to compare

Features

  • Add attr function to use with comparisons (attr('x.y') is replacing entity.x.y)
  • Add .options() method on queries to set the page size or attach a new session
  • Add FTRACK_API_PAGE_SIZE environment variable to set the page size globally, and a page_size parameter to FTrackQuery() to set it for the entire session
  • Add session.select() as shorthand for session.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

06 Jun 10:43

Choose a tag to compare

Features

  • Added select, update, delete and create statements to work in a similar way to SQLAlchemy.
  • 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 a delete statement, which will automatically remove matching components from every location.
  • Stop automatically executing the query when checking for truthiness.
  • Allow the use of order_by for sorting, and also accept asc/desc as strings.
  • Added a contains method, which is the equivelant of .like(f'%{val}%').

Automatically execute query objects in comparisons

21 Jun 12:26

Choose a tag to compare

Improvements

  • Any query objects passed into comparisons will now be executed.
    The following is now valid:
    session.Episode.where(project=query) - Executes query.one().
    session.Episode.where(entity.project == query) - Executes query.one().
    session.Episode.where(entity.project.in_(query)) - Executes query.all().
    session.Episode.where(entity.project.in_(query, query)) - Executes query.one() on each.

Improve populate behaviour

22 Apr 16:33

Choose a tag to compare

Improvements

  • Accept lists in populate function - session.populate(item, (entity.name, entity.project.name)) is now valid

Improvement to primary key query

15 Feb 13:00

Choose a tag to compare

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

12 Feb 11:18

Choose a tag to compare

Changes

  • Remove FTrackQuery.exc (ftrack_api.exception)
  • Remove FTrackQuery.symbol (ftrack_api.symbol)
  • Remove FTrackQuery.Entity (ftrack_api.entity.base.Entity)