o
    <g.                     @   s@   d dl mZ d dlmZmZ G dd deZG dd deZdS )    )OGRGeomType)DatabaseIntrospectionFlexibleFieldLookupDictc                	   @   s.   e Zd ZdZi ejddddddddZdS )GeoFlexibleFieldLookupDictzi
    Subclass that includes updates the `base_data_types_reverse` dict
    for geometry field types.
    GeometryField)point
linestringpolygon
multipointmultilinestringmultipolygongeometrycollectionN)__name__
__module____qualname____doc__r   base_data_types_reverse r   r   j/var/www/html/venv/lib/python3.10/site-packages/django/contrib/gis/db/backends/spatialite/introspection.pyr      s    r   c                       s*   e Zd Ze Zdd Z fddZ  ZS )SpatiaLiteIntrospectionc           
      C   s   | j  i}|d||jf | }|std||jf |d }t|tr2|dkr2|d tj	 }t|j
}|d }|d }i }	|dkrI||	d< t|trRd	|v sV|d
krdd
|	d< W d    ||	fS W d    ||	fS 1 sqw   Y  ||	fS )NzpSELECT coord_dimension, srid, geometry_type FROM geometry_columns WHERE f_table_name=%s AND f_geometry_column=%sz.Could not find a geometry column for "%s"."%s"   i  r      i  sridZ   dim)
connectioncursorexecutenamefetchone	Exception
isinstanceintr   wkb25bitdjangostr)
self
table_namedescriptionr   rowogr_type
field_typer   r   field_paramsr   r   r   get_geometry_type   s<   


!
!!z)SpatiaLiteIntrospection.get_geometry_typec                    sR   t  ||}|d|f | D ]}|d gddd ddd|d|d  < q|S )Nz`SELECT f_geometry_column FROM geometry_columns WHERE f_table_name=%s AND spatial_index_enabled=1r   FT)columnsprimary_keyuniqueforeign_keycheckindexz%s__spatial__index)superget_constraintsr   fetchall)r'   r   r(   constraintsr*   	__class__r   r   r6   A   s   z'SpatiaLiteIntrospection.get_constraints)r   r   r   r   data_types_reverser.   r6   __classcell__r   r   r9   r   r      s    $r   N)django.contrib.gis.gdalr   (django.db.backends.sqlite3.introspectionr   r   r   r   r   r   r   r   <module>   s    