U
    f.                     @   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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.
    ZGeometryField)ZpointZ
linestringZpolygonZ
multipointZmultilinestringZmultipolygonZgeometrycollectionN)__name__
__module____qualname____doc__r   Zbase_data_types_reverse r
   r
   [/tmp/pip-unpacked-wheel-_jot26k8/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  }|d||jf | }|s<td||jf |d }t|trd|dkrd|d tj	 }t|j
}|d }|d }i }	|dkr||	d< t|trd	|ks|d
krd
|	d< W 5 Q R X ||	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nameZfetchone	Exception
isinstanceintr   Zwkb25bitZdjangostr)
self
table_namedescriptionr   rowZogr_typeZ
field_typer   r   Zfield_paramsr
   r
   r   get_geometry_type   s0    
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)columnsZprimary_keyuniqueZforeign_keycheckindexz%s__spatial__index)superget_constraintsr   Zfetchall)r   r   r   constraintsr   	__class__r
   r   r%   A   s    z'SpatiaLiteIntrospection.get_constraints)r   r   r   r   Zdata_types_reverser   r%   __classcell__r
   r
   r'   r   r      s   $r   N)Zdjango.contrib.gis.gdalr   Z(django.db.backends.sqlite3.introspectionr   r   r   r   r
   r
   r
   r   <module>   s   