File tree Expand file tree Collapse file tree 6 files changed +545
-0
lines changed
Expand file tree Collapse file tree 6 files changed +545
-0
lines changed Original file line number Diff line number Diff line change 1+ # psqlextra.contrib
2+
3+ This module contains a arbitrary collection of utilities and snippets that build on top of core functionality provided by django-postgres-extra.
4+
5+ This collection is UNTESTED, UNSUPPORTED and UNDOCUMENTED. They are only provided here as an inspiration. Use at your own risk.
Original file line number Diff line number Diff line change 1+ from .model_data_migrator import PostgresModelDataMigrator
2+ from .static_row import StaticRowQueryCompiler , StaticRowQuerySet
3+ from .transaction import no_transaction
4+
5+ __all__ = [
6+ "PostgresModelDataMigrator" ,
7+ "PostgresModelDataMigratorState" "StaticRowQuery" ,
8+ "StaticRowQueryCompiler" ,
9+ "StaticRowQuerySet" ,
10+ "no_transaction" ,
11+ ]
Original file line number Diff line number Diff line change 1+ from django .db import models
2+ from django .db .models .expressions import CombinedExpression , Func
3+
4+
5+ class Equals (CombinedExpression ):
6+ """Expression that constructs `{lhs} = {rhs}`.
7+
8+ Used as an alternative to Django's `Q` object when the
9+ left-hand side is a aliased field not known to Django.
10+ """
11+
12+ connector : str = "="
13+
14+ def __init__ (self , lhs , rhs ) -> None :
15+ super ().__init__ (
16+ lhs , self .connector , rhs , output_field = models .BooleanField ()
17+ )
18+
19+
20+ class Is (Equals ):
21+ """Expression that constructs `{lhs} IS {rhs}`."""
22+
23+ connector : str = "IS"
24+
25+
26+ class GreaterThen (Equals ):
27+ """Expression that constructs `{lhs} > {rhs}`."""
28+
29+ connector : str = ">"
30+
31+
32+ class LowerThenOrEqual (Equals ):
33+ """Expression that constructs `{lhs} <= {rhs}`."""
34+
35+ connector : str = "<="
36+
37+
38+ class And (Equals ):
39+ """Expression that constructs `{lhs} AND {rhs}`."""
40+
41+ connector : str = "AND"
42+
43+
44+ class Bool (Func ):
45+ """Cast to a boolean."""
46+
47+ function = "BOOL"
You can’t perform that action at this time.
0 commit comments