
    -h9                         S 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Qr\R(                   " S S\5      5       rg)z|MapperProperty implementations.

This is a private module which defines the behavior of individual ORM-
mapped attributes.

    )absolute_import   )
attributes)CompositeProperty)ConcreteInheritedProperty)SynonymProperty)PropComparator)StrategizedProperty)RelationshipProperty   )log)util)	coercions)roles)ColumnPropertyr   r   r   r   c                   ,  ^  \ rS rSrSrSrSrSrSrU 4S jr	S r
\R                  " S	S
5      S 5       r\R                  " S	S
5      S 5       rS r\S 5       rS rU 4S jrS r\R,                  4S jrS r " S S\R2                  \5      rS rSrU =r$ )r   &   zDescribes an object attribute that corresponds to a table column.

Public constructor is the :func:`_orm.column_property` function.

columnTF)columnsgroupdeferred
instrumentcomparator_factory
descriptoractive_historyexpire_on_flushinfodocstrategy_key_creation_order_is_polymorphic_discriminator_mapped_by_synonym_deferred_column_loader_raise_column_loader_renders_in_subqueries	raiseloadc           
        > [         [        U ]  5         U Vs/ s H(  n[        R                  " [
        R                  U5      PM*     snU l        UR                  SS5      U l	        UR                  SS5      U l
        UR                  SS5      U l        UR                  SS5      U l        UR                  SU R                  R                  5      U l        UR                  S	S5      U l        UR                  S
S5      U l        UR                  SS5      U l        SU;   a  UR                  S5      U l        SU;   a  UR                  S5      U l        O;[+        U R                  5       H  n[-        USS5      nUc  M  XPl          O	   SU l        U(       aL  [/        U R                  R0                  < SSR3                  [5        UR7                  5       5      5      < 35      e[8        R:                  " U 5        SU R                  4SU R                  44U l        U R                  (       a  U =R<                  S-  sl        ggs  snf )a<  Provide a column-level property for use with a mapping.

Column-based properties can normally be applied to the mapper's
``properties`` dictionary using the :class:`_schema.Column`
element directly.
Use this function when the given column is not directly present within
the mapper's selectable; examples include SQL expressions, functions,
and scalar SELECT queries.

The :func:`_orm.column_property` function returns an instance of
:class:`.ColumnProperty`.

Columns that aren't present in the mapper's selectable won't be
persisted by the mapper and are effectively "read-only" attributes.

:param \*cols:
      list of Column objects to be mapped.

:param active_history=False:
  When ``True``, indicates that the "previous" value for a
  scalar attribute should be loaded when replaced, if not
  already loaded. Normally, history tracking logic for
  simple non-primary-key scalar values only needs to be
  aware of the "new" value in order to perform a flush. This
  flag is available for applications that make use of
  :func:`.attributes.get_history` or :meth:`.Session.is_modified`
  which also need to know
  the "previous" value of the attribute.

:param comparator_factory: a class which extends
   :class:`.ColumnProperty.Comparator` which provides custom SQL
   clause generation for comparison operations.

:param group:
    a group name for this property when marked as deferred.

:param deferred:
      when True, the column property is "deferred", meaning that
      it does not load immediately, and is instead loaded when the
      attribute is first accessed on an instance.  See also
      :func:`~sqlalchemy.orm.deferred`.

:param doc:
      optional string that will be applied as the doc on the
      class-bound descriptor.

:param expire_on_flush=True:
    Disable expiry on flush.   A column_property() which refers
    to a SQL expression (and not a single table-bound column)
    is considered to be a "read only" property; populating it
    has no effect on the state of data, and it can only return
    database state.   For this reason a column_property()'s value
    is expired whenever the parent object is involved in a
    flush, that is, has any kind of "dirty" state within a flush.
    Setting this parameter to ``False`` will have the effect of
    leaving any existing value present after the flush proceeds.
    Note however that the :class:`.Session` with default expiration
    settings still expires
    all attributes after a :meth:`.Session.commit` call, however.

:param info: Optional data dictionary which will be populated into the
    :attr:`.MapperProperty.info` attribute of this object.

:param raiseload: if True, indicates the column should raise an error
    when undeferred, rather than loading the value.  This can be
    altered at query time by using the :func:`.deferred` option with
    raiseload=False.

    .. versionadded:: 1.4

    .. seealso::

        :ref:`deferred_raiseload`

.. seealso::

    :ref:`column_property_options` - to map columns while including
    mapping options

    :ref:`mapper_column_property_sql_expressions` - to map SQL
    expressions

r   Nr   Fr&   _instrumentTr   r   r   r   r   r   z* received unexpected keyword argument(s): z, r   ))r&   T)superr   __init__r   expectr   LabeledColumnExprRoler   popr   r   r&   r   	__class__
Comparatorr   r   r   r   r   r   reversedgetattr	TypeError__name__joinsortedkeysr   set_creation_orderr   )selfr   kwargsccolr   r.   s         nC:\Users\ROHAN GUPTA\OneDrive\Desktop\mathbuddy-assessment\venv\Lib\site-packages\sqlalchemy/orm/properties.pyr*   ColumnProperty.__init__G   s   h 	nd,.FM
FMIU88!<g
 ZZ.


:u5K7 **]D9"(** $..";";#
 !**\48$jj)95A%zz*;TBV

6*DIF?zz%(DH-c5$/?"H	 .  >>**DIIfV[[]6K,LN 
 	% '4??+
 >>!77 Q
s   /Ic                     SU R                   ;   a  U R                  R                  $ SU R                   ;  =(       d    X R                  R                  ;  $ )N)query_expressionT)r   T)r   strategy_have_default_expressionparent_readonly_propsr8   s    r<   %_memoized_attr__renders_in_subqueries4ColumnProperty._memoized_attr__renders_in_subqueries   sH    %):)::==999!):):: 
333	
    zsqlalchemy.orm.statezsqlalchemy.orm.strategiesc                    [         R                  R                  n[         R                  R                  nUR                  R                  U R                  R                  UR                  U R                  5      U R                  5      $ N
r   	preloaded	orm_stateorm_strategiesInstanceState"_instance_level_callable_processorrB   class_managerLoadDeferredColumnskeyr8   state
strategiess      r<   &_memoized_attr__deferred_column_loader5ColumnProperty._memoized_attr__deferred_column_loader   s_    ((^^22
""EEKK%%**4884HH
 	
rG   c                    [         R                  R                  n[         R                  R                  nUR                  R                  U R                  R                  UR                  U R                  S5      U R                  5      $ )NTrJ   rS   s      r<   #_memoized_attr__raise_column_loader2ColumnProperty._memoized_attr__raise_column_loader   sa    ((^^22
""EEKK%%**488T:HH
 	
rG   c                     U R                   $ )zcAllow the ColumnProperty to work in expression before it is turned
into an instrumented attribute.
)
expressionrD   s    r<   __clause_element__!ColumnProperty.__clause_element__   s    
 rG   c                      U R                   S   $ )az  Return the primary column or expression for this ColumnProperty.

E.g.::


    class File(Base):
        # ...

        name = Column(String(64))
        extension = Column(String(8))
        filename = column_property(name + '.' + extension)
        path = column_property('C:/' + filename.expression)

.. seealso::

    :ref:`mapper_column_property_sql_expressions_composed`

r   )r   rD   s    r<   r\   ColumnProperty.expression   s    ( ||ArG   c                     U R                   (       d  g [        R                  " UR                  U R                  U R                  X5      UU R                  S9  g )N)
comparatorparententityr   )r   r   register_descriptorclass_rR   r   r   )r8   mappers     r<   instrument_classColumnProperty.instrument_class   s@    &&MMHH..t<	
rG   c                   > [         [        U ]  5         [        U R                  5      S:  a  [        U R                  R                  5      R                  U R                  5      (       aV  [        R                  " SU R                  < SU R                  S   < SU R                  S   < SU R                  < S3	5        g g g )Nr   z
On mapper z, primary key column 'z6' is being combined with distinct primary key column 'r   z' in attribute 'zM'. Use explicit properties to give each column its own mapped attribute name.)r)   r   do_initlenr   setrB   primary_key
issupersetr   warnrR   )r8   r.   s    r<   rj   ColumnProperty.do_init  s    nd+-t||q S)@)@%A%L%LLL&
 &
 II ;;Qa$((L&
 rG   c                 l    [        U R                  U R                  U R                  U R                  S.6$ )N)r   r   r   )r   r   r   r   r   rD   s    r<   copyColumnProperty.copy  s1     \\ ]]**..
 	
rG   c                 T    UR                  U R                  5      R                  XUS9$ )N)passive)get_implrR   get_committed_value)r8   rT   dict_r   ru   s        r<   _getcommittedColumnProperty._getcommitted$  s.     ~~dhh';;' < 
 	
rG   c	                 j   U R                   (       d  g U R                  U;   aS  X0R                     n	U(       d  XU R                  '   g UR                  U R                  5      n
U
R                  XEU	S 5        g UR                  (       a-  U R                  U;  a  UR                  XPR                  /SS9  g g g )NT)	no_loader)r   rR   rv   rl   has_identity_expire_attributes)r8   sessionsource_statesource_dict
dest_state	dest_dictload
_recursive_resolve_conflict_mapvalueimpls              r<   mergeColumnProperty.merge+  s     XX$)E&+$((#!**4884t<$$)B))HH: *  *C$rG   c                   F    \ rS rSrSrSrS rS rS rS r	S r
S	 rS
 rSrg)ColumnProperty.ComparatoriE  a8  Produce boolean, comparison, and other operators for
:class:`.ColumnProperty` attributes.

See the documentation for :class:`.PropComparator` for a brief
overview.

.. seealso::

    :class:`.PropComparator`

    :class:`.ColumnOperators`

    :ref:`types_operators`

    :attr:`.TypeEngine.comparator_factory`

)r]   r   expressionsc                 &   U R                   nUUUU R                  R                  S.nUnU R                  R                  (       a+  UnU R                  R                  R                  U5      nXSS'   UR                  U5      R                  SUS.5      $ )a  annotate and possibly adapt a column to be returned
as the mapped-attribute exposed version of the column.

The column in this context needs to act as much like the
column in an ORM mapped context as possible, so includes
annotations to give hints to various ORM functions as to
the source entity of this column.   It also adapts it
to the mapper's with_polymorphic selectable if one is
present.

)entity_namespacerc   parentmapper	proxy_keyadapt_columnorm)compile_state_pluginplugin_subject)_parententityproprR   _parentmapper_polymorphic_adaptertraverse	_annotate_set_propagate_attrs)r8   r   peannotationsr;   mapper_local_cols         r<   _orm_annotate_column.ColumnProperty.Comparator._orm_annotate_columnZ  s     ##B$& " "!YY]]	K C !!66#& ((==FFsK
 /?N+==-BB)."E rG   c                     U R                   (       a=  U R                  U R                  R                  S   U R                  R                  5      $ U R	                  U R                  R                  S   5      $ )Nr   adapterr   r   rR   r   rD   s    r<   #_memoized_method___clause_element__=ColumnProperty.Comparator._memoized_method___clause_element__  sQ    ||||DII$5$5a$8$))--HH001B1B11EFFrG   c                     U R                  5       n UR                  $ ! [         a    U R                  R                  s $ f = f)z(The .info dictionary for this attribute.)r]   r   AttributeErrorr   )r8   ces     r<   _memoized_attr_info-ColumnProperty.Comparator._memoized_attr_info  s=     ((*B&ww! &yy~~%&s     A Ac                 6   U R                   (       aJ  U R                  R                   Vs/ s H(  nU R                  XR                  R                  5      PM*     sn$ U R                  R                   Vs/ s H  oR	                  U5      PM     sn$ s  snf s  snf )z}The full sequence of columns referenced by this
attribute, adjusted for any aliasing in progress.

.. versionadded:: 1.3.17

r   )r8   r;   s     r<   _memoized_attr_expressions4ColumnProperty.Comparator._memoized_attr_expressions  s     ||  $yy000 LLiimm40  ?Cii>O>O>Os--c2>O 
s   /B4Bc                 6    [        U R                  5       U5      $ )zoproxy attribute access down to the mapped column.

this allows user-defined comparison methods to be accessed.
)r1   r]   )r8   rR   s     r<   _fallback_getattr+ColumnProperty.Comparator._fallback_getattr  s    
 4224c::rG   c                 6    U" U R                  5       /UQ70 UD6$ rI   )r]   )r8   opotherr9   s       r<   operate!ColumnProperty.Comparator.operate  s     d--/B%B6BBrG   c                 T    U R                  5       nU" UR                  X5      U40 UD6$ rI   )r]   _bind_param)r8   r   r   r9   r;   s        r<   reverse_operate)ColumnProperty.Comparator.reverse_operate  s+    ))+Ccoob0#@@@rG    N)r3   
__module____qualname____firstlineno____doc__	__slots__r   r   r   r   r   r   r   __static_attributes__r   rG   r<   r/   r   E  s6    	$ @	&	P	G	&	"	;	C	ArG   r/   c                 t    [        U R                  R                  R                  5      S-   U R                  -   $ )N.)strrB   re   r3   rR   rD   s    r<   __str__ColumnProperty.__str__  s+    4;;%%../#5@@rG   )r   r   r   r   r   r   r   r   r   r   r&   r   )r3   r   r   r   r   strategy_wildcard_keyinherit_cache_links_to_entityr   r*   rE   r   preload_modulerV   rY   r]   propertyr\   rg   rj   rr   r   PASSIVE_OFFry   r   MemoizedSlotsr	   r/   r   r   __classcell__)r.   s   @r<   r   r   &   s     %MI*~8@
 
/1LM
 N
 
/1LM
 N
  *

 
 -7,B,B
4iAT'' iAVA ArG   r   N)r   
__future__r    r   descriptor_propsr   r   r   
interfacesr	   r
   relationshipsr   r   r   sqlr   r   __all__class_loggerr   r   rG   r<   <module>r      s_    '  / 7 - & + /     JA( JA JArG   