
    Dvg                     >    d dl mZ d dlmZmZ  G d de          ZdS )    )DatabaseSchemaEditor)ColFuncc                   R     e Zd ZdZdZdZdZdZd Z fdZ	dd	 fd

Z
 fdZ xZS )PostGISSchemaEditorGISTGIST_GEOMETRY_OPS_NDzST_ConvexHull(%(expressions)s)zLALTER COLUMN %(column)s TYPE %(type)s USING ST_Force3D(%(column)s)::%(type)szLALTER COLUMN %(column)s TYPE %(type)s USING ST_Force2D(%(column)s)::%(type)sc                 @    | j         j                            |          S )N)
connectionopsgeo_quote_name)selfnames     j/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/contrib/gis/db/backends/postgis/schema.pyr   z"PostGISSchemaEditor.geo_quote_name   s    "11$777    c                 n    t          |dd          rdS t                                          ||          S )Nspatial_indexFT)getattrsuper_field_should_be_indexed)r   modelfield	__class__s      r   r   z,PostGISSchemaEditor._field_should_be_indexed   s6    5/511 	4ww//u===r   N)fieldsc                   |)t          |          dk    st          |d         d          s t                      j        |fd|i|S |d         }d }d }|j        dk    r't          t          d |          | j                  }d }n|j        dk    r|j	        s| j
        g}|                    d          }|s'|                     |j        j        |j        gd	          }t                                          |||d
| j        z  ||          S )N   r   geodeticr   RASTER)template   r   _idz	 USING %s)r   r   using	opclassesexpressions)lenhasattrr   _create_index_sql	geom_typer   r   rast_index_templatedim	geographygeom_index_ops_ndget_create_index_name_metadb_tablecolumngeom_index_type)	r   r   r   kwargsr   r$   r#   r   r   s	           r   r'   z%PostGISSchemaEditor._create_index_sql   s)   >S[[A--WVAY
5S5S-,577,ULL6LVLLLq		?h&& s4//$:RSSSKFFY]]5?]/0Izz&!! 	X**5;+?%,QVWWDww(( 44# ) 
 
 	
r   c                 `   t          |d          rt          |d          s&t                                          ||||||          S |j        dk    r|j        dk    r| j        }n%|j        dk    r|j        dk    r| j        }n| j        }||                     |j                  |ddz  g fg fS )z6
        Special case when dimension changed.
        r*   r        )r1   type	collation)	r&   r   _alter_column_type_sqlr*   sql_alter_column_to_3dsql_alter_column_to_2dsql_alter_column_type
quote_namer1   )	r   table	old_field	new_fieldnew_typeold_collationnew_collation	sql_alterr   s	           r   r9   z*PostGISSchemaEditor._alter_column_type_sql5   s     y%(( 		50I0I 	7711y)X}m   =A)-1"4"43II]aIMQ$6$63II2I "ooi.>??$!#   
 	
r   )__name__
__module____qualname__r2   r,   r)   r:   r;   r   r   r'   r9   __classcell__)r   s   @r   r   r      s        O.: 	W  	W 8 8 8> > > > >
 26 
 
 
 
 
 
 
8
 
 
 
 
 
 
 
 
r   r   N)$django.db.backends.postgresql.schemar   django.db.models.expressionsr   r   r    r   r   <module>rL      sn    E E E E E E 2 2 2 2 2 2 2 2L
 L
 L
 L
 L
. L
 L
 L
 L
 L
r   