
    KiID                    p   S SK Jr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S S	KJ
r
  S
SKJr  S
SKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  \	(       a0  SSKJr  SSKJr  SSKJ r   SSKJ!r!  SSK"J#r#  SSK$J%r%  SSKJ&r&  SSKJ'r'  \
" S\S 9r( " S! S"\RB                  \(   5      r) " S# S$\5      r*S% r+ " S& S'\RX                  \(   5      r- " S( S)\-5      r. " S* S+\-5      r/ " S, S-\-5      r0 " S. S/\-5      r1 " S0 S1\-5      r2 " S2 S3\-5      r3g4)5    )annotations)Any)Iterable)List)Optional)overload)Tuple)TYPE_CHECKING)TypeVar   )types)ARRAY   )	coercions)elements)
expression)	functions)roles)schema)ColumnCollectionConstraint)TEXT)InternalTraversal)_ColumnExpressionArgument)_DDLColumnArgument)ClauseElement)ColumnElement)OperatorType)
FromClause)_CloneCallableType)_TraverseInternalsType_T)boundc                  *   \ rS rSr% SrS rSrS\R                  4S\R                  4S\R                  4/r
S\S'   \    SS	 j5       r\    SS
 j5       r    SS jr S   SS jjrSS jr\R"                  4     SS jjr\SS j5       rSrg)aggregate_order_by,   a  Represent a PostgreSQL aggregate order by expression.

E.g.::

    from sqlalchemy.dialects.postgresql import aggregate_order_by

    expr = func.array_agg(aggregate_order_by(table.c.a, table.c.b.desc()))
    stmt = select(expr)

would represent the expression:

.. sourcecode:: sql

    SELECT array_agg(a ORDER BY b DESC) FROM table;

Similarly::

    expr = func.string_agg(
        table.c.a, aggregate_order_by(literal_column("','"), table.c.a)
    )
    stmt = select(expr)

Would represent:

.. sourcecode:: sql

    SELECT string_agg(a, ',' ORDER BY a) FROM table;

.. versionchanged:: 1.2.13 - the ORDER BY argument may be multiple terms

.. seealso::

    :class:`_functions.array_agg`


postgresqltargettypeorder_byr    _traverse_internalsc                    g N selfr'   r)   s      d/var/www/html/dynamic-report/venv/lib/python3.13/site-packages/sqlalchemy/dialects/postgresql/ext.py__init__aggregate_order_by.__init__Z       
     c                    g r,   r-   r.   s      r0   r1   r2   a   r3   r4   c                   [         R                  " [        R                  U5      U l        U R                  R
                  U l        [        U5      nU   US:X  a  [        S5      eUS:X  a.  [         R                  " [        R                  US   5      U l        g [        R                  " US[        R                  06U l        g )Nr   z)at least one ORDER BY element is requiredr   _literal_as_text_role)r   expectr   ExpressionElementRoler'   r(   len	TypeErrorr)   r   
ClauseList)r/   r'   r)   _lobs       r0   r1   r2   h   s    
 &/%5%5''&
 KK$$	8}19GHHQY%,,++Xa[DM %//161L1LDMr4   Nc                    U $ r,   r-   )r/   againsts     r0   
self_groupaggregate_order_by.self_group   s	     r4   c                2    U R                   U R                  4$ r,   r'   r)   )r/   kwargss     r0   get_childrenaggregate_order_by.get_children   s    {{DMM))r4   c                d    U" U R                   40 UD6U l         U" U R                  40 UD6U l        g r,   rC   )r/   clonekws      r0   _copy_internals"aggregate_order_by._copy_internals   s.     DKK.2.dmm2r2r4   c                \    U R                   R                  U R                  R                  -   $ r,   )r'   _from_objectsr)   )r/   s    r0   rM    aggregate_order_by._from_objects   s!    {{((4==+F+FFFr4   )r)   r'   r(   )r'   zColumnElement[_T]r)   _ColumnExpressionArgument[Any])r'   z_ColumnExpressionArgument[_T]r)   rO   r,   )r?   zOptional[OperatorType]returnr   )rD   r   rP   zIterable[ClauseElement])rH   r   rI   r   rP   None)rP   zList[FromClause])__name__
__module____qualname____firstlineno____doc____visit_name__stringify_dialectr   dp_clauseelementdp_typer*   __annotations__r   r1   r@   rE   r   _clonerJ   propertyrM   __static_attributes__r-   r4   r0   r$   r$   ,   s   "H *N$	$556	"**+	&7783/  ! 2  - 2 - 20 15-	
* +3//3'3AD3	3 G Gr4   r$   c                     ^  \ rS rSrSrSrSrSrSr\	R                  " SSS	5            SS
 j5       rU 4S jrSS jrSrU =r$ )ExcludeConstraint   zA table-level EXCLUDE constraint.

Defines an EXCLUDE constraint as described in the `PostgreSQL
documentation`__.

__ https://www.postgresql.org/docs/current/static/sql-createtable.html#SQL-CREATETABLE-EXCLUDE

exclude_constraintNFr&   wherez:class:`.ExcludeConstraint`z$:paramref:`.ExcludeConstraint.where`c                   / n/ n0 U l         [        U6 u  pV[        [        R                  " [        R
                  U5      U5       HR  u  u  pxpnU
b  UR                  U
5        Ub  UR                  OU	nUb  XR                   U'   UR                  X|U45        MT     X@l        [        R                  " U /UQ7UR                  S5      UR                  S5      UR                  S5      S.6  UR                  SS5      U l        UR                  S5      nUb*  [        R                  " [        R                  U5      U l        UR                  S	0 5      U l        g)
a
  
Create an :class:`.ExcludeConstraint` object.

E.g.::

    const = ExcludeConstraint(
        (Column("period"), "&&"),
        (Column("group"), "="),
        where=(Column("group") != "some group"),
        ops={"group": "my_operator_class"},
    )

The constraint is normally embedded into the :class:`_schema.Table`
construct
directly, or added later using :meth:`.append_constraint`::

    some_table = Table(
        "some_table",
        metadata,
        Column("id", Integer, primary_key=True),
        Column("period", TSRANGE()),
        Column("group", String),
    )

    some_table.append_constraint(
        ExcludeConstraint(
            (some_table.c.period, "&&"),
            (some_table.c.group, "="),
            where=some_table.c.group != "some group",
            name="some_table_excl_const",
            ops={"group": "my_operator_class"},
        )
    )

The exclude constraint defined in this example requires the
``btree_gist`` extension, that can be created using the
command ``CREATE EXTENSION btree_gist;``.

:param \*elements:

  A sequence of two tuples of the form ``(column, operator)`` where
  "column" is either a :class:`_schema.Column` object, or a SQL
  expression element (e.g. ``func.int8range(table.from, table.to)``)
  or the name of a column as string, and "operator" is a string
  containing the operator to use (e.g. `"&&"` or `"="`).

  In order to specify a column name when a :class:`_schema.Column`
  object is not available, while ensuring
  that any necessary quoting rules take effect, an ad-hoc
  :class:`_schema.Column` or :func:`_expression.column`
  object should be used.
  The ``column`` may also be a string SQL expression when
  passed as :func:`_expression.literal_column` or
  :func:`_expression.text`

:param name:
  Optional, the in-database name of this constraint.

:param deferrable:
  Optional bool.  If set, emit DEFERRABLE or NOT DEFERRABLE when
  issuing DDL for this constraint.

:param initially:
  Optional string.  If set, emit INITIALLY <value> when issuing DDL
  for this constraint.

:param using:
  Optional string.  If set, emit USING <index_method> when issuing DDL
  for this constraint. Defaults to 'gist'.

:param where:
  Optional SQL expression construct or literal SQL string.
  If set, emit WHERE <predicate> when issuing DDL
  for this constraint.

:param ops:
  Optional dictionary.  Used to define operator classes for the
  elements; works the same way as that of the
  :ref:`postgresql_ops <postgresql_operator_classes>`
  parameter specified to the :class:`_schema.Index` construct.

  .. versionadded:: 1.3.21

  .. seealso::

    :ref:`postgresql_operator_classes` - general description of how
    PostgreSQL operator classes are specified.

Nname
deferrable	initially)re   rf   rg   usinggistrc   ops)	operatorszipr    expect_col_expression_collectionr   DDLConstraintColumnRoleappendre   _render_exprsr   r1   getrh   r8   StatementOptionRolerc   rj   )r/   r   rI   columnsrender_exprsexpressionsrk   exprcolumnstrnameadd_elementoperatorre   rc   s                 r0   r1   ExcludeConstraint.__init__   s@   B !$h>A66--{ 	?
:0T7( &{+"("46;;'D'/t$X 67?
" *"++	
	
 vvl+ff[)	
 VVGV,
w"))%*C*CUKDJ66%$r4   c           	        > [         TU ]  U5        U R                   VVVs/ s H/  u  p4n[        U[        5      (       d  UOUR
                  U   UU4PM1     snnnU l        g s  snnnf r,   )super_set_parentrp   
isinstancestrc)r/   tablerI   rv   re   rz   	__class__s         r0   r~   ExcludeConstraint._set_parent+  sg    E" *.););
 *<$H	 'tS11uwwt}
 *<
 
s   6A"c           
     v   U R                    VVVs/ s H)  u  p4n[        R                  " X0R                  U5      U4PM+     nnnnU R                  " UU R
                  U R                  U R                  U R                  U R                  S.6nUR                  R                  U R                  5        U$ s  snnnf )N)re   rf   rg   rc   rh   )rp   r   _copy_expressionparentr   re   rf   rg   rc   rh   dispatch_update)r/   target_tablerI   rv   _rz   r   r   s           r0   _copyExcludeConstraint._copy7  s     &*%7%7

 &8! ''kk<H &8 	 
 NNnn****
 	


4==)!
s   0B4)rp   rk   rj   rh   rc   )r   zTuple[_DDLColumnArgument, str]rI   r   rP   rQ   r,   )rR   rS   rT   rU   rV   rW   rc   inherit_cachecreate_drop_stringify_dialectr   _document_text_coercionr1   r~   r   r^   __classcell__r   s   @r0   r`   r`      sr     *NEM$0!%%%.
A%7A%?BA%	A%
A%F

 r4   r`   c                 T    [         US'   [        R                  R                  " U 0 UD6$ )zPostgreSQL-specific form of :class:`_functions.array_agg`, ensures
return type is :class:`_postgresql.ARRAY` and not
the plain :class:`_types.ARRAY`, unless an explicit ``type_``
is passed.

_default_array_type)r   r   func	array_agg)argrI   s     r0   r   r   K  s)     !&B>>##S/B//r4   c                  ,   ^  \ rS rSrSrU 4S jrSrU =r$ )_regconfig_fniV  Tc                  > [        U5      n[        U5      S:  aR  [        R                  " [        R
                  UR                  S5      [        U SS 5      U [        R                  S9nU/nO/ nU Vs/ s H3  n[        R                  " [        R
                  U[        U SS 5      U S9PM5     nn[        TU ],  " X5-   0 UD6  g s  snf )Nr   r   re   )re   apply_propagate_attrstype_re   r   )listr:   r   r8   r   r9   popgetattrr   	REGCONFIGr}   r1   )r/   argsrD   initial_argr   
addtl_argsr   s         r0   r1   _regconfig_fn.__init__Y  s    Dzt9q=#**++T640&*ooK '-KK 
  ++T640&*	  	 
 	;3??
s   4:Cr-   )rR   rS   rT   rU   r   r1   r^   r   r   s   @r0   r   r   V  s    M@ @r4   r   c                  4    \ rS rSrSrSr\R                  rSr	g)to_tsvectoris  a  The PostgreSQL ``to_tsvector`` SQL function.

This function applies automatic casting of the REGCONFIG argument
to use the :class:`_postgresql.REGCONFIG` datatype automatically,
and applies a return type of :class:`_postgresql.TSVECTOR`.

Assuming the PostgreSQL dialect has been imported, either by invoking
``from sqlalchemy.dialects import postgresql``, or by creating a PostgreSQL
engine using ``create_engine("postgresql...")``,
:class:`_postgresql.to_tsvector` will be used automatically when invoking
``sqlalchemy.func.to_tsvector()``, ensuring the correct argument and return
type handlers are used at compile and execution time.

.. versionadded:: 2.0.0rc1

Tr-   N)
rR   rS   rT   rU   rV   r   r   TSVECTORr(   r^   r-   r4   r0   r   r   s  s    " M>>Dr4   r   c                  4    \ rS rSrSrSr\R                  rSr	g)
to_tsqueryi  a  The PostgreSQL ``to_tsquery`` SQL function.

This function applies automatic casting of the REGCONFIG argument
to use the :class:`_postgresql.REGCONFIG` datatype automatically,
and applies a return type of :class:`_postgresql.TSQUERY`.

Assuming the PostgreSQL dialect has been imported, either by invoking
``from sqlalchemy.dialects import postgresql``, or by creating a PostgreSQL
engine using ``create_engine("postgresql...")``,
:class:`_postgresql.to_tsquery` will be used automatically when invoking
``sqlalchemy.func.to_tsquery()``, ensuring the correct argument and return
type handlers are used at compile and execution time.

.. versionadded:: 2.0.0rc1

Tr-   N
rR   rS   rT   rU   rV   r   r   TSQUERYr(   r^   r-   r4   r0   r   r         " M==Dr4   r   c                  4    \ rS rSrSrSr\R                  rSr	g)plainto_tsqueryi  a  The PostgreSQL ``plainto_tsquery`` SQL function.

This function applies automatic casting of the REGCONFIG argument
to use the :class:`_postgresql.REGCONFIG` datatype automatically,
and applies a return type of :class:`_postgresql.TSQUERY`.

Assuming the PostgreSQL dialect has been imported, either by invoking
``from sqlalchemy.dialects import postgresql``, or by creating a PostgreSQL
engine using ``create_engine("postgresql...")``,
:class:`_postgresql.plainto_tsquery` will be used automatically when
invoking ``sqlalchemy.func.plainto_tsquery()``, ensuring the correct
argument and return type handlers are used at compile and execution time.

.. versionadded:: 2.0.0rc1

Tr-   Nr   r-   r4   r0   r   r     r   r4   r   c                  4    \ rS rSrSrSr\R                  rSr	g)phraseto_tsqueryi  a  The PostgreSQL ``phraseto_tsquery`` SQL function.

This function applies automatic casting of the REGCONFIG argument
to use the :class:`_postgresql.REGCONFIG` datatype automatically,
and applies a return type of :class:`_postgresql.TSQUERY`.

Assuming the PostgreSQL dialect has been imported, either by invoking
``from sqlalchemy.dialects import postgresql``, or by creating a PostgreSQL
engine using ``create_engine("postgresql...")``,
:class:`_postgresql.phraseto_tsquery` will be used automatically when
invoking ``sqlalchemy.func.phraseto_tsquery()``, ensuring the correct
argument and return type handlers are used at compile and execution time.

.. versionadded:: 2.0.0rc1

Tr-   Nr   r-   r4   r0   r   r     r   r4   r   c                  4    \ rS rSrSrSr\R                  rSr	g)websearch_to_tsqueryi  a  The PostgreSQL ``websearch_to_tsquery`` SQL function.

This function applies automatic casting of the REGCONFIG argument
to use the :class:`_postgresql.REGCONFIG` datatype automatically,
and applies a return type of :class:`_postgresql.TSQUERY`.

Assuming the PostgreSQL dialect has been imported, either by invoking
``from sqlalchemy.dialects import postgresql``, or by creating a PostgreSQL
engine using ``create_engine("postgresql...")``,
:class:`_postgresql.websearch_to_tsquery` will be used automatically when
invoking ``sqlalchemy.func.websearch_to_tsquery()``, ensuring the correct
argument and return type handlers are used at compile and execution time.

.. versionadded:: 2.0.0rc1

Tr-   Nr   r-   r4   r0   r   r     r   r4   r   c                  4   ^  \ rS rSrSrSr\rU 4S jrSr	U =r
$ )ts_headlinei  a  The PostgreSQL ``ts_headline`` SQL function.

This function applies automatic casting of the REGCONFIG argument
to use the :class:`_postgresql.REGCONFIG` datatype automatically,
and applies a return type of :class:`_types.TEXT`.

Assuming the PostgreSQL dialect has been imported, either by invoking
``from sqlalchemy.dialects import postgresql``, or by creating a PostgreSQL
engine using ``create_engine("postgresql...")``,
:class:`_postgresql.ts_headline` will be used automatically when invoking
``sqlalchemy.func.ts_headline()``, ensuring the correct argument and return
type handlers are used at compile and execution time.

.. versionadded:: 2.0.0rc1

Tc                F  > [        U5      n[        U5      S:  a  SnOQ[        US   [        R                  5      (       a-  US   R
                  R                  [        R                  L a  SnOSnU(       aR  [        R                  " [        R                  UR                  S5      U [        U SS 5      [        R                  S9nU/nO/ nU Vs/ s H3  n[        R                  " [        R                  U[        U SS 5      U S9PM5     nn[         TU ]D  " XF-   0 UD6  g s  snf )	N   Fr   Tr   re   )r   re   r   r   )r   r:   r   r   r   r(   _type_affinityr   r   r   r8   r   r9   r   r   r   r}   r1   )r/   r   rD   has_regconfigr   r   r   r   s          r0   r1   ts_headline.__init__  s   Dz t9q=!MtAw 6 677Q++u}}< "M M#**++&*T640ooK '-KK 
  ++T640&*	  	 
 	;3??
s   :Dr-   )rR   rS   rT   rU   rV   r   r   r(   r1   r^   r   r   s   @r0   r   r     s     " MD&@ &@r4   r   N)4
__future__r   typingr   r   r   r   r   r	   r
   r    r   arrayr   sqlr   r   r   r   r   r   
sql.schemar   sql.sqltypesr   sql.visitorsr   sql._typingr   r   sql.elementsr   r   sql.operatorsr   sql.selectabler   r   r    r!   r$   r`   r   GenericFunctionr   r   r   r   r   r   r   r-   r4   r0   <module>r      s    #                  4   -81---,26TcG11"5 cGLv2 vr0@I--b1 @:- , ,m ,} ,= ,;@- ;@r4   