U Yzf_y@sdZddlZddlZddlZddlmZmZddlmZddlm Z ddl m Z ddl m Z mZd d Zd d Zd dZddZddZddZddZddZddZddZddZGdd d eZGd!d"d"eZGd#d$d$eZGd%d&d&eZGd'd(d(eZGd)d*d*eZ Gd+d,d,eZ!Gd-d.d.eZ"Gd/d0d0eZ#Gd1d2d2eZ$Gd3d4d4eZ%Gd5d6d6eZ&Gd7d8d8eZ'Gd9d:d:eZ(Gd;d<dd>e(Z*Gd?d@d@e*Z+GdAdBdBe+Z,GdCdDdDe*Z-dS)Ez%Implementation of the Result classes.N)datetime timedelta)DbDoc)MYSQL_CHARACTER_SETS) STRING_TYPES)decode_from_bytes deprecatedcCst|dkrdSzPtjttjttjttjt tj t tj t tjttjttjttjttjti ||WStk r}z4tjd|tjd|dWYdSd}~XYnXdS)Nr{0}hex)lenColumnProtoTypeSINTvarsint_from_protobufUINTvarint_from_protobufBYTESbytes_from_protobufDATETIMEdatetime_from_protobufTIMEtime_from_protobufFLOATfloat_from_protobufDOUBLEdouble_from_protobufBITSETset_from_protobufENUMDECIMALdecimal_from_protobufKeyErrorsysstderrwriteformatencode)col_typepayloaderrr+e/private/var/folders/n9/53xbvtmd7sjg1q1l55xmpg58n4mgng/T/pip-unpacked-wheel-47tvuv7y/mysqlx/result.py from_protobuf,sD    r-cCst|ddS)N)rr)r+r+r,rDsrcCst|dksttd|S)NzZ"d?d@Z#dS)BColumna_Represents meta data for a table column. Args: col_type (int): The column type. catalog (str): The catalog. schema (str): The schema name. table (str): The table name. original_table (str): The original table name. name (str): The column name. original_name (str): The original table name. length (int): The column length, collation (str): The collation name. fractional_digits (int): The fractional digits. flags (int): The flags. content_type (int): The content type. .. versionchanged:: 8.0.12 Nc Cst||_t||_t||_t||_t||_||_d|_||_||_ | |_ | |_ | |_ | |_ d|_d|_d|_d|_d|_d|_d|_|j dkr|j ttkrtd|j t|j } | d|_| d|_d|jkpd|jk|_||jtjtjtjtjtjfk|_dS)NFrz"No mapping found for collation {0}rbinaryZ_bin) r_schema_name_original_name_table_original_table _proto_type _col_type_catalog_lengthZ _collation_fractional_digits_flags _content_type_number_signed _is_padded _is_binary _is_bytes_collation_name_character_set_name _zero_fillr rr9r& _map_typer`rrrrr)rr(catalogschematableZoriginal_tablename original_namelengthZ collationfractional_digitsflags content_typeinfor+r+r,rsN          zColumn.__init__cCst|j|j|jt|jdS)N)r(rrr)strrrrrrr+r+r,rs zColumn.__str__cCsj|jtjkrtj|_nD|jtjkr,tj|_n.|jtjkrBtj|_n|jrRtj|_ntj |_|j d@|_ dS)z Map bytes.rN) rrrr`rrrrrrrrrr+r+r, _map_bytess       zColumn._map_bytescCsN|jdkrtj|_n6|jtj@dkr.tj|_n|jdkrBtj|_ntddS)z Map datetime.rJrrkz#Datetime mapping scenario unhandledN) rr`rrrrrrr9rr+r+r, _map_datetimes     zColumn._map_datetimecCsb|jdkrtj|_nD|jdkr(tj|_n0|jdkrr Z_has_more_datarArBrCZset_active_resultrr+r+r,rDszBufferingResult._init_resultcCsr|j|}|dkrdSdgt|d}|shtt|dD](}|j|}t||d|||<q>t||S)zRead item. Args: dumping (bool): `True` for dumping. Returns: :class:`mysqlx.Row`: A `Row` object. Nfield)rZread_rowr rr>r-rr )rdumpingrowrArcolr+r+r, _read_items   zBufferingResult._read_itemcCsL|jr dSd}t|jD].}|d}|dkr2qH|j||d7}q|S)zSReads the page items. Returns: int: Total items read. FrNr)rrrBrJrArG)rrErrAr+r+r,_page_in_itemss   zBufferingResult._page_in_itemscCs0d}|jD] }||kr"|S|d7}q dS)zeReturns the index of the column. Returns: int: The index of the column. rrr.)r>r)rZcol_namerrIr+r+r,rs    zBufferingResult.index_ofcCs|jr dS|dS)zuFetch one item. Returns: :class:`mysqlx.Row` or :class:`mysqlx.DbDoc`: one result item. NF)rrJrr+r+r, fetch_oneszBufferingResult.fetch_onecCs|sq q|jS)zFetch all items. Returns: `list`: The list of items of :class:`mysqlx.DbDoc` or :class:`mysqlx.Row`. )rKrArr+r+r, fetch_allszBufferingResult.fetch_allcCs ||_dS)zdSets if result has data. Args: flag (bool): `True` if result has data. Nr?r'r+r+r, set_has_dataszBufferingResult.set_has_datacCs ||_dS)zfSets if has more results. Args: flag (bool): `True` if has more results. N)r@r'r+r+r,set_has_more_resultssz$BufferingResult.set_has_more_results)r]r^r_r rrrrErDrJrKrrLrMrOrPr<r+r+r7r,r=s      r=cs4eZdZdZfddZeddZddZZS) RowResultzAllows traversing the Row objects returned by a Table.select operation. Args: connection (mysqlx.connection.Connection): The Connection object. cstt||dSr{)r4rQrr!r7r+r,rszRowResult.__init__cCs|jS)z`list`: The list of columns.r>rr+r+r,columnsszRowResult.columnscCs|jS)zReturns the list of columns. Returns: `list`: The list of columns. .. versionadded:: 8.0.12 rRrr+r+r, get_columnsszRowResult.get_columns) r]r^r_r rrrSrTr<r+r+r7r,rQs   rQcs8eZdZdZfddZddZddZdd ZZS) SqlResultzRepresents a result from a SQL statement. Args: connection (mysqlx.connection.Connection): The Connection object. cstt||dSr{)r4rUrr!r7r+r,r0szSqlResult.__init__cCs|jS)zReturns the identifier for the last record inserted. Returns: str: The identifier of the last record inserted. r/rr+r+r,r83sz!SqlResult.get_autoincrement_valuecCs|jr dSd|_|dS)zjProcess the next result. Returns: bool: Returns `True` if the fetch is done. FT)rr@rDrr+r+r, next_result;s zSqlResult.next_resultcCs|jS)zReturns True if result has data. Returns: bool: Returns `True` if result has data. .. versionadded:: 8.0.12 rNrr+r+r,has_dataGszSqlResult.has_data) r]r^r_r rr8rVrWr<r+r+r7r,rU*s   rUcs,eZdZdZfddZfddZZS) DocResultzAllows traversing the DbDoc objects returned by a Collection.find operation. Args: connection (mysqlx.connection.Connection): The Connection object. cstt||dSr{)r4rXrr!r7r+r,rXszDocResult.__init__cs,tt||}|dkrdStt|dS)zRead item. Args: dumping (bool): `True` for dumping. Returns: :class:`mysqlx.DbDoc`: A `DbDoc` object. Nr)r4rXrJrr)rrGrHr7r+r,rJ[s zDocResult._read_item)r]r^r_r rrJr<r+r+r7r,rXQs rX).r rMr3r#rrZdbdocrZcharsetsrcompatrZhelpersrr r-rrrrCrrrr!rrobjectr[r`r rrrrrrrrrr rr3r=rQrUrXr+r+r+r,sP   $ L'[)K/~'