Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
ó
‹EYc@@sèddlmZddlZddlmZddlmZddlm	Z	ddlm
Z
dd	l
mZmZdd
lm
Z
dZdejfd„ƒYZdejfd„ƒYZeed<d
efd„ƒYZeed<dS(i(tabsolute_importNi(t
ischema_namesi(ttypes(t	custom_op(tsql(telementstdefault_comparator(tutiltJSONtJSONElementtJSONBcB@s8eZdZeddd„Zed„ƒZd„ZRS(sËRepresents accessing an element of a :class:`.JSON` value.

    The :class:`.JSONElement` is produced whenever using the Python index
    operator on an expression that has the type :class:`.JSON`::

        expr = mytable.c.json_data['some_key']

    The expression typically compiles to a JSON access such as ``col -> key``.
    Modifiers are then available for typing behavior, including
    :meth:`.JSONElement.cast` and :attr:`.JSONElement.astext`.

    cC@s¼||_|dkrft|dƒr]t|tjƒr]d}ddjd„|Dƒƒ}qfd}n||_t|ddƒ}t	j
|||ƒ}tt|ƒj
|||d	|ƒdS(
Nt__iter__s#>s{%s}s, cs@s|]}tj|ƒVqdS(N(Rt	text_type(t.0telem((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pys	<genexpr>+ss->t
precedenceittype_(t_astexttNonethasattrt
isinstanceRtstring_typestjoint_json_opstringRRt_check_literaltsuperR	t__init__(tselftlefttrighttastexttopstringtresult_typetoperator((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pyR#s			cC@sI|jr
|St|j|jdtd|jddtjdtƒƒSdS(sêConvert this :class:`.JSONElement` to use the 'astext' operator
        when evaluated.

        E.g.::

            select([data_table.c.data['some key'].astext])

        .. seealso::

            :meth:`.JSONElement.cast`

        RRt>R tconvert_unicodeN(RR	RRtTrueRtsqltypestString(R((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pyR6s		
cC@s-|js|jj|ƒStj||ƒSdS(sConvert this :class:`.JSONElement` to apply both the 'astext' operator
        as well as an explicit type cast when evaluated.

        E.g.::

            select([data_table.c.data['some key'].cast(Integer)])

        .. seealso::

            :attr:`.JSONElement.astext`

        N(RRtcastR(RR((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pyR'Os
	N(	t__name__t
__module__t__doc__tFalseRRtpropertyRR'(((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pyR	s
cB@sNeZdZdZed„Zdejjfd„ƒYZ	d„Z
d„ZRS(s‡	Represent the Postgresql JSON type.

    The :class:`.JSON` type stores arbitrary JSON format data, e.g.::

        data_table = Table('data_table', metadata,
            Column('id', Integer, primary_key=True),
            Column('data', JSON)
        )

        with engine.connect() as conn:
            conn.execute(
                data_table.insert(),
                data = {"key1": "value1", "key2": "value2"}
            )

    :class:`.JSON` provides several operations:

    * Index operations::

        data_table.c.data['some key']

    * Index operations returning text (required for text comparison)::

        data_table.c.data['some key'].astext == 'some value'

    * Index operations with a built-in CAST call::

        data_table.c.data['some key'].cast(Integer) == 5

    * Path index operations::

        data_table.c.data[('key_1', 'key_2', ..., 'key_n')]

    * Path index operations returning text (required for text comparison)::

        data_table.c.data[('key_1', 'key_2', ..., 'key_n')].astext == \
            'some value'

    Index operations return an instance of :class:`.JSONElement`, which
    represents an expression such as ``column -> index``.  This element then
    defines methods such as :attr:`.JSONElement.astext` and
    :meth:`.JSONElement.cast` for setting up type behavior.

    The :class:`.JSON` type, when used with the SQLAlchemy ORM, does not
    detect in-place mutations to the structure.  In order to detect these, the
    :mod:`sqlalchemy.ext.mutable` extension must be used.  This extension will
    allow "in-place" changes to the datastructure to produce events which
    will be detected by the unit of work.  See the example at :class:`.HSTORE`
    for a simple example involving a dictionary.

    Custom serializers and deserializers are specified at the dialect level,
    that is using :func:`.create_engine`.  The reason for this is that when
    using psycopg2, the DBAPI only allows serializers at the per-cursor
    or per-connection level.   E.g.::

        engine = create_engine("postgresql://scott:tiger@localhost/test",
                                json_serializer=my_serialize_fn,
                                json_deserializer=my_deserialize_fn
                        )

    When using the psycopg2 dialect, the json_deserializer is registered
    against the database using ``psycopg2.extras.register_default_json``.

    .. versionadded:: 0.9

    RcC@s
||_dS(sConstruct a :class:`.JSON` type.

        :param none_as_null: if True, persist the value ``None`` as a
         SQL NULL value, not the JSON encoding of ``null``.   Note that
         when this flag is False, the :func:`.null` construct can still
         be used to persist a NULL value::

             from sqlalchemy import null
             conn.execute(table.insert(), data=null())

         .. versionchanged:: 0.9.8 - Added ``none_as_null``, and :func:`.null`
            is now supported in order to persist a NULL value.

         N(tnone_as_null(RR-((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pyR¨stcomparator_factorycB@s eZdZd„Zd„ZRS(s0Define comparison operations for :class:`.JSON`.cC@st|j|ƒS(sGet the value at a given key.(R	texpr(Rtother((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pyt__getitem__¼scC@sGt|tƒr.|jdkr.|tjfSntjjj|||ƒS(Ns->(RRRR%tTexttConcatenablet
Comparatort_adapt_expression(Rtoptother_comparator((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pyR5Ás
(R(R)R*R1R5(((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pyR.¹s	c@sR|jptj‰tjr<|j‰‡‡‡fd†}n‡‡fd†}|S(Nc@s>t|tjƒs'|dkr+ˆjr+dSˆ|ƒjˆƒS(N(RRtNullRR-tencode(tvalue(tencodingtjson_serializerR(sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pytprocessÍsc@s5t|tjƒs'|dkr+ˆjr+dSˆ|ƒS(N(RRR8RR-(R:(R<R(sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pyR=Ôs(t_json_serializertjsontdumpsRtpy2kR;(RtdialectR=((R;R<RsX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pytbind_processorÈs		c@sL|jptj‰tjr9|j‰‡‡fd†}n‡fd†}|S(Nc@s#|dkrdSˆ|jˆƒƒS(N(Rtdecode(R:(R;tjson_deserializer(sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pyR=ásc@s|dkrdSˆ|ƒS(N(R(R:(RE(sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pyR=æs(t_json_deserializerR?tloadsRRAR;(RRBtcoltypeR=((R;REsX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pytresult_processorÜs		(R(R)R*t__visit_name__R+RR%R3R4R.RCRI(((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pyRbsB	R?cB@s6eZdZdZeZdejjfd„ƒYZ	RS(sŽ	Represent the Postgresql JSONB type.

    The :class:`.JSONB` type stores arbitrary JSONB format data, e.g.::

        data_table = Table('data_table', metadata,
            Column('id', Integer, primary_key=True),
            Column('data', JSONB)
        )

        with engine.connect() as conn:
            conn.execute(
                data_table.insert(),
                data = {"key1": "value1", "key2": "value2"}
            )

    :class:`.JSONB` provides several operations:

    * Index operations::

        data_table.c.data['some key']

    * Index operations returning text (required for text comparison)::

        data_table.c.data['some key'].astext == 'some value'

    * Index operations with a built-in CAST call::

        data_table.c.data['some key'].cast(Integer) == 5

    * Path index operations::

        data_table.c.data[('key_1', 'key_2', ..., 'key_n')]

    * Path index operations returning text (required for text comparison)::

        data_table.c.data[('key_1', 'key_2', ..., 'key_n')].astext == \
            'some value'

    Index operations return an instance of :class:`.JSONElement`, which
    represents an expression such as ``column -> index``.  This element then
    defines methods such as :attr:`.JSONElement.astext` and
    :meth:`.JSONElement.cast` for setting up type behavior.

    The :class:`.JSON` type, when used with the SQLAlchemy ORM, does not
    detect in-place mutations to the structure.  In order to detect these, the
    :mod:`sqlalchemy.ext.mutable` extension must be used.  This extension will
    allow "in-place" changes to the datastructure to produce events which
    will be detected by the unit of work.  See the example at :class:`.HSTORE`
    for a simple example involving a dictionary.

    Custom serializers and deserializers are specified at the dialect level,
    that is using :func:`.create_engine`.  The reason for this is that when
    using psycopg2, the DBAPI only allows serializers at the per-cursor
    or per-connection level.   E.g.::

        engine = create_engine("postgresql://scott:tiger@localhost/test",
                                json_serializer=my_serialize_fn,
                                json_deserializer=my_deserialize_fn
                        )

    When using the psycopg2 dialect, the json_deserializer is registered
    against the database using ``psycopg2.extras.register_default_json``.

    .. versionadded:: 0.9.7

    R
R.cB@sMeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z	RS(s0Define comparison operations for :class:`.JSON`.cC@st|j|ƒS(sGet the value at a given key.(R	R/(RR0((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pyR1:scC@sct|tƒrJ|jdkr+|tjfS|jdkrJ|tjfSntjjj|||ƒS(Nt?s?&s?|s@>s<@s->(RKs?&s?|s@>s<@(	RRRR%tBooleanR2R3R4R5(RR6R7((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pyR5?s
cC@s|jjdƒ|ƒS(svBoolean expression.  Test for presence of a key.  Note that the
            key may be a SQLA expression.
            RK(R/R6(RR0((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pythas_keyJscC@s|jjdƒ|ƒS(sHBoolean expression.  Test for presence of all keys in jsonb
            s?&(R/R6(RR0((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pythas_allPscC@s|jjdƒ|ƒS(sGBoolean expression.  Test for presence of any key in jsonb
            s?|(R/R6(RR0((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pythas_anyUscK@s|jjdƒ|ƒS(sŒBoolean expression.  Test if keys (or array) are a superset of/contained
            the keys of the argument jsonb expression.
            s@>(R/R6(RR0tkwargs((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pytcontainsZscC@s|jjdƒ|ƒS(s|Boolean expression.  Test if keys are a proper subset of the
            keys of the argument jsonb expression.
            s<@(R/R6(RR0((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pytcontained_by`s(
R(R)R*R1R5RMRNRORQRR(((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pyR.7s						(
R(R)R*RJR+thashableR%R3R4R.(((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pyR
ðsBtjsonb(sJSONsJSONElementsJSONB(t
__future__RR?tbaseRtRR%t
sql.operatorsRRRRRt__all__tBinaryExpressionR	t
TypeEngineRR
(((sX/home/tvault/.virtenv/lib/python2.7/site-packages/sqlalchemy/dialects/postgresql/json.pyt<module>sM‹
v