1Ei(dZddlZddlZddlmZddlmZddlmZejdZ ejd Z Gd d e Z d Z ejd ZGddejjZGddejjZGdde ZGdde ZGddeZGdde ZGddeZGddejZGddejeZGd d!ejZd#d"ZdS)$z4Foundational utilities common to many sql modules. N) ClauseVisitor)exc)utilPARSE_AUTOCOMMITNO_ARGc$eZdZdZdZdZdZdS) Immutablez@mark a ClauseElement as 'immutable' when expressions are cloned.c tdNz(Immutable objects do not support copyingNotImplementedErrorself optionaldictkwargss /srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/sqlalchemy/sql/base.py unique_paramszImmutable.unique_params!"LMMMc tdr rrs rparamszImmutable.paramsrrc|SNrs r_clonezImmutable._clone"s rN)__name__ __module__ __qualname____doc__rrrrrrr r sMJJNNNNNNrr c2tjd|DS)Ncg|] }|j Sr) _from_objects).0elements r z!_from_objects..'sKKKwW2KKKr) itertoolschain)elementss rr%r%&s ?KK(KKK LLrcb|d}||g|ddRi||S)zMark a method as generative.rrN) _generate)fnargskwrs r _generativer1*sF 7    DBtd122h" Krc<eZdZdZdZdZdZdZdZdZ dZ d S) _DialectArgViewzaA dictionary view of dialect-level arguments in the form _. c||_dSr)obj)rr5s r__init__z_DialectArgView.__init__9s rc |dd\}}||fS#t$r.}tjt ||Yd}~dSd}~wwxYw)N_rreplace_context)split ValueErrorrraise_KeyError)rkeydialect value_keyerrs r_keyz_DialectArgView._key<sz &!$3!2!2 GYI% % < < < K s ; ; ; ; ; ; ; ; ; ; )rr?r@rAoptrBs r __getitem__z_DialectArgView.__getitem__Ds!YYs^^ "(*73Cy> !$ < < < K s ; ; ; ; ; ; ; ; ; ; _r9)rCr5rEr>rr=r ArgumentError)rr?valuer@rArBs r __setitem__z_DialectArgView.__setitem__Ns A!%3 GYK|]}t|jVdSr)len _non_defaults)r&r/s r z*_DialectArgView.__len__..`sA   " # #      r)sumr5rEvaluesrs r__len__z_DialectArgView.__len___sA  07799      rc4fdjjDS)Nc3~K|]7}jj|jD]}tj|d|V8dS)r8N)r5rErRr safe_kwarg)r& dialect_name value_namers rrSz+_DialectArgView.__iter__..fss  "h6    O|||ZZ@ A A       r)r5rErs`r__iter__z_DialectArgView.__iter__es3    $ 8    rN) rr r!r"r6rCrHrLrNrVr\rrrr3r33s &&&""" A A A999        rr3c6eZdZdZdZdZdZdZdZdZ dS) _DialectArgDictzA dictionary view of dialect-level arguments for a specific dialect. Maintains a separate collection of user-specified arguments and dialect-specified default arguments. c"i|_i|_dSrrR _defaultsrs rr6z_DialectArgDict.__init__xsrcttt|j|jSr)rQsetrRunionrars rrVz_DialectArgDict.__len__|s+3t)**00@@AAArcttt|j|jSr)iterrcrRrdrars rr\z_DialectArgDict.__iter__s+C*++11$.AABBBrcH||jvr |j|S|j|Srr`rr?s rrHz_DialectArgDict.__getitem__s+ $$ $ $%c* *>#& &rc||j|<dSrrR)rr?rKs rrLz_DialectArgDict.__setitem__s"'3rc|j|=dSrrjrhs rrNz_DialectArgDict.__delitem__s  s # # #rN) rr r!r"r6rVr\rHrLrNrrrr^r^os~BBBCCC''' ((($$$$$rr^ceZdZdZedZejdZe dZ ej ddZ ej e ZdZejdZd Zd S) DialectKWArgsa9Establish the ability for a class to have dialect-specific arguments with defaults and constructor validation. The :class:`.DialectKWArgs` interacts with the :attr:`.DefaultDialect.construct_arguments` present on a dialect. .. seealso:: :attr:`.DefaultDialect.construct_arguments` ctj|}|tjd|z||vri||<||||<dS)aAdd a new kind of dialect-specific keyword argument for this class. E.g.:: Index.argument_for("mydialect", "length", None) some_index = Index('a', 'b', mydialect_length=5) The :meth:`.DialectKWArgs.argument_for` method is a per-argument way adding extra arguments to the :attr:`.DefaultDialect.construct_arguments` dictionary. This dictionary provides a list of argument names accepted by various schema-level constructs on behalf of a dialect. New dialects should typically specify this dictionary all at once as a data member of the dialect class. The use case for ad-hoc addition of argument names is typically for end-user code that is also using a custom compilation scheme which consumes the additional arguments. :param dialect_name: name of a dialect. The dialect must be locatable, else a :class:`.NoSuchModuleError` is raised. The dialect must also include an existing :attr:`.DefaultDialect.construct_arguments` collection, indicating that it participates in the keyword-argument validation and default system, else :class:`.ArgumentError` is raised. If the dialect does not include this collection, then any keyword argument can be specified on behalf of this dialect already. All dialects packaged within SQLAlchemy include this collection, however for third party dialects, support may vary. :param argument_name: name of the parameter. :param default: default value of the parameter. .. versionadded:: 0.9.4 NzRDialect '%s' does have keyword-argument validation and defaults enabled configured)rm _kw_registryrrJ)clsrZ argument_namedefaultconstruct_arg_dictionarys r argument_forzDialectKWArgs.argument_forskP$1#=l#K # +#=?KL  . . .,. $S )7> %m444rc t|S)a9A collection of keyword arguments specified as dialect-specific options to this construct. The arguments are present here in their original ``_`` format. Only arguments that were actually passed are included; unlike the :attr:`.DialectKWArgs.dialect_options` collection, which contains all options known by this dialect including defaults. The collection is also writable; keys are accepted of the form ``_`` where the value will be assembled into the list of options. .. versionadded:: 0.9.2 .. versionchanged:: 0.9.4 The :attr:`.DialectKWArgs.dialect_kwargs` collection is now writable. .. seealso:: :attr:`.DialectKWArgs.dialect_options` - nested dictionary form )r3rs rdialect_kwargszDialectKWArgs.dialect_kwargss0t$$$rc|jS)z4A synonym for :attr:`.DialectKWArgs.dialect_kwargs`.)rvrs rrzDialectKWArgs.kwargss ""rzsqlalchemy.dialectscp|j|}|jdSt|jSr)registryloadconstruct_argumentsdict)dialectsrZ dialect_clss r_kw_reg_for_dialectz!DialectKWArgs._kw_reg_for_dialects7',,\::  * 24K3444rctj|}t}||jddin@t |jjD]&}||vr |j||'|S)N*)rmror^raupdatereversed __class____mro__)rrZrsdrps r_kw_reg_for_dialect_clsz%DialectKWArgs._kw_reg_for_dialect_clss#0#=l#K    # + K  T{ + + + + 677 F F222K&&'?'DEEErcXtjtj|jS)aA collection of keyword arguments specified as dialect-specific options to this construct. This is a two-level nested registry, keyed to ```` and ````. For example, the ``postgresql_where`` argument would be locatable as:: arg = my_object.dialect_options['postgresql']['where'] .. versionadded:: 0.9.2 .. seealso:: :attr:`.DialectKWArgs.dialect_kwargs` - flat dictionary form )r PopulateDictportable_instancemethodrrs rrEzDialectKWArgs.dialect_optionss*&  ()E F F   rc |sdS|D]}tjd|}|std|z|dd\}} |j|}d|vr&||vr"t jd|d|d|j||||<#t j$ratj d |d |tx|j|<}|j ddi|||j|<YwxYwdS) Nz ^(.+?)_(.+)$zGAdditional arguments should be named _, got '%s'rrrz Argument z is not accepted by dialect z on behalf of zCan't validate argument z,; can't locate any SQLAlchemy dialect named )rematch TypeErrorgrouprErrJrrFrwarnr^rarrR)rrkmrZarg_namersrs r_validate_dialect_kwargsz&DialectKWArgs._validate_dialect_kwargss  F C CA++A ?ABC&'WWQ]] "L( C+/+? +M(777 (@@@++11lllDNN< :@,X66)( 6 6 6 qq,,( :I9J9JJ$\2Q ""C;///,21I))) 6 C Cs BA-C?>C?N)rr r!r" classmethodrtrmemoized_propertyrvpropertyr dependenciesrrrorrErrrrrmrms  /?/?[/?b %%%2##X#T,--55.-5 %4$%899L       ,%C%C%C%C%CrrmceZdZdZdZdS) GenerativezRAllow a ClauseElement to generate itself via the @_generative decorator. c|j|j}|j|_|Sr)r__new____dict__copy)rss rr-zGenerative._generateGs3 N " "4> 2 2]'')) rN)rr r!r"r-rrrrrAs- rrcveZdZdZdZejZdZe dZ dZ dZ dZ edZdS) ExecutablezMark a :class:`_expression.ClauseElement` as supporting execution. :class:`.Executable` is a superclass for all "statement" types of objects, including :func:`select`, :func:`delete`, :func:`update`, :func:`insert`, :func:`text`. TNc d|vrtjdd|vrtjd|j||_dS)aSet non-SQL options for the statement which take effect during execution. Execution options can be set on a per-statement or per :class:`_engine.Connection` basis. Additionally, the :class:`_engine.Engine` and ORM :class:`~.orm.query.Query` objects provide access to execution options which they in turn configure upon connections. The :meth:`execution_options` method is generative. A new instance of this statement is returned that contains the options:: statement = select([table.c.x, table.c.y]) statement = statement.execution_options(autocommit=True) Note that only a subset of possible execution options can be applied to a statement - these include "autocommit" and "stream_results", but not "isolation_level" or "compiled_cache". See :meth:`_engine.Connection.execution_options` for a full list of possible options. .. seealso:: :meth:`_engine.Connection.execution_options` :meth:`_query.Query.execution_options` :meth:`.Executable.get_execution_options` isolation_levelz'isolation_level' execution option may only be specified on Connection.execution_options(), or per-engine using the isolation_level argument to create_engine().compiled_cachezm'compiled_cache' execution option may only be specified on Connection.execution_options(), not per statement.N)rrJ_execution_optionsrd)rr0s rexecution_optionszExecutable.execution_optionsZssB  " "#/  r ! !#H #'"9"?"?"C"Crc|jS)zGet the non-SQL options which will take effect during execution. .. versionadded:: 1.3 .. seealso:: :meth:`.Executable.execution_options` )rrs rget_execution_optionsz Executable.get_execution_optionss &&rc|j}|4t|d|jj}d|z}t j|||||S)z.Compile and execute this :class:`.Executable`.N descriptionzThis %s is not directly bound to a Connection or Engine. Use the .execute() method of a Connection or Engine to execute this construct.)bindgetattrrrrUnboundExecutionError_execute_clauseelement)r multiparamsrelabelmsgs rexecutezExecutable.executesa I 9D-1HIIE-/45  +C00 0''k6BBBrc@|j|i|S)znCompile and execute this :class:`.Executable`, returning the result's scalar representation. )rscalar)rrrs rrzExecutable.scalars' t|[3F33::<<.s***SVV***r)reprrs r__str__zColumnCollection.__str__s**T***+++rcndj|vr<jjkr,|j}|j|jkr||j|j=j|jvr|jj|jj< fd|jD|jdd<dS|jdS)aAdd the given column to this collection, removing unaliased versions of this column as well as existing columns with the same key. E.g.:: t = Table('sometable', metadata, Column('col1', Integer)) t.columns.replace(Column('col1', Integer, key='columnone')) will remove the original 'col1' from the collection, and add the new column under the name 'columnname'. Used by schema.Column to override columns during table reflection. Nc g|] }|urn| Srr)r&rcolumn remove_cols rr(z,ColumnCollection.replace..s2$$$56!z//q$$$r)namer?_datarappend)rrotherrs ` @rreplacezColumnCollection.replaces  ;$  6:#<#<%EzUY&&" Juy) : # #FJ/J!' 6:  !$$$$$:>:K$$$D aaa    $ $V , , , , ,rcP|jstjd|||j<dS)zAdd a column to this collection. The key attribute of the column will be used as the hash key for this dictionary. z-Can't add unnamed column to column collectionN)r?rrJrrs rrzColumnCollection.add s:z #? "VZrctrrrhs rrNzColumnCollection.__delitem__!###rctrr)rr?r5s rrzColumnCollection.__setattr__rrc 6||vrp||}||urdS||s-tjd|dt|ddd|dtj|d|j|||j|<dS)NzColumn z on table tablez being replaced by zG, which has the same key. Consider use_labels for select() statements. proxy_set) shares_lineagerrrrresetrrr)rr?rKexistings rrLzColumnCollection.__setitem__ s $;; CyH5  **511  ssGHgt<<<.As%   AVOOAOOOr)rr?rrs `rremovezColumnCollection.remove?sL Jvz "    (   !!!rct|}t|j|jfd|D|jd|DdS)Nc3*K|] \}}|v |VdSrr)r&rr all_col_sets rrSz*ColumnCollection.update..Hs:! ! %a{&:&:A&:&:&:&:! ! rc3$K|] \}}||fV dSrr)r&rrs rrSz*ColumnCollection.update..Ks*::5!*::::::rlistrcrextendrrriter_colsrs @rrzColumnCollection.updateEsE{{$+,,    ! ! ! ! "! ! !     ::T::::::::rct|}t|j|jfd|D|jd|DdS)Nc3$K|] }|v|V dSrr)r&rrs rrSz*ColumnCollection.extend..Ps- I IqA[4H4H4H4H4H4H I Irc3(K|] }|j|fVdSr)r?rs rrSz*ColumnCollection.extend..Qs(3315!*333333rrrs @rrzColumnCollection.extendMsuE{{$+,,    I I I ID I I IIII 33d33333333rNsqlalchemy.sql.elementscg}t|d|D]:}|jD]0}||r|||k1;|j|Sr)rrrrand_rr+rlrlocals r__eq__zColumnCollection.__eq__Usw 66 ) )A* ) )##E**)HHQ%Z((( )x}a  rct|tjstjdtj||S)Nz'__contains__ requires a string argument) isinstancer string_typesrrJOrderedProperties __contains__rrs rr zColumnCollection.__contains__^sC%!233 O#$MNN N%224???rc |j|jdS)Nrrrrs r __getstate__zColumnCollection.__getstate__csT5FGGGrct|d|dt|d|ddS)Nrr)rr)rstates r __setstate__zColumnCollection.__setstate__fsA4%.9994~1FGGGGGrc.|t|jvSr)rcrrcols rcontains_columnz ColumnCollection.contains_columnjsc$+,,,,rc6t|j|jSr)ImmutableColumnCollectionrrrs r as_immutablezColumnCollection.as_immutablems(T5FGGGr)rr r!r" __slots__r6rrrrNrrLrrrr__hash__rrrr rrrr __classcell__)rs@rrrsjI ,,, - - -D " " "$$$$$$   8$$$   ;;;444 HT011!!21!@@@ HHHHHH---HHHHHHHrrc0eZdZdZejjxZZdS)rc~tj||t|d|dSr)rImmutablePropertiesr6rr)rdata all_columnss rr6z"ImmutableColumnCollection.__init__rs9  ))$5554=====rN) rr r!r6rr  _immutablerrrrrrrqs/>>>.99FVVVrrcXeZdZdZdZdZejddZdZ dS) ColumnSetc ||vSrrrs rrzColumnSet.contains_columnzs d{rc:|D]}||dSr)r)rrrs rrzColumnSet.extend}s,  C HHSMMMM  rc@t|t|zSr)rr s r__add__zColumnSet.__add__sDzzDKK''rrcg}|D]5}|D]0}||r|||k16|j|Sr)rrrrs rrzColumnSet.__eq__sh  ) )A ) )##E**)HHQ%Z((( )x}a  rcNttd|DS)Nc3K|]}|VdSrr)r&xs rrSz%ColumnSet.__hash__..s"**!******r)hashtuplers rrzColumnSet.__hash__s'E**T*****+++rN) rr r!rrr)rrrrrrrr%r%ysz(((T011!!21!,,,,,rr%c |j}|sV|jj}t|dt|dd}|r|d|}nd|z}|d|z}t j||S)Nfullnamerz object z %s objectzm%s is not bound to an Engine or Connection. Execution can not proceed without a database to execute against.)rrrrrr) schemaitemrrrritems r_bind_or_errorr4s ?D -#,  GJ$E$E    &%)TT551DD%D ;!"  ',,, Krr) r"r)rvisitorsrrrsymbolrr rr r% decoratorr1collections_abcMutableMappingr3r^rmrrrrr rr rordered_column_setr%r4rrrr<s  ######4;122 X          MMM9 9 9 9 9 d*99 9 9 x$$$$$d*9$$$@oCoCoCoCoCFoCoCoCd        ppppppppf88888888"44444M444 WHWHWHWHWHt-WHWHWHt::::: 8:J:::,,,,,',,,0r