a
    Kcò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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.
    ZGeometryField)ÚpointZ
linestringZpolygonZ
multipointZmultilinestringZmultipolygonZgeometrycollectionN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Zbase_data_types_reverse© r   r   út/home/httpd/docs/test/DocsMgr/lib/python3.9/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  ¡ �¸}| 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ƒr¤d	|v s¬|d
kr´d
|	d< W d   ƒ n1 sÈ0    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ÚnameZfetchoneÚ	ExceptionÚ
isinstanceÚintr   Zwkb25bitÚ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   