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
U
¤ý°dæã@sddZddlmZddlZddlmZmZmZmZm    Z    ddl
m Z Gdd„dej ƒZ Gd    d
„d
ƒZdS) zImplementation of the DbDoc.é)Ú annotationsN)ÚAnyÚDictÚKeysViewÚOptionalÚUnioné)ÚProgrammingErrorc@s eZdZdZdddœdd„ZdS)ÚExprJSONEncoderzgA :class:`json.JSONEncoder` subclass, which enables encoding of
    :class:`mysqlx.ExprParser` objects.ÚobjectÚstr)ÚoÚreturncCst|dƒr|›Stj ||¡S)NÚexpr)ÚhasattrÚjsonÚ JSONEncoderÚdefault)Úselfr ©rúCd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\mysqlx/dbdoc.pyr,s
zExprJSONEncoder.defaultN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__rrrrrr
(sr
c@sœeZdZdZdddœdd„Zddœd    d
„Zddœd d „Zdd ddœdd„Zdd dœdd„Zdddœdd„Z    d"dddœdd„Z
ddœdd„Z ddœd d!„Z dS)#ÚDbDoczÏRepresents a generic document in JSON format.
 
    Args:
        value (object): The value can be a JSON string or a dict.
 
    Raises:
        ValueError: If ``value`` type is not a basestring or dict.
    zUnion[str, Dict[str, Any]]ÚNone)ÚvaluercCs@t|tƒr||_n*t|tƒr*t |¡|_ntdt|ƒ›ƒ‚dS)NzUnable to handle type: )Ú
isinstanceÚdictÚ__dict__r rÚloadsÚ
ValueErrorÚtype)rrrrrÚ__init__=s
 
 
zDbDoc.__init__r )rcCs| ¡S©N)Úas_str©rrrrÚ__str__Esz DbDoc.__str__cCs
t|jƒSr%)Úreprr r'rrrÚ__repr__HszDbDoc.__repr__r)ÚindexrrcCs|dkrtdƒ‚||j|<dS)NÚ_idzCannot modify _id)r    r )rr+rrrrÚ __setitem__KszDbDoc.__setitem__)r+rcCs
|j|Sr%©r )rr+rrrÚ __getitem__PszDbDoc.__getitem__Úbool)ÚitemrcCs
||jkSr%r.)rr1rrrÚ __contains__SszDbDoc.__contains__Nz Optional[str])Údoc_idrcCs.|j ¡}|r||d<nd|kr&|d=t|ƒS)aeReturns a new copy of a :class:`mysqlx.DbDoc` object containing the
        `doc_id` provided. If `doc_id` is not provided, it will be removed from
        new :class:`mysqlx.DbDoc` object.
 
        Args:
            doc_id (Optional[str]): Document ID
 
        Returns:
            mysqlx.DbDoc: A new instance of DbDoc containing the _id provided
        r,)r Úcopyr)rr3Znew_dictrrrr4Vs
 
z
DbDoc.copyz KeysView[str]cCs
|j ¡S)zJReturns the keys.
 
        Returns:
            `list`: The keys.
        )r Úkeysr'rrrr5hsz
DbDoc.keyscCstj|jtdS)zÃSerialize :class:`mysqlx.DbDoc` to a JSON formatted ``str``.
 
        Returns:
            str: A JSON formatted ``str`` representation of the document.
 
        .. versionadded:: 8.0.16
        )Úcls)rÚdumpsr r
r'rrrr&psz DbDoc.as_str)N) rrrrr$r(r*r-r/r2r4r5r&rrrrr3s    r)rÚ
__future__rrÚtypingrrrrrÚerrorsr    rr
rrrrrÚ<module>s