|
Server : Apache System : Linux cvar2.toservers.com 3.10.0-962.3.2.lve1.5.73.el7.x86_64 #1 SMP Wed Aug 24 21:31:23 UTC 2022 x86_64 User : njnconst ( 1116) PHP Version : 8.4.18 Disable Function : NONE Directory : /usr/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/ |
Upload File : |
�
���\c @ s( d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z y d d l m
Z Wn e k
r} d Z n Xe j d � Z e j d
� Z d e j f d � � YZ e j d
d d �Z e j d d d �Z e j d d d �Z d e j f d � � YZ e e e j <e e d <d S( i ( t colspecs( t
ischema_namesi ( t types( t
expression( t operatorsi����( t UUIDc C s | j | | � S( s� A synonym for the :meth:`.ARRAY.Comparator.any` method.
This method is legacy and is here for backwards-compatibility.
.. seealso::
:func:`.expression.any_`
( t any( t othert arrexprt operator( ( sJ /usr/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyt Any s c C s | j | | � S( s� A synonym for the :meth:`.ARRAY.Comparator.all` method.
This method is legacy and is here for backwards-compatibility.
.. seealso::
:func:`.expression.all_`
( t all( R R R ( ( sJ /usr/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyt All# s t arrayc B s8 e Z d Z d Z d � Z e d d � Z d d � Z RS( sb A PostgreSQL ARRAY literal.
This is used to produce ARRAY literals in SQL expressions, e.g.::
from sqlalchemy.dialects.postgresql import array
from sqlalchemy.dialects import postgresql
from sqlalchemy import select, func
stmt = select([
array([1,2]) + array([3,4,5])
])
print stmt.compile(dialect=postgresql.dialect())
Produces the SQL::
SELECT ARRAY[%(param_1)s, %(param_2)s] ||
ARRAY[%(param_3)s, %(param_4)s, %(param_5)s]) AS anon_1
An instance of :class:`.array` will always have the datatype
:class:`.ARRAY`. The "inner" type of the array is inferred from
the values present, unless the ``type_`` keyword argument is passed::
array(['foo', 'bar'], type_=CHAR)
.. seealso::
:class:`.postgresql.ARRAY`
R
c K s/ t t | � j | | � t | j � | _ d S( N( t superR
t __init__t ARRAYt type( t selft clausest kw( ( sJ /usr/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyR T s c C s� | s | t j k rU t | t � s* t � t j d | d | d | d | j d t �St
g | D]$ } | j | | d t d | �^ q_ � Sd S( Nt _compared_to_operatort type_t _compared_to_typet uniquet _assume_scalar( R t getitemt
isinstancet intt AssertionErrorR t
BindParametert NoneR t TrueR
t _bind_param( R R t objR R t o( ( sJ /usr/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyR! X s c C s3 | t j t j t j f k r+ t j | � S| Sd S( N( R t any_opt all_opR R t Grouping( R t against( ( sJ /usr/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyt
self_groupp s
N( t __name__t
__module__t __doc__t __visit_name__R t FalseR R! R( ( ( ( sJ /usr/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyR
1 s
s @>t
precedencei s <@s &&R c B s� e Z d Z d e j j f d � � YZ e Z e d
e d � Z e
d � � Z e
d � � Z d � Z
d � Z d � Z d � Z RS( s� PostgreSQL ARRAY type.
.. versionchanged:: 1.1 The :class:`.postgresql.ARRAY` type is now
a subclass of the core :class:`.types.ARRAY` type.
The :class:`.postgresql.ARRAY` type is constructed in the same way
as the core :class:`.types.ARRAY` type; a member type is required, and a
number of dimensions is recommended if the type is to be used for more
than one dimension::
from sqlalchemy.dialects import postgresql
mytable = Table("mytable", metadata,
Column("data", postgresql.ARRAY(Integer, dimensions=2))
)
The :class:`.postgresql.ARRAY` type provides all operations defined on the
core :class:`.types.ARRAY` type, including support for "dimensions",
indexed access, and simple matching such as
:meth:`.types.ARRAY.Comparator.any` and
:meth:`.types.ARRAY.Comparator.all`. :class:`.postgresql.ARRAY` class also
provides PostgreSQL-specific methods for containment operations, including
:meth:`.postgresql.ARRAY.Comparator.contains`
:meth:`.postgresql.ARRAY.Comparator.contained_by`, and
:meth:`.postgresql.ARRAY.Comparator.overlap`, e.g.::
mytable.c.data.contains([1, 2])
The :class:`.postgresql.ARRAY` type may not be supported on all
PostgreSQL DBAPIs; it is currently known to work on psycopg2 only.
Additionally, the :class:`.postgresql.ARRAY` type does not work directly in
conjunction with the :class:`.ENUM` type. For a workaround, see the
special type at :ref:`postgresql_array_of_enum`.
.. seealso::
:class:`.types.ARRAY` - base array type
:class:`.postgresql.array` - produces a literal array value.
t
Comparatorc B s) e Z d Z d � Z d � Z d � Z RS( s$ Define comparison operations for :class:`.ARRAY`.
Note that these operations are in addition to those provided
by the base :class:`.types.ARRAY.Comparator` class, including
:meth:`.types.ARRAY.Comparator.any` and
:meth:`.types.ARRAY.Comparator.all`.
c K s | j t | d t j �S( s Boolean expression. Test if elements are a superset of the
elements of the argument array expression.
t result_type( t operatet CONTAINSt sqltypest Boolean( R R t kwargs( ( sJ /usr/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyt contains� s c C s | j t | d t j �S( s� Boolean expression. Test if elements are a proper subset of the
elements of the argument array expression.
R0 ( R1 t CONTAINED_BYR3 R4 ( R R ( ( sJ /usr/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyt contained_by� s c C s | j t | d t j �S( su Boolean expression. Test if array has elements in common with
an argument array expression.
R0 ( R1 t OVERLAPR3 R4 ( R R ( ( sJ /usr/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyt overlap� s ( R) R* R+ R6 R8 R: ( ( ( sJ /usr/lib64/python2.7/site-packages/sqlalchemy/dialects/postgresql/array.pyR/ � s c C sa t | t � r t d � � n t | t � r9 | � } n | | _ | | _ | | _ | | _ d S( sP Construct an ARRAY.
E.g.::
Column('myarray', ARRAY(Integer))
Arguments are:
:param item_type: The data type of items of this array. Note that
dimensionality is irrelevant here, so multi-dimensional arrays like
``INTEGER[][]``, are constructed as ``ARRAY(Integer)``, not as
``ARRAY(ARRAY(Integer))`` or such.
:param as_tuple=False: Specify whether return results
should be converted to tuples from lists. DBAPIs such
as psycopg2 return lists by default. When tuples are
returned, the results are hashable.
:param dimensions: if non-None, the ARRAY will assume a fixed
number of dimensions. This will cause the DDL emitted for this
ARRAY to include the exact number of bracket clauses ``[]``,
and will also optimize the performance of the type overall.
Note that PG arrays are always implicitly "non-dimensioned",
meaning they can store any number of dimensions no matter how
they were declared.
:param zero_indexes=False: when True, index values will be converted
between Python zero-based and PostgreSQL one-based indexes, e.g.
a value of one will be added to all index values before passing
to the database.
.. versionadded:: 0.9.5
sU Do not nest ARRAY types; ARRAY(basetype) handles multi-dimensional arrays of basetypeN( R R t
ValueErrorR t item_typet as_tuplet
dimensionst zero_indexes( R R<