/usr/local/lib/python3.9/site-packages/django/contrib/gis/db/backends/postgis/__pycache__
a Ӱ�h� � @ s0 d dl mZ d dlmZmZ G dd� de�ZdS )� )�DatabaseSchemaEditor)�Col�Funcc sV e Zd ZdZdZdZdZdZdd� Z� fdd �Z d d�� fdd � Z � fdd�Z� ZS )�PostGISSchemaEditorZGISTZGIST_GEOMETRY_OPS_NDzST_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 C s | j j�|�S )N)� connection�ops�geo_quote_name)�self�name� r �W/usr/local/lib/python3.9/site-packages/django/contrib/gis/db/backends/postgis/schema.pyr s z"PostGISSchemaEditor.geo_quote_namec s t |dd�rdS t� �||�S )NZ spatial_indexFT)�getattr�super�_field_should_be_indexed)r �model�field�� __class__r r r s z,PostGISSchemaEditor._field_should_be_indexedN)�fieldsc s� |d u s"t |�dks"t|d d�s:t� j|fd|i|��S |d }d }d }|jdkrnttd |�| jd�}d }n|jdkr�|j s�| j g}|�d�}|s�| �|j j|jgd �}t� j|||d | j ||d�S )N� r Zgeodeticr ZRASTER)�template� r Z_idz USING %s)r r �using� opclasses�expressions)�len�hasattrr �_create_index_sqlZ geom_typer r �rast_index_template�dimZ geography�geom_index_ops_nd�getZ_create_index_name�_metaZdb_table�column�geom_index_type)r r r �kwargsr r r r r r r r s* " �z%PostGISSchemaEditor._create_index_sqlc s� t |d�rt |d�s*t� �||||||�S |jdkrF|jdkrF| j}n"|jdkrb|jdkrb| j}n| j}|| �|j�|dd� g fg fS )z6 Special case when dimension changed. r r � � )r# �typeZ collation) r r �_alter_column_type_sqlr �sql_alter_column_to_3d�sql_alter_column_to_2dZsql_alter_column_typeZ quote_namer# )r �tableZ old_fieldZ new_field�new_typeZ old_collationZ new_collationZ sql_alterr r r r) 5 s&