Commit c47364ef authored by Claude Paroz's avatar Claude Paroz
Browse files

Fixed #26134 -- Used new OpenGIS names for recent MySQL

Thanks František Malina for the report.
parent 9a5c9458
Loading
Loading
Loading
Loading
+28 −11
Original line number Diff line number Diff line
@@ -11,12 +11,27 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):

    mysql = True
    name = 'mysql'
    select = 'AsText(%s)'
    from_wkb = 'GeomFromWKB'
    from_text = 'GeomFromText'

    Adapter = WKTAdapter

    @cached_property
    def select(self):
        if self.connection.mysql_version < (5, 6, 0):
            return 'AsText(%s)'
        return 'ST_AsText(%s)'

    @cached_property
    def from_wkb(self):
        if self.connection.mysql_version < (5, 6, 0):
            return 'GeomFromWKB'
        return 'ST_GeomFromWKB'

    @cached_property
    def from_text(self):
        if self.connection.mysql_version < (5, 6, 0):
            return 'GeomFromText'
        return 'ST_GeomFromText'

    gis_operators = {
        'bbcontains': SpatialOperator(func='MBRContains'),  # For consistency w/PostGIS API
        'bboverlaps': SpatialOperator(func='MBROverlaps'),  # .. ..
@@ -32,11 +47,13 @@ class MySQLOperations(BaseSpatialOperations, DatabaseOperations):
        'within': SpatialOperator(func='MBRWithin'),
    }

    function_names = {
    @cached_property
    def function_names(self):
        return {
            'Difference': 'ST_Difference',
            'Distance': 'ST_Distance',
            'Intersection': 'ST_Intersection',
        'Length': 'GLength',
            'Length': 'GLength' if self.connection.mysql_version < (5, 6, 0) else 'ST_Length',
            'SymDifference': 'ST_SymDifference',
            'Union': 'ST_Union',
        }