
    EvgO                          d Z ddlZddlmZ ddlmZmZ ddlmZ  G d de	          Z
 G d d	          Z G d
 d          Z G d d          ZdS )z]
Useful auxiliary data structures for query construction. Not useful outside
the SQL domain.
    N)FullResultSet)INNERLOUTER)RemovedInDjango60Warningc                       e Zd ZdZd ZdS )	MultiJoinz
    Used by join construction code to indicate the point at which a
    multi-valued join was attempted (if the caller wants to treat that
    exceptionally).
    c                 "    || _         || _        d S N)levelnames_with_path)self	names_pospath_with_namess      `/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/db/models/sql/datastructures.py__init__zMultiJoin.__init__   s    
.    N)__name__
__module____qualname____doc__r    r   r   r   r      s-         / / / / /r   r   c                       e Zd ZdS )EmptyN)r   r   r   r   r   r   r   r      s        Dr   r   c                   V    e Zd ZdZ	 ddZd Zd Zed             Zd Z	d Z
d	 Zd
 ZdS )Joina  
    Used by sql.Query and sql.SQLCompiler to generate JOIN clauses into the
    FROM entry. For example, the SQL generated could be
        LEFT OUTER JOIN "sometable" T1
        ON ("othertable"."sometable_id" = "sometable"."id")

    This class is primarily used in Query.alias_map. All entries in alias_map
    must be Join compatible by providing the following attributes and methods:
        - table_name (string)
        - table_alias (possible alias for the table, can be None)
        - join_type (can be None for those entries that aren't joined from
          anything)
        - parent_alias (which table is this join's parent, can be None similarly
          to join_type)
        - as_sql()
        - relabeled_clone()
    Nc                 v   || _         || _        || _        || _        t	          |d          r=|                                | _        t          d | j        D                       | _        n:t          j
        dt                     d | _        |                                | _        || _        || _        || _        d S )Nget_joining_fieldsc              3   8   K   | ]\  }}|j         |j         fV  d S r
   )column).0	lhs_field	rhs_fields      r   	<genexpr>z Join.__init__.<locals>.<genexpr>F   sE       # #(Iy !9#34# # # # # #r   zaThe usage of get_joining_columns() in Join is deprecated. Implement get_joining_fields() instead.)
table_nameparent_aliastable_alias	join_typehasattrr   join_fieldstuple	join_colswarningswarnr   get_joining_columns
join_fieldnullablefiltered_relation)r   r$   r%   r&   r'   r/   r0   r1   s           r   r   zJoin.__init__1   s     %(&" :344 	>)<<>>D" # #,0,<# # #  DNN
 M0(  
  $D';;==DN$ !2r   c                    g }g }|j         }|j        j        }| j        p| j        }|D ]\  }}	t          |t                    r= || j                  d ||          }
 || j                  d ||	          }nd|j        	                    | j        || j        |	          \  }}	|
                    |          \  }}||z  }
|
                    |	          \  }}||z  }|                    |
 d|            | j                            | j        | j                  }|rE|
                    |          \  }}|                    d|z             |                    |           | j        r\	 |
                    | j                  \  }}|                    d|z             |                    |           n# t           $ r Y nw xY w|s2t#          | j        d| j                  }t%          d|j        z            d                    |          }| j        | j        k    rdn	d| j        z  }| j        d	 || j                  |d
|d}||fS )z
        Generate the full
           LEFT OUTER JOIN sometable ON sometable.somecol = othertable.othercol, params
        clause for this join.
        .z = z(%s)fieldzaJoin generated an empty ON clause. %s did not yield either joining columns or extra restrictions.z AND   %s z ON ())quote_name_unless_aliasops
quote_namer)   r+   
isinstancestrr%   r&   prepare_join_on_clausecompileappendr/   get_extra_restrictionextendr1   r   getattr
ValueError	__class__joinr$   r'   )r   compiler
connectionjoin_conditionsparamsqnqn2r)   lhsrhslhs_full_namerhs_full_namelhs_sql
lhs_paramsrhs_sql
rhs_params
extra_cond	extra_sqlextra_paramsdeclared_fieldon_clause_sql	alias_strsqls                          r   as_sqlzJoin.as_sqlX   s    -n' &8$.# 	I 	IHC#s## 5 ,.2d.?+@+@+@+@##c((( K+-2d.>+?+?+?+?S J%>@@%sD,<c S '/&6&6s&;&;# '* 4&.&6&6s&;&;# '* 4""m#G#G#G#GHHHH _::d/
 

  	(&.&6&6z&B&B#I|""6I#5666MM,'''! 	,,*2*:*:4;Q*R*R'	<  &&v	'9:::l++++	 !   
  	$T_gtOON9;I;ST    _55"do55BBEDDT<T 	 NNNBtIIMM	
 F{s   2F= =
G
	G
c           	      *   |                     | j        | j                  }|                     | j        | j                  }| j        | j                            |          }nd }|                     | j        ||| j        | j        | j	        |          S )N)r1   )
getr%   r&   r1   relabeled_clonerE   r$   r'   r/   r0   )r   
change_mapnew_parent_aliasnew_table_aliasr1   s        r   r_   zJoin.relabeled_clone   s    %>>$*;T=NOO$..)94;KLL!- $ 6 F Fz R R $~~ONOM/  
 
 	
r   c                 B    | j         | j        | j        | j        | j        fS r
   )rE   r$   r%   r/   r1   r   s    r   identityzJoin.identity   s)     NOO"
 	
r   c                 Z    t          |t                    st          S | j        |j        k    S r
   )r<   r   NotImplementedre   r   others     r   __eq__zJoin.__eq__   s)    %&& 	"!!}..r   c                 *    t          | j                  S r
   hashre   rd   s    r   __hash__zJoin.__hash__       DM"""r   c                 H    |                      i           }t          |_        |S r
   )r_   r   r'   r   news     r   demotezJoin.demote   s!    ""2&&
r   c                 H    |                      i           }t          |_        |S r
   )r_   r   r'   rq   s     r   promotezJoin.promote   s!    ""2&&
r   r
   )r   r   r   r   r   r\   r_   propertyre   rj   rn   rs   ru   r   r   r   r   r      s         4 %3 %3 %3 %3N@ @ @D
 
 
" 
 
 X
/ / /
# # #  
    r   r   c                   R    e Zd ZdZdZdZdZd Zd Zd Z	e
d             Zd Zd ZdS )		BaseTablez
    The BaseTable class is used for base table references in FROM clause. For
    example, the SQL "foo" in
        SELECT * FROM "foo" WHERE somecond
    could be generated by this class.
    Nc                 "    || _         || _        d S r
   )r$   r&   )r   r$   aliass      r   r   zBaseTable.__init__   s    $ r   c                 |    | j         | j        k    rdn	d| j         z  }|                    | j                  }||z   g fS )Nr5   r6   )r&   r$   r9   )r   rG   rH   rZ   base_sqls        r   r\   zBaseTable.as_sql   sL    "do55BBEDDT<T 	 33DODD)#R''r   c                 t    |                      | j        |                    | j        | j                            S r
   )rE   r$   r^   r&   )r   r`   s     r   r_   zBaseTable.relabeled_clone   s3    ~~OZ^^D,<d>NOO
 
 	
r   c                 *    | j         | j        | j        fS r
   )rE   r$   r&   rd   s    r   re   zBaseTable.identity   s    ~t0@@@r   c                 Z    t          |t                    st          S | j        |j        k    S r
   )r<   rx   rg   re   rh   s     r   rj   zBaseTable.__eq__   s)    %++ 	"!!}..r   c                 *    t          | j                  S r
   rl   rd   s    r   rn   zBaseTable.__hash__   ro   r   )r   r   r   r   r'   r%   r1   r   r\   r_   rv   re   rj   rn   r   r   r   rx   rx      s          IL! ! !( ( (
 
 

 A A XA/ / /
# # # # #r   rx   )r   r,   django.core.exceptionsr   django.db.models.sql.constantsr   r   django.utils.deprecationr   	Exceptionr   r   r   rx   r   r   r   <module>r      s   
  0 0 0 0 0 0 8 8 8 8 8 8 8 8 = = = = = =
/ 
/ 
/ 
/ 
/	 
/ 
/ 
/	 	 	 	 	 	 	 	g g g g g g g gT&# &# &# &# &# &# &# &# &# &#r   