zmc
2023-10-12 ed135d79df12a2466b52dae1a82326941211dcc9
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
U
¸ý°dë!ã@spddlZddlmZddlmZddlmZddlmZddlmZGd    d
„d
ejej    eƒZ
Gd d „d eƒZ dS) éNé)Ú _StringTypeé)Úexc)Úsql)Úutil)ÚsqltypescsDeZdZdZdZdZdd„Zedd„ƒZ‡fdd„Z    d    d
„Z
‡Z S) ÚENUMzMySQL ENUM type.TcOs4| dd¡| ||¡tj|fd|ji|—ŽdS)a°Construct an ENUM.
 
        E.g.::
 
          Column('myenum', ENUM("foo", "bar", "baz"))
 
        :param enums: The range of valid values for this ENUM.  Values in
          enums are not quoted, they will be escaped and surrounded by single
          quotes when generating the schema.  This object may also be a
          PEP-435-compliant enumerated type.
 
          .. versionadded: 1.1 added support for PEP-435-compliant enumerated
             types.
 
        :param strict: This flag has no effect.
 
         .. versionchanged:: The MySQL ENUM type as well as the base Enum
            type now validates all Python data values.
 
        :param charset: Optional, a column-level character set for this string
          value.  Takes precedence to 'ascii' or 'unicode' short-hand.
 
        :param collation: Optional, a column-level collation for this string
          value.  Takes precedence to 'binary' short-hand.
 
        :param ascii: Defaults to False: short-hand for the ``latin1``
          character set, generates ASCII in schema.
 
        :param unicode: Defaults to False: short-hand for the ``ucs2``
          character set, generates UNICODE in schema.
 
        :param binary: Defaults to False: short-hand, pick the binary
          collation type that matches the column's character set.  Generates
          BINARY in schema.  This does not affect the type of data stored,
          only the collation of character data.
 
        ÚstrictNÚlength)ÚpopZ
_enum_initrÚ__init__r )ÚselfÚenumsÚkw©rú[d:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/dialects/mysql/enumerated.pyr s&  z ENUM.__init__cKs4| d|j¡| d|j¡| d|j¡|f|ŽS)zXProduce a MySQL native :class:`.mysql.ENUM` from plain
        :class:`.Enum`.
 
        Úvalidate_stringsÚvalues_callableZ omit_aliases)Ú
setdefaultrrZ _omit_aliases)ÚclsÚimplrrrrÚadapt_emulated_to_nativeDszENUM.adapt_emulated_to_nativecs|dkr |Stƒ |¡SdS)NÚ)ÚsuperÚ_object_value_for_elem)rÚelem©Ú    __class__rrrOszENUM._object_value_for_elemcCstj|tttjgdS)N)Ú
to_inspect)rÚ generic_reprr    rrÚEnum©rrrrÚ__repr__Ys
ÿz ENUM.__repr__) Ú__name__Ú
__module__Ú __qualname__Ú__doc__Ú__visit_name__Z native_enumr Ú classmethodrrr#Ú __classcell__rrrrr    s*
 
 
r    csTeZdZdZdZ‡fdd„Zdd„Z‡fdd„Z‡fdd    „Zd
d „Z    d d „Z
‡Z S)ÚSETzMySQL SET type.csž| dd¡|_t|ƒ|_|js0d|kr0t d¡‚|jrhdd„t|jƒDƒ|_|j dd„t|jƒDƒ¡t    d    d
„|Dƒd gƒ}| 
d |¡t ƒj f|Žd S)aConstruct a SET.
 
        E.g.::
 
          Column('myset', SET("foo", "bar", "baz"))
 
 
        The list of potential values is required in the case that this
        set will be used to generate DDL for a table, or if the
        :paramref:`.SET.retrieve_as_bitwise` flag is set to True.
 
        :param values: The range of valid values for this SET. The values
          are not quoted, they will be escaped and surrounded by single
          quotes when generating the schema.
 
        :param convert_unicode: Same flag as that of
         :paramref:`.String.convert_unicode`.
 
        :param collation: same as that of :paramref:`.String.collation`
 
        :param charset: same as that of :paramref:`.VARCHAR.charset`.
 
        :param ascii: same as that of :paramref:`.VARCHAR.ascii`.
 
        :param unicode: same as that of :paramref:`.VARCHAR.unicode`.
 
        :param binary: same as that of :paramref:`.VARCHAR.binary`.
 
        :param retrieve_as_bitwise: if True, the data for the set type will be
          persisted and selected using an integer value, where a set is coerced
          into a bitwise mask for persistence.  MySQL allows this mode which
          has the advantage of being able to store values unambiguously,
          such as the blank string ``''``.   The datatype will appear
          as the expression ``col + 0`` in a SELECT statement, so that the
          value is coerced into an integer value in result sets.
          This flag is required if one wishes
          to persist a set that can store the blank string ``''`` as a value.
 
          .. warning::
 
            When using :paramref:`.mysql.SET.retrieve_as_bitwise`, it is
            essential that the list of set values is expressed in the
            **exact same order** as exists on the MySQL database.
 
        Úretrieve_as_bitwiseFrzNCan't use the blank value '' in a SET without setting retrieve_as_bitwise=TruecSsi|]\}}|d|“qS)ér©Ú.0ÚidxÚvaluerrrÚ
<dictcomp>šsz SET.__init__.<locals>.<dictcomp>css|]\}}d||fVqdS)r-Nrr.rrrÚ    <genexpr>szSET.__init__.<locals>.<genexpr>cSsg|] }t|ƒ‘qSr)Úlen)r/ÚvrrrÚ
<listcomp> sz SET.__init__.<locals>.<listcomp>rr N) r r,ÚtupleÚvaluesrÚ ArgumentErrorÚ    enumerateÚ_bitmapÚupdateÚmaxrrr )rr8rr rrrr ds .
ÿÿ ÿ z SET.__init__cCs(|jr t t |tj¡d|¡S|SdS©Nr)r,rZ type_coercerZInteger)rZcolexprrrrÚcolumn_expression¤s ÿzSET.column_expressioncs2ˆjr‡fdd„}ntƒ ||¡‰‡fdd„}|S)Ncs,|dk    r$t|ƒ}tt ˆjj|¡ƒSdSdS)N)ÚintÚsetrZmap_bitsr;Ú __getitem__©r1r"rrÚprocess¯sz%SET.result_processor.<locals>.processcs@t|tƒr&ˆrˆ|ƒ}tt d|¡ƒS|dk    r8| d¡|SdS)Nz[^,]+r)Ú
isinstanceÚstrrAÚreÚfindallÚdiscardrC©Ú super_convertrrrDºs
 
)r,rÚresult_processor)rÚdialectZcoltyperDr©rrKrrL¬s
     zSET.result_processorcs2tƒ |¡‰ˆjr"‡‡fdd„}n ‡fdd„}|S)NcsP|dkr dSt|ttfƒr,ˆr&ˆ|ƒS|Sn d}|D]}|ˆj|O}q4|SdSr>)rEr@rFr;)r1Z    int_valuer5rNrrrDÍsz#SET.bind_processor.<locals>.processcs4|dk    r t|ttfƒs d |¡}ˆr,ˆ|ƒS|SdS)Nú,)rEr@rFÚjoinrCrJrrrDÝs
 
)rÚbind_processorr,)rrMrDrrNrrQÉs
 
zSET.bind_processorcKs |j|d<tj||f|jž|ŽS)Nr,)r,rZconstructor_copyr8)rZimpltyperrrrÚadaptés
z    SET.adaptcCstj|ttgdgdS)N)r,F)rZ additional_kw)rr r+rr"rrrr#ís ÿýz SET.__repr__) r$r%r&r'r(r r?rLrQrRr#r*rrrrr+_s @   r+) rGÚtypesrrrrrrZNativeForEmulatedr!r    r+rrrrÚ<module>
s     L