+
    }¯³j»9  ã                   óâ   € R t ^ RIt^ RIHt ]P
                  ! 4       t ! R R4      t ! R R]4      t ! R R]4      t	 ! R	 R
]4      t
 ! R R]4      t ! R R]4      t]	! R4      t]	! R4      tR# )zSQL composition utility module
N)Ú
extensionsc                   óN   a € ] tR t^#t o RtR tR tR tR tR t	R t
R tR	tV tR
# )Ú
Composablea  
Abstract base class for objects that can be used to compose an SQL string.

`!Composable` objects can be passed directly to `~cursor.execute()`,
`~cursor.executemany()`, `~cursor.copy_expert()` in place of the query
string.

`!Composable` objects can be joined using the ``+`` operator: the result
will be a `Composed` instance containing the objects joined. The operator
``*`` is also supported with an integer argument: the result is a
`!Composed` instance containing the left argument repeated as many times as
requested.
c                ó   € Wn         R # ©N©Ú_wrapped)ÚselfÚwrappeds   &&ÚM/home/luca/screen-checking/.venv/lib/python3.14/site-packages/psycopg2/sql.pyÚ__init__ÚComposable.__init__1   s   € ØŽó    c                óP   € V P                   P                   R V P                  : R2# )Ú(Ú))Ú	__class__Ú__name__r   ©r	   s   &r   Ú__repr__ÚComposable.__repr__4   s%   € Ø—.‘.×)Ñ)Ð*¨!¨D¯M©MÑ+<¸AÐ>Ð>r   c                ó   € \         h)a2  
Return the string value of the object.

:param context: the context to evaluate the string into.
:type context: `connection` or `cursor`

The method is automatically invoked by `~cursor.execute()`,
`~cursor.executemany()`, `~cursor.copy_expert()` if a `!Composable` is
passed instead of the query string.
)ÚNotImplementedError©r	   Úcontexts   &&r   Ú	as_stringÚComposable.as_string7   s
   € ô "Ð!r   c                óÆ   € \        V\        4      '       d   \        V .4      V,           # \        V\        4      '       d   \        V .4      \        V.4      ,           # \        # r   )Ú
isinstanceÚComposedr   ÚNotImplemented©r	   Úothers   &&r   Ú__add__ÚComposable.__add__D   sM   € Ü�eœX×&Ò&Ü˜T˜FÓ# eÕ+Ð+Ü�eœZ×(Ò(Ü˜T˜FÓ#¤h°¨wÓ&7Õ7Ð7ä!Ð!r   c                ó(   € \        V .V,          4      # r   )r   )r	   Úns   &&r   Ú__mul__ÚComposable.__mul__L   s   € Ü˜˜ �
Ó#Ð#r   c                óp   € \        V 4      \        V4      J ;'       d    V P                  VP                  8H  # r   )Útyper   r!   s   &&r   Ú__eq__ÚComposable.__eq__O   s*   € Ü�D‹zœT %›[Ð(×LÐL¨T¯]©]¸e¿n¹nÑ-LÐLr   c                ó.   € V P                  V4      '       * # r   )r+   r!   s   &&r   Ú__ne__ÚComposable.__ne__R   s   € Ø—;‘;˜uÓ%Ô%Ð%r   r   N)r   Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r#   r'   r+   r.   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r   r   #   s3   ø‡ € ñò ò?ò"ò"ò$òM÷&ð &r   r   c                   ó^   a a€ ] tR t^Vt oRtV 3R lt]R 4       tR tR t	R t
R tRtVtV ;t# )	r   aì  
A `Composable` object made of a sequence of `!Composable`.

The object is usually created using `!Composable` operators and methods.
However it is possible to create a `!Composed` directly specifying a
sequence of `!Composable` as arguments.

Example::

    >>> comp = sql.Composed(
    ...     [sql.SQL("insert into "), sql.Identifier("table")])
    >>> print(comp.as_string(conn))
    insert into "table"

`!Composed` objects are iterable (so they can be used in `SQL.join` for
instance).
c                óª   <€ . pV F:  p\        V\        4      '       g   \        R V: R24      hVP                  V4       K<  	  \        SV `  V4       R# )z*Composed elements must be Composable, got z insteadN)r   r   Ú	TypeErrorÚappendÚsuperr   )r	   Úseqr
   Úir   s   &&  €r   r   ÚComposed.__init__h   sU   ø€ ØˆÛˆAÜ˜a¤×,Ò,ÜØ@ÀÁÀXÐNóPð Pà�N‰N˜1Öñ	 ô 	‰Ñ˜Ö!r   c                ó,   € \        V P                  4      # )z+The list of the content of the `!Composed`.)Úlistr   r   s   &r   r=   ÚComposed.seqr   s   € ô �D—M‘MÓ"Ð"r   c                óŽ   € . pV P                    F#  pVP                  VP                  V4      4       K%  	  R P                  V4      # )Ú )r   r;   r   Újoin)r	   r   Úrvr>   s   &&  r   r   ÚComposed.as_stringw   s8   € ØˆØ—”ˆAØ�I‰I�a—k‘k 'Ó*Ö+ñ à�w‰w�r‹{Ðr   c                ó,   € \        V P                  4      # r   )Úiterr   r   s   &r   Ú__iter__ÚComposed.__iter__}   s   € Ü�D—M‘MÓ"Ð"r   c                óì   € \        V\        4      '       d'   \        V P                  VP                  ,           4      # \        V\        4      '       d   \        V P                  V.,           4      # \        # r   )r   r   r   r   r    r!   s   &&r   r#   ÚComposed.__add__€   sP   € Ü�eœX×&Ò&Ü˜DŸM™M¨E¯N©NÕ:Ó;Ð;Ü�eœZ×(Ò(Ü˜DŸM™M¨U¨GÕ3Ó4Ð4ä!Ð!r   c                óª   € \        V\        4      '       d   \        V4      pM!\        V\        4      '       g   \        R4      hVP	                  V 4      # )a<  
Return a new `!Composed` interposing the *joiner* with the `!Composed` items.

The *joiner* must be a `SQL` or a string which will be interpreted as
an `SQL`.

Example::

    >>> fields = sql.Identifier('foo') + sql.Identifier('bar')  # a Composed
    >>> print(fields.join(', ').as_string(conn))
    "foo", "bar"

z3Composed.join() argument must be a string or an SQL)r   ÚstrÚSQLr:   rE   )r	   Újoiners   &&r   rE   ÚComposed.joinˆ   sJ   € ô �fœc×"Ò"Ü˜“[‰FÜ˜F¤C×(Ò(ÜØEóGð Gð �{‰{˜4Ó Ð r   © )r   r0   r1   r2   r3   r   Úpropertyr=   r   rJ   r#   rE   r4   r5   Ú__classcell__©r   r7   s   @@r   r   r   V   s<   ù‡ € ñõ""ð ñ#ó ð#òò#ò"÷!ò !r   r   c                   óX   a a€ ] tR t^Ÿt oRtV 3R lt]R 4       tR tR t	R t
RtVtV ;t# )rP   a  
A `Composable` representing a snippet of SQL statement.

`!SQL` exposes `join()` and `format()` methods useful to create a template
where to merge variable parts of a query (for instance field or table
names).

The *string* doesn't undergo any form of escaping, so it is not suitable to
represent variable identifiers or values: you should only use it to pass
constant strings representing templates or snippets of SQL statements; use
other objects such as `Identifier` or `Literal` to represent variable
parts.

Example::

    >>> query = sql.SQL("select {0} from {1}").format(
    ...    sql.SQL(', ').join([sql.Identifier('foo'), sql.Identifier('bar')]),
    ...    sql.Identifier('table'))
    >>> print(query.as_string(conn))
    select "foo", "bar" from "table"
c                óh   <€ \        V\        4      '       g   \        R 4      h\        SV `  V4       R# )zSQL values must be stringsN)r   rO   r:   r<   r   )r	   Ústringr   s   &&€r   r   ÚSQL.__init__µ   s)   ø€ Ü˜&¤#×&Ò&ÜÐ8Ó9Ð9Ü‰Ñ˜Ö r   c                ó   € V P                   # )z(The string wrapped by the `!SQL` object.r   r   s   &r   rY   Ú
SQL.stringº   ó   € ð �}‰}Ðr   c                ó   € V P                   # r   r   r   s   &&r   r   ÚSQL.as_string¿   s   € Ø�}‰}Ðr   c                óJ  € . p^ p\         P                  V P                  4       Fò  w  rVrxV'       d   \        R4      hV'       d   \        R4      hV'       d   VP	                  \        V4      4       Vf   KT  VP                  4       '       d9   V'       d   \        R4      hVP	                  V\        V4      ,          4       RpK¢  V'       g2   Vf   \        R4      hVP	                  W,          4       V^,          pKÛ  VP	                  W&,          4       Kô  	  \        V4      # )až  
Merge `Composable` objects into a template.

:param `Composable` args: parameters to replace to numbered
    (``{0}``, ``{1}``) or auto-numbered (``{}``) placeholders
:param `Composable` kwargs: parameters to replace to named (``{name}``)
    placeholders
:return: the union of the `!SQL` string with placeholders replaced
:rtype: `Composed`

The method is similar to the Python `str.format()` method: the string
template supports auto-numbered (``{}``), numbered (``{0}``,
``{1}``...), and named placeholders (``{name}``), with positional
arguments replacing the numbered placeholders and keywords replacing
the named ones. However placeholder modifiers (``{0!r}``, ``{0:<10}``)
are not supported. Only `!Composable` objects can be passed to the
template.

Example::

    >>> print(sql.SQL("select * from {} where {} = %s")
    ...     .format(sql.Identifier('people'), sql.Identifier('id'))
    ...     .as_string(conn))
    select * from "people" where "id" = %s

    >>> print(sql.SQL("select * from {tbl} where {pkey} = %s")
    ...     .format(tbl=sql.Identifier('people'), pkey=sql.Identifier('id'))
    ...     .as_string(conn))
    select * from "people" where "id" = %s

z(no format specification supported by SQLz%no format conversion supported by SQLNz6cannot switch from automatic field numbering to manualz6cannot switch from manual field numbering to automatic)	Ú
_formatterÚparser   Ú
ValueErrorr;   rP   ÚisdigitÚintr   )	r	   ÚargsÚkwargsrF   ÚautonumÚpreÚnameÚspecÚconvs	   &*,      r   ÚformatÚ
SQL.formatÂ   sí   € ð@ ˆØˆÜ%/×%5Ñ%5°d·m±mÖ%DÑ!ˆC�tßÜ Ð!KÓLÐLßÜ Ð!HÓIÐIßØ—	‘	œ#˜c›(Ô#àŠ|Ùà�|‰|�~Š~ßÜ$ØPóRð Rà—	‘	˜$œs 4›y�/Ô*Ø’çØ’?Ü$ØPóRð Rà—	‘	˜$�-Ô(Ø˜1•’ð —	‘	˜&�,Ö'ñ5 &Eô8 ˜‹|Ðr   c                óà   € . p\        V4      p VP                  \        V4      4       V F%  pVP                  V 4       VP                  V4       K'  	  \	        V4      #   \         d     Li ; i)a¸  
Join a sequence of `Composable`.

:param seq: the elements to join.
:type seq: iterable of `!Composable`

Use the `!SQL` object's *string* to separate the elements in *seq*.
Note that `Composed` objects are iterable too, so they can be used as
argument for this method.

Example::

    >>> snip = sql.SQL(', ').join(
    ...     sql.Identifier(n) for n in ['foo', 'bar', 'baz'])
    >>> print(snip.as_string(conn))
    "foo", "bar", "baz"
)rI   r;   ÚnextÚStopIterationr   )r	   r=   rF   Úitr>   s   &&   r   rE   ÚSQL.join  si   € ð$ ˆÜ�#‹Yˆð	Ø�I‰I”d˜2“hÔó �Ø—	‘	˜$”Ø—	‘	˜!–ñ ô ˜‹|Ðøô ô 	Ùð	ús   �A ÁA-Á,A-rS   )r   r0   r1   r2   r3   r   rT   rY   r   rm   rE   r4   r5   rU   rV   s   @@r   rP   rP   Ÿ   s8   ù‡ € ñõ*!ð
 ñó ðòò>÷@ò r   rP   c                   ób   a a€ ] tR tRt oRtV 3R lt]R 4       t]R 4       tR t	R t
RtVtV ;t# )	Ú
Identifieri"  aÚ  
A `Composable` representing an SQL identifier or a dot-separated sequence.

Identifiers usually represent names of database objects, such as tables or
fields. PostgreSQL identifiers follow `different rules`__ than SQL string
literals for escaping (e.g. they use double quotes instead of single).

.. __: https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#         SQL-SYNTAX-IDENTIFIERS

Example::

    >>> t1 = sql.Identifier("foo")
    >>> t2 = sql.Identifier("ba'r")
    >>> t3 = sql.Identifier('ba"z')
    >>> print(sql.SQL(', ').join([t1, t2, t3]).as_string(conn))
    "foo", "ba'r", "ba""z"

Multiple strings can be passed to the object to represent a qualified name,
i.e. a dot-separated sequence of identifiers.

Example::

    >>> query = sql.SQL("select {} from {}").format(
    ...     sql.Identifier("table", "field"),
    ...     sql.Identifier("schema", "table"))
    >>> print(query.as_string(conn))
    select "table"."field" from "schema"."table"

c                ó    <€ V'       g   \        R 4      hV F$  p\        V\        4      '       d   K  \        R4      h	  \        SV `  V4       R# )zIdentifier cannot be emptyz$SQL identifier parts must be stringsN)r:   r   rO   r<   r   )r	   ÚstringsÚsr   s   &* €r   r   ÚIdentifier.__init__A  sD   ø€ ßÜÐ8Ó9Ð9ãˆAÜ˜a¤×%Ô%ÜÐ FÓGÐGñ ô 	‰Ñ˜Ö!r   c                ó   € V P                   # )z5A tuple with the strings wrapped by the `Identifier`.r   r   s   &r   rw   ÚIdentifier.stringsK  r]   r   c                ór   € \        V P                  4      ^8X  d   V P                  ^ ,          # \        R4      h)z0The string wrapped by the `Identifier`.
        z2the Identifier wraps more than one than one string)Úlenr   ÚAttributeErrorr   s   &r   rY   ÚIdentifier.stringP  s6   € ô ˆt�}‰}Ó Ô"Ø—=‘= Õ#Ð#ä ØDóFð Fr   c                óˆ   € V P                   P                   R RP                  \        \        V P
                  4      4       R2# )r   z, r   )r   r   rE   ÚmapÚreprr   r   s   &r   r   ÚIdentifier.__repr__Z  s6   € Ø—.‘.×)Ñ)Ð*¨!¨D¯I©I´c¼$ÀÇÁÓ6NÓ,OÐ+PÐPQÐRÐRr   c                óN   a€ R P                  V3R lV P                   4       4      # )Ú.c              3   óR   <"  € T F  p\         P                  ! VS4      x € K  	  R # 5ir   )ÚextÚquote_ident)Ú.0rx   r   s   & €r   Ú	<genexpr>Ú'Identifier.as_string.<locals>.<genexpr>^  s   øé € ÐK¹]¸œŸš¨¨7×3Ð3»]ùs   ƒ$')rE   r   r   s   &fr   r   ÚIdentifier.as_string]  s   ø€ Ø�x‰xÔK¸T¿]º]ÓKÓKÐKr   rS   )r   r0   r1   r2   r3   r   rT   rw   rY   r   r   r4   r5   rU   rV   s   @@r   ru   ru   "  sK   ù‡ € ñõ<"ð ñó ðð ñFó ðFòS÷Lò Lr   ru   c                   ó:   a € ] tR tRt o Rt]R 4       tR tRtV t	R# )ÚLiteralia  aT  
A `Composable` representing an SQL value to include in a query.

Usually you will want to include placeholders in the query and pass values
as `~cursor.execute()` arguments. If however you really really need to
include a literal value in the query you can use this object.

The string returned by `!as_string()` follows the normal :ref:`adaptation
rules <python-types-adaptation>` for Python objects.

Example::

    >>> s1 = sql.Literal("foo")
    >>> s2 = sql.Literal("ba'r")
    >>> s3 = sql.Literal(42)
    >>> print(sql.SQL(', ').join([s1, s2, s3]).as_string(conn))
    'foo', 'ba''r', 42

c                ó   € V P                   # )z%The object wrapped by the `!Literal`.r   r   s   &r   r
   ÚLiteral.wrappedu  r]   r   c                óî  € \        V\        P                  4      '       d   TpM8\        V\        P                  4      '       d   VP                  pM\	        R 4      h\        P
                  ! V P                  4      p\        VR4      '       d   VP                  V4       VP                  4       p\        V\        4      '       d1   VP                  \        P                  VP                  ,          4      pV# )z(context must be a connection or a cursorÚprepare)r   r‡   Ú
connectionÚcursorr:   Úadaptr   Úhasattrr’   Ú	getquotedÚbytesÚdecodeÚ	encodingsÚencoding)r	   r   ÚconnÚarF   s   &&   r   r   ÚLiteral.as_stringz  s¢   € ä�gœsŸ~™~×.Ò.Ø‰DÜ˜¤§¡×,Ò,Ø×%Ñ%‰DäÐFÓGÐGä�IŠI�d—m‘mÓ$ˆÜ�1�i× Ò Ø�I‰I�dŒOà�[‰[‹]ˆÜ�bœ%× Ò Ø—‘œ3Ÿ=™=¨¯©Õ7Ó8ˆBàˆ	r   rS   N)
r   r0   r1   r2   r3   rT   r
   r   r4   r5   r6   s   @r   rŽ   rŽ   a  s(   ø‡ € ñð& ñó ð÷ð r   rŽ   c                   óV   a a€ ] tR tRt oRtRV 3R llt]R 4       tR tR t	Rt
VtV ;t# )	ÚPlaceholderiŽ  aŸ  A `Composable` representing a placeholder for query parameters.

If the name is specified, generate a named placeholder (e.g. ``%(name)s``),
otherwise generate a positional placeholder (e.g. ``%s``).

The object is useful to generate SQL queries with a variable number of
arguments.

Examples::

    >>> names = ['foo', 'bar', 'baz']

    >>> q1 = sql.SQL("insert into table ({}) values ({})").format(
    ...     sql.SQL(', ').join(map(sql.Identifier, names)),
    ...     sql.SQL(', ').join(sql.Placeholder() * len(names)))
    >>> print(q1.as_string(conn))
    insert into table ("foo", "bar", "baz") values (%s, %s, %s)

    >>> q2 = sql.SQL("insert into table ({}) values ({})").format(
    ...     sql.SQL(', ').join(map(sql.Identifier, names)),
    ...     sql.SQL(', ').join(map(sql.Placeholder, names)))
    >>> print(q2.as_string(conn))
    insert into table ("foo", "bar", "baz") values (%(foo)s, %(bar)s, %(baz)s)

c                ó¦   <€ \        V\        4      '       d   R V9   d   \        RV: 24      hMVe   \        RV: 24      h\        SV `  V4       R# )r   zinvalid name: Nz%expected string or None as name, got )r   rO   rc   r:   r<   r   )r	   rj   r   s   &&€r   r   ÚPlaceholder.__init__©  sV   ø€ Ü�dœC× Ò Ø�dŒ{Ü  >°$±Ð!:Ó;Ð;ð ð ÒÜÐCÀDÁ8ÐLÓMÐMä‰Ñ˜Ör   c                ó   € V P                   # )zThe name of the `!Placeholder`.r   r   s   &r   rj   ÚPlaceholder.name³  r]   r   c                óž   € V P                   f   V P                  P                   R2# V P                  P                   RV P                   : R2# )Nz()r   r   )r   r   r   r   s   &r   r   ÚPlaceholder.__repr__¸  sG   € Ø�=‰=Ò Ø—n‘n×-Ñ-Ð.¨bÐ1Ð1à—n‘n×-Ñ-Ð.¨a°·±Ñ/@ÀÐBÐBr   c                óB   € V P                   e   RV P                    R2# R# )Nz%(z)sz%sr   r   s   &&r   r   ÚPlaceholder.as_string¾  s"   € Ø�=‰=Ò$Ø˜Ÿ™� bÐ)Ð)ár   rS   r   )r   r0   r1   r2   r3   r   rT   rj   r   r   r4   r5   rU   rV   s   @@r   r    r    Ž  s3   ù‡ € ñ÷4ð ñó ðòC÷ò r   r    ÚNULLÚDEFAULT)r3   rY   Úpsycopg2r   r‡   Ú	Formatterra   r   r   rP   ru   rŽ   r    r©   rª   rS   r   r   Ú<module>r­      sˆ   ðñó4 å &ð ×ÒÓ€
÷0&ñ 0&ôfF!ˆzô F!ôR@ˆ*ô @ôF<L�ô <Lô~*ˆjô *ôZ4�*ô 4ñp ˆ6ƒ{€Ù
ˆi‹.‚r   