zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
U
¸ý°d§{ã@sddlmZddlZddlmZddlmZddlmZddlmZddlm    Z    ddlm
Z
dd    lm Z dd
lm Z dd lm Z dd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZerddlmZddlmZddlmZddlmZede    dZ edZ!erBddiZ"ddiZ#niZ"iZ#ej$fddie"—ŽGd d!„d!e e ƒƒZ%Gd"d#„d#eje%e ƒZ&Gd$d%„d%e&e%e ƒZ'Gd&d'„d'e&e%e ƒZ(Gd(d)„d)e'e%e e(e%e ƒZ)Gd*d+„d+e&e%e*ƒZ+Gd,d-„d-e&e%e*ƒZ,Gd.d/„d/e&e%eƒZ-Gd0d1„d1e&e%eƒZ.Gd2d3„d3e&e%eƒZ/Gd4d5„d5e&e%eƒZ0Gd6d7„d7e(e%e*ƒZ1Gd8d9„d9e(e%e*ƒZ2Gd:d;„d;e(e%eƒZ3Gd<d=„d=e(e%eƒZ4Gd>d?„d?e(e%eƒZ5Gd@dA„dAe(e%eƒZ6dS)Bé)Ú annotationsN)Údate)Údatetime)Ú    timedelta)ÚDecimal)ÚAny)Úcast)ÚGeneric)ÚOptional)Úoverload)ÚTuple)ÚType)Ú TYPE_CHECKING)ÚTypeVar)ÚUnioné)Útypes)Úpy310)ÚLiteral)Ú ColumnElement)Ú_TE)Ú
TypeEngine)ÚTypeEngineMixinÚ_T)Úbound)z()ú[)z(]z[]ÚslotsTZkw_onlyÚfrozenc@s eZdZUdZdZded<dZded<erTej    ddZ
ded    <ej    d
dZ d ed <n8ej    fd die —ŽZ
ded    <ej    fd d
ie —ŽZ d ed <e s®dXdd
dœdddd dœdd„Zd dœdd„Zed dœdd„ƒZed dœdd„ƒZed dœdd„ƒZed dœdd„ƒZed dœdd„ƒZed dœdd „ƒZed!dœd"d#„ƒZd$d d%œd&d'„Zd(dœd)d*„ZdYdd+dd+d d,d-œd.d/„Zd(d d0œd1d2„Zd3d d0œd4d5„Zd6d d%œd7d8„Zd3d d0œd9d:„Zd3d d0œd;d<„ZeZ d3d d0œd=d>„Z!e!Z"d3d d0œd?d@„Z#d3d d0œdAdB„Z$dd+dd+d dCœdDdE„Z%d3d d0œdFdG„Z&d3d3d0œdHdI„Z'd3d3d0œdJdK„Z(d3d3d0œdLdM„Z)d3d3d0œdNdO„Z*d3d3d0œdPdQ„Z+d3d3d0œdRdS„Z,d+dœdTdU„Z-d+dœdVdW„Z.dS)ZÚRangea_Represent a PostgreSQL range.
 
    E.g.::
 
        r = Range(10, 50, bounds="()")
 
    The calling style is similar to that of psycopg and psycopg2, in part
    to allow easier migration from previous SQLAlchemy versions that used
    these objects directly.
 
    :param lower: Lower bound value, or None
    :param upper: Upper bound value, or None
    :param bounds: keyword-only, optional string value that is one of
     ``"()"``, ``"[)"``, ``"(]"``, ``"[]"``.  Defaults to ``"[)"``.
    :param empty: keyword-only, optional bool indicating this is an "empty"
     range
 
    .. versionadded:: 2.0
 
    Nz Optional[_T]ÚlowerÚupperr)ÚdefaultÚ _BoundsTypeÚboundsFÚboolÚemptyr!)r#r%©rr r#r%cCs|j ||||dœ¡dS)Nr&)Ú__dict__Úupdate)Úselfrr r#r%©r*ú\d:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/dialects/postgresql/ranges.pyÚ__init__Us    üÿzRange.__init__)ÚreturncCs|j S©N©r%©r)r*r*r+Ú__bool__gszRange.__bool__cCs|jS©z$A synonym for the 'empty' attribute.r/r0r*r*r+Úisemptyjsz Range.isemptycCs|jSr2r/r0r*r*r+Úis_emptypszRange.is_emptycCs|jddkS)z,Return True if the lower bound is inclusive.rú[©r#r0r*r*r+Ú    lower_incvszRange.lower_inccCs|j o|jdkS)zKReturn True if this range is non-empty and lower bound is
        infinite.N)r%rr0r*r*r+Ú    lower_inf|szRange.lower_infcCs|jddkS)z,Return True if the upper bound is inclusive.éú]r6r0r*r*r+Ú    upper_incƒszRange.upper_inccCs|j o|jdkS)zOReturn True if this range is non-empty and the upper bound is
        infinite.N)r%r r0r*r*r+Ú    upper_inf‰szRange.upper_infzAbstractRange[Range[_T]]cCstƒSr.)Ú AbstractRanger0r*r*r+Ú__sa_type_engine__szRange.__sa_type_engine__r©Úvaluer-cCs°|jr
dS|jdkr@|jdkp>|jddkr6||jkS||jkS|jdkrl|jddkrb||jkS||jkS|jddkr„||jkn||jko®|jddkr¦||jkS||jkS)z3Return True if this range contains the given value.FNr9ú)rú()r%rr r#©r)r@r*r*r+Ú_contains_value”s*
 
 ÿ ý
 ÿ ý ÿ ý ÿ ùzRange._contains_valuercCsbt|jtƒst|jtƒrdSt|jtƒs4t|jtƒr8dSt|jtƒsPt|jtƒrZtddSdSdS)uADetermine the â€œstep” for this range, if it is a discrete one.r9N)Údays)Ú
isinstancerÚintr rrrr0r*r*r+Ú_get_discrete_step²sÿ
zRange._get_discrete_stepÚstrrG)Úvalue1Úbound1Úvalue2Úbound2Ú only_valuesr-c Csx|dk}|dk}||kr$dkrBnn||kr4dS|r<dSdSn(|dkrV|rRdSdS|dkrj|rfdSdS||kr~||kr~dS|dk}|dk}    | ¡}
|
dk    rê|r´|sÄ||
7}d}n|rÄ||
7}d}|rÚ|    sê||
7}d}    n|    rê||
7}d}    ||krödS||krdS|rdS|r|    rdS|sH|    sH||kr8dS|rBdSdSn,|s\|rXdSdS|    sp|rldSdSdSdS)    aCompare two range bounds.
 
        Return -1, 0 or 1 respectively when `value1` is less than,
        equal to or greater than `value2`.
 
        When `only_value` is ``True``, do not consider the *inclusivity*
        of the edges, just their values.
        >rBr5Nréÿÿÿÿr9>r:r5TF)rH) r)rJrKrLrMrNZvalue1_is_lower_boundZvalue2_is_lower_boundZ
value1_incZ
value2_incÚstepr*r*r+Ú_compare_edgesÆs^  
 
zRange._compare_edges©Úotherr-c
Cs–t|tƒstS|jr|jrdS|j|jkr.dS|j}|jd}|j}|jd}|j}|jd}|j}|jd}    | ||||¡dko”| ||||    ¡dkS)z€Compare this range to the `other` taking into account
        bounds inclusivity, returning ``True`` if they are equal.
        TFrr9)rFrÚNotImplementedr%rr#r rQ©
r)rSÚslowerÚslower_bÚolowerÚolower_bÚsupperÚsupper_bÚoupperÚoupper_br*r*r+Ú__eq__s"
 
 
 
 
þz Range.__eq__z    Range[_T]c
Csˆ|jr
dS|jrdS|j}|jd}|j}|jd}| ||||¡dkrLdS|j}|jd}|j}|jd}    | ||||    ¡dkr„dSdS)z7Determine whether this range is a contained by `other`.TFrr9)r%rr#rQr rUr*r*r+Ú contained_by:s"
 
 
 
zRange.contained_byzUnion[_T, Range[_T]]cCs"t|tƒr| |¡S| |¡SdS)z.Determine whether this range contains `value`.N)rFrr_rDrCr*r*r+ÚcontainsWs
 
zRange.containsc
Cs¬|js |jrdS|j}|jd}|j}|jd}|j}|jd}|j}|jd}    | ||||¡dkr|| ||||    ¡dkr|dS| ||||¡dkr¨| ||||¡dkr¨dSdS)z3Determine whether this range overlaps with `other`.Frr9T©r%rr#r rQ©
r)rSrVrWrZr[rXrYr\r]r*r*r+Úoverlaps_s* 
 
 
 
ÿþÿþzRange.overlapscCsD|js |jrdS|j}|jd}|j}|jd}| ||||¡dkS)zBDetermine whether this range is completely to the left of `other`.Fr9r)r%r r#rrQ)r)rSrZr[rXrYr*r*r+Ústrictly_left_ofs 
 
zRange.strictly_left_ofcCsD|js |jrdS|j}|jd}|j}|jd}| ||||¡dkS)zCDetermine whether this range is completely to the right of `other`.Frr9ra)r)rSrVrWr\r]r*r*r+Ústrictly_right_ofs 
 
zRange.strictly_right_ofcCsD|js |jrdS|j}|jd}|j}|jd}| ||||¡dkS)z>Determine whether this does not extend to the left of `other`.Fr)r%rr#rQ)r)rSrVrWrXrYr*r*r+Únot_extend_left_of¡s 
 
zRange.not_extend_left_ofcCsD|js |jrdS|j}|jd}|j}|jd}| ||||¡dkS)z?Determine whether this does not extend to the right of `other`.Fr9r)r%r r#rQ)r)rSrZr[r\r]r*r*r+Únot_extend_right_of°s 
 
zRange.not_extend_right_of)rJrKrLrMr-cCsÖ| ||||d¡}|dkrr| ¡}|dkr.dS|dkrT|dkrJ|||kS||kSqÒ|dkrd||kS|||kSn`|dkrÎ|dkrŠ|dksš|dkr®|d    kr®| ¡}|dk    r®dS|dkr¾|dkpÌ|dkoÌ|d    kSdSdS)
zTDetermine whether an upper bound is immediately successive to a
        lower bound.TrONFr:r5rrArB)rQrH)r)rJrKrLrMÚresrPr*r*r+Ú_upper_edge_adjacent_to_lower¿s>  
ÿþýüÿüz#Range._upper_edge_adjacent_to_lowerc
Csp|js |jrdS|j}|jd}|j}|jd}|j}|jd}|j}|jd}    | ||||¡pn| ||    ||¡S)z8Determine whether this range is adjacent to the `other`.Frr9)r%rr#r rirbr*r*r+Ú adjacent_toîs. 
 
 
 
ÿÿþzRange.adjacent_tocCsÔ|jr
|S|jr|S| |¡s0| |¡s0tdƒ‚|j}|jd}|j}|jd}|j}|jd}|j}|jd}    | ||||¡dkrŽ|}
|} n|}
|} | ||||    ¡dkr´|} |} n|} |    } t|
| t    t
| | ƒdS)z¾Compute the union of this range with the `other`.
 
        This raises a ``ValueError`` exception if the two ranges are
        "disjunct", that is neither adjacent nor overlapping.
        zAAdding non-overlapping and non-adjacent ranges is not implementedrr9r6) r%rcrjÚ
ValueErrorrr#r rQrrr"©r)rSrVrWrZr[rXrYr\r]ZrlowerÚrlower_bZrupperÚrupper_br*r*r+Úunions>ÿ
 
 
 
 ÿz Range.unioncCs
| |¡Sr.)ro©r)rSr*r*r+Ú__add__2sz Range.__add__cCsø|js |jr|S|j}|jd}|j}|jd}|j}|jd}|j}|jd}    | ||||¡}
| ||||    ¡} |
dkrˆ| dkrˆtdƒ‚| ||||    ¡} | ||||¡} | dks¸| dkr¼|S|
dkrÚ| dkrÚtddddS|
dkrZ| dkrZ| dkrZ|dkrdnd    }|dkrB|d    krB| ||||¡dkrBtddddSt||tt||ƒd
S|
dkrÚ| dkrÚ| dkrÚ|    d    kr†d nd}|dkrÂ|d    krÂ| ||||¡dkrÂtddddSt||tt||ƒd
Sd sôt    d |›d|›ƒ‚dS)zÇCompute the difference between this range and the `other`.
 
        This raises a ``ValueError`` exception if the two ranges are
        "disjunct", that is neither adjacent nor overlapping.
        rr9z5Subtracting a strictly inner range is not implementedNTr/r5rAr:r6rBFzUnhandled case computing z - )
r%rr#r rQrkrrr"ÚAssertionError)r)rSrVrWrZr[rXrYr\r]Zsl_vs_olZsu_vs_ouZsl_vs_ouZsu_vs_olrnrmr*r*r+Ú
difference5sn 
 
 
 
ÿÿþÿý ýÿþÿý ýzRange.differencecCs
| |¡Sr.)rsrpr*r*r+Ú__sub__sz Range.__sub__cCsÈ|js|js| |¡s$tddddS|j}|jd}|j}|jd}|j}|jd}|j}|jd}    | ||||¡dkr‚|}
|} n|}
|} | ||||    ¡dkr¨|} |    } n|} |} t|
| tt| | ƒdS)zdCompute the intersection of this range with the `other`.
 
        .. versionadded:: 2.0.10
 
        NTr/rr9r6)    r%rcrrr#r rQrr"rlr*r*r+Ú intersection„s2
 
 
 
 ýzRange.intersectioncCs
| |¡Sr.)rurpr*r*r+Ú__mul__ªsz Range.__mul__cCs| ¡Sr.)Ú
_stringifyr0r*r*r+Ú__str__­sz Range.__str__cCs^|jr
dS|j|j}}|dkr$dn|}|dkr4dn|}td|jƒ\}}|›|›d|›|›S)Nr%ÚzTuple[str, str]ú,)r%rr rr#)r)ÚlÚrZb0Zb1r*r*r+rw°szRange._stringify)NN)F)/Ú__name__Ú
__module__Ú __qualname__Ú__doc__rÚ__annotations__r rÚ dataclassesÚfieldr#r%Ú    dc_kwonlyrr,r1Úpropertyr3r4r7r8r;r<r>rDrHrQr^r_r`rcrdÚ
__lshift__reÚ
__rshift__rfrgrirjrorqrsrtrurvrxrwr*r*r*r+r/sl
  ýúúY /.L&rcsŠeZdZdZdZdZeddddœdd„ƒZed    dd
dœd d„ƒZd dd
dœ‡fd d„ Zdddœdd„ZGdd„de    j
j e e ƒZ‡ZS)r=zª
    Base for PostgreSQL RANGE types.
 
    .. seealso::
 
        `PostgreSQL range functions <https://www.postgresql.org/docs/current/static/functions-range.html>`_
 
    Tz    Type[_TE]rr)ÚclsÚkwr-cKsdSr.r*©r)rˆr‰r*r*r+ÚadaptËszAbstractRange.adaptzType[TypeEngineMixin]zTypeEngine[Any]cKsdSr.r*rŠr*r*r+r‹Ïsz-Type[Union[TypeEngine[Any], TypeEngineMixin]]c sHt|tƒr8||jk    r8|j}t|›d||jfd|iƒƒStƒ |¡SdS)a    Dynamically adapt a range type to an abstract impl.
 
        For example ``INT4RANGE().adapt(_Psycopg2NumericRange)`` should
        produce a type that will have ``_Psycopg2NumericRange`` behaviors
        and also render as ``INT4RANGE`` in SQL and DDL.
 
        Z    RangeImplÚ__visit_name__N)Ú
issubclassÚAbstractRangeImplÚ    __class__rŒÚtypeÚsuperr‹)r)rˆr‰Z
visit_name©rr*r+r‹Ós 
ýr?cCsp|jdk    r|jn|j}t|tƒr&tƒSt|ttfƒr:tƒSt|tƒrV|j    sPt
ƒSt ƒSt|t ƒrft ƒStjSdSr.)rr rFrGÚ    INT8RANGErÚfloatÚNUMRANGErÚtzinfoÚTSRANGEÚ    TSTZRANGErÚ    DATERANGEÚsqltypesZNULLTYPE)r)r@Úspecr*r*r+Ú_resolve_for_literalòs
 
 
z"AbstractRange._resolve_for_literalcsîeZdZdZdddœ‡fdd„ Zddddœdd    „Zdddœd
d „Zdddœd d „Zdddœdd„ZeZ    dddœdd„Z
e
Z dddœdd„Z dddœdd„Z dddœdd„Zdddœdd„ZeZdddœdd„ZeZdddœdd„ZeZ‡ZS)z AbstractRange.comparator_factoryz-Define comparison operations for range types.rzColumnElement[bool]rRcs,|dkrtƒ |¡S|jjddd|ƒSdS)z<Boolean expression. Returns true if two ranges are not equalNz<>T©Z is_comparison)r‘Ú__ne__ÚexprÚoprpr’r*r+ržs z'AbstractRange.comparator_factory.__ne__)rSr‰r-cKs|jjddd|ƒS)a
Boolean expression. Returns true if the right hand operand,
            which can be an element or a range, is contained within the
            column.
 
            kwargs may be ignored by this operator but are required for API
            conformance.
            z@>Tr©rŸr )r)rSr‰r*r*r+r` sz)AbstractRange.comparator_factory.containscCs|jjddd|ƒS)zsBoolean expression. Returns true if the column is contained
            within the right hand operand.
            z<@Trr¡rpr*r*r+r_sz-AbstractRange.comparator_factory.contained_bycCs|jjddd|ƒS)z„Boolean expression. Returns true if the column overlaps
            (has points in common with) the right hand operand.
            z&&Trr¡rpr*r*r+rcsz)AbstractRange.comparator_factory.overlapscCs|jjddd|ƒS)zsBoolean expression. Returns true if the column is strictly
            left of the right hand operand.
            z<<Trr¡rpr*r*r+rd!sz1AbstractRange.comparator_factory.strictly_left_ofcCs|jjddd|ƒS)ztBoolean expression. Returns true if the column is strictly
            right of the right hand operand.
            z>>Trr¡rpr*r*r+re)sz2AbstractRange.comparator_factory.strictly_right_ofcCs|jjddd|ƒS)z‡Boolean expression. Returns true if the range in the column
            does not extend right of the range in the operand.
            z&<Trr¡rpr*r*r+rg1sz4AbstractRange.comparator_factory.not_extend_right_ofcCs|jjddd|ƒS)z†Boolean expression. Returns true if the range in the column
            does not extend left of the range in the operand.
            z&>Trr¡rpr*r*r+rf7sz3AbstractRange.comparator_factory.not_extend_left_ofcCs|jjddd|ƒS)z}Boolean expression. Returns true if the range in the column
            is adjacent to the range in the operand.
            z-|-Trr¡rpr*r*r+rj=sz,AbstractRange.comparator_factory.adjacent_tocCs|j d¡|ƒS)úRange expression. Returns the union of the two ranges.
            Will raise an exception if the resulting range is not
            contiguous.
            ú+r¡rpr*r*r+roCsz&AbstractRange.comparator_factory.unioncCs|j d¡|ƒS)r¢ú-r¡rpr*r*r+rsLsz+AbstractRange.comparator_factory.differencezColumnElement[Range[_T]]cCs|j d¡|ƒS)z¤Range expression. Returns the intersection of the two ranges.
            Will raise an exception if the resulting range is not
            contiguous.
            Ú*r¡rpr*r*r+ruUsz-AbstractRange.comparator_factory.intersection)r}r~rr€ržr`r_rcrdr†rer‡rgrfrjrorqrsrtrurvÚ __classcell__r*r*r’r+Úcomparator_factorys$
r§)r}r~rr€Zrender_bind_castÚ __abstract__r r‹rœršZ ConcatenableZ
Comparatorrrr§r¦r*r*r’r+r=½s    r=c@seZdZdZdS)rŽúKMarker for AbstractRange that will apply a subclass-specific
    adaptationN©r}r~rr€r*r*r*r+rŽ_srŽc@seZdZdZdZdS)ÚAbstractMultiRangez$base for PostgreSQL MULTIRANGE typesTN)r}r~rr€r¨r*r*r*r+r«dsr«c@seZdZdZdS)ÚAbstractMultiRangeImplr©Nrªr*r*r*r+r¬jsr¬c@seZdZdZdZdS)Ú    INT4RANGEz(Represent the PostgreSQL INT4RANGE type.N©r}r~rr€rŒr*r*r*r+r­qsr­c@seZdZdZdZdS)r“z(Represent the PostgreSQL INT8RANGE type.Nr®r*r*r*r+r“wsr“c@seZdZdZdZdS)r•z'Represent the PostgreSQL NUMRANGE type.Nr®r*r*r*r+r•}sr•c@seZdZdZdZdS)r™z(Represent the PostgreSQL DATERANGE type.Nr®r*r*r*r+r™ƒsr™c@seZdZdZdZdS)r—ú&Represent the PostgreSQL TSRANGE type.Nr®r*r*r*r+r—‰sr—c@seZdZdZdZdS)r˜ú(Represent the PostgreSQL TSTZRANGE type.Nr®r*r*r*r+r˜sr˜c@seZdZdZdZdS)ÚINT4MULTIRANGEz-Represent the PostgreSQL INT4MULTIRANGE type.Nr®r*r*r*r+r±•sr±c@seZdZdZdZdS)ÚINT8MULTIRANGEz-Represent the PostgreSQL INT8MULTIRANGE type.Nr®r*r*r*r+r²›sr²c@seZdZdZdZdS)Ú NUMMULTIRANGEz,Represent the PostgreSQL NUMMULTIRANGE type.Nr®r*r*r*r+r³¡sr³c@seZdZdZdZdS)ÚDATEMULTIRANGEz-Represent the PostgreSQL DATEMULTIRANGE type.Nr®r*r*r*r+r´§sr´c@seZdZdZdZdS)Ú TSMULTIRANGEr¯Nr®r*r*r*r+rµ­srµc@seZdZdZdZdS)ÚTSTZMULTIRANGEr°Nr®r*r*r*r+r¶³sr¶)7Ú
__future__rr‚rrrÚdecimalrÚtypingrrr    r
r r r rrrryrršÚutilrZ util.typingrZ sql.elementsrZ sql.type_apirrrrr"Zdc_slotsr„Z    dataclassrr=rŽr«r¬rGr­r“r•r™r—r˜r±r²r³r´rµr¶r*r*r*r+Ú<module>sr                       
#
 
 
ÿ