
    h                     6    S SK Jr  S SKJrJr   " S S\5      rg)    )DatabaseSchemaEditor)ColFuncc                   b   ^  \ rS rSrSrSrSrSrSrS r	U 4S jr
S	S
.U 4S jjrU 4S jrSrU =r$ )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                 L    U R                   R                  R                  U5      $ )N)
connectionopsgeo_quote_name)selfnames     _/var/www/html/env/lib/python3.13/site-packages/django/contrib/gis/db/backends/postgis/schema.pyr   "PostGISSchemaEditor.geo_quote_name   s    ""11$77    c                 H   > [        USS5      (       a  g[        TU ]	  X5      $ )Nspatial_indexFT)getattrsuper_field_should_be_indexed)r   modelfield	__class__s      r   r   ,PostGISSchemaEditor._field_should_be_indexed   s%    5/511w/==r   N)fieldsc          	        > Ub#  [        U5      S:w  d  [        US   S5      (       d  [        TU ]  " U4SU0UD6$ US   nS nS nUR                  S:X  a!  [        [        S U5      U R                  S9nS nO.UR                  S:  a  UR                  (       d  U R                  /nUR                  S5      nU(       d2  U R                  UR                  R                  UR                  /S	5      n[        TU ]  UUUS
U R                   -  UUS9$ )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*   %PostGISSchemaEditor._create_index_sql   s   >S[A-WVAY
5S5S7,UL6LVLLq		??h& s4/$:R:RSKFYY]5??//0Izz&!**5;;+?+?%,,QVWDw( 4 44# ) 
 	
r   c                   > [        US5      (       a  [        US5      (       d  [        TU ]	  XX4XV5      $ UR                  S:X  a  UR                  S:X  a  U R                  nO9UR                  S:X  a  UR                  S:X  a  U R
                  nOU R                  nUU R                  UR                  5      USS.-  / 4/ 4$ )z&
Special case when dimension changed.
r-   r#       )r4   type	collation)	r)   r   _alter_column_type_sqlr-   sql_alter_column_to_3dsql_alter_column_to_2dsql_alter_column_type
quote_namer4   )	r   table	old_field	new_fieldnew_typeold_collationnew_collation	sql_alterr   s	           r   r=   *PostGISSchemaEditor._alter_column_type_sql5   s     y%((	50I0I71)}  ==A)--1"433I]]aIMMQ$633I22I "ooi.>.>?$!#  
 	
r    )__name__
__module____qualname____firstlineno__r5   r/   r,   r>   r?   r   r   r*   r=   __static_attributes____classcell__)r   s   @r   r   r      sM    O.: 	W  	W 8>
 26 
 
8
 
r   r   N)$django.db.backends.postgresql.schemar   django.db.models.expressionsr   r   r   rJ   r   r   <module>rS      s    E 2L
. L
r   