Enhanced query and custom comparators

class coaster.sqlalchemy.comparators.Query(entities, session=None)[source]

Extends flask_sqlalchemy.BaseQuery to add additional helper methods.

isempty()[source]

Returns the equivalent of not bool(query.count()) but using an efficient SQL EXISTS function, so the database stops counting after the first result is found.

notempty()[source]

Returns the equivalent of bool(query.count()) but using an efficient SQL EXISTS function, so the database stops counting after the first result is found.

class coaster.sqlalchemy.comparators.SplitIndexComparator(expression, splitindex=None)[source]

Base class for comparators that support splitting a string and comparing with one of the split values.

class coaster.sqlalchemy.comparators.SqlSplitIdComparator(expression, splitindex=None)[source]

Allows comparing an id value with a column, useful mostly because of the splitindex feature, which splits an incoming string along the - character and picks one of the splits for comparison.

class coaster.sqlalchemy.comparators.SqlHexUuidComparator(expression, splitindex=None)[source]

Allows comparing UUID fields with hex representations of the UUID

class coaster.sqlalchemy.comparators.SqlBuidComparator(expression, splitindex=None)[source]

Allows comparing UUID fields with URL-safe Base64 (BUID) representations of the UUID

class coaster.sqlalchemy.comparators.SqlSuuidComparator(expression, splitindex=None)[source]

Allows comparing UUID fields with ShortUUID representations of the UUID