My name is Hiroyuki Yamashia.

Create SQL query function is wrong by Django2.0.7.

I using MariaDB and using "__regex".

Django2.0.7 is generate this SQL query.

SELECT `scanner_tmpresponse_07`.`id` FROM `scanner_tmpresponse_07`
WHERE (`scanner_tmpresponse_07`.`audit_history_id` = 225 AND
`scanner_tmpresponse_07`.`deleted` = False AND
`scanner_tmpresponse_07`.`disabled` = False AND
REGEXP_LIKE(`scanner_tmpresponse_07`.`response_body`,
.*192\.168\.\d+\.\d+.*, 'c')) ORDER BY `scanner_tmpresponse_07`.`id`
ASC

I think "REGEXP_LIKE" is Oracle function for Regular expression.

Django2.0.6 is generate this SQL query.
This version is no problem.

SELECT `scanner_tmpresponse_07`.`id` FROM `scanner_tmpresponse_07`
WHERE (`scanner_tmpresponse_07`.`audit_history_id` = 224 AND
`scanner_tmpresponse_07`.`deleted` = False AND
`scanner_tmpresponse_07`.`disabled` = False AND
`scanner_tmpresponse_07`.`response_body` REGEXP BINARY
.*192\.168\.\d+\.\d+.*) ORDER BY `scanner_tmpresponse_07`.`id` ASC


#-------------------------
settings.py

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME' : 'XXXXXXX',
            'HOST' : 'localhost',
            'USER' : 'XXXXXXXX',
            'PASSWORD' : 'XXXXXXXXX',
            'PORT' : '3306',
    #        'ATOMIC_REQUESTS':True,

        },
    'scanner': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME' : 'XXXXXXX',
            'HOST' : 'localhost',
            'USER' : 'XXXXXXXX',
            'PASSWORD' : 'XXXXXXXXX',
            'PORT' : '3306',
    #        'ATOMIC_REQUESTS':True,

        },
    'portal': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME' : 'XXXXXXX',
            'HOST' : 'localhost',
            'USER' : 'XXXXXXXX',
            'PASSWORD' : 'XXXXXXXXX',
            'PORT' : '3306',
    #        'ATOMIC_REQUESTS':True,
        }
    }

#-------------------------

Traceback (most recent call last):

  File 
"/opt/virtual_setting/release/lib/python3.6/site-packages/django/db/backends/utils.py",
line 85, in _execute
    return self.cursor.execute(sql, params)

  File 
"/opt/virtual_setting/release/lib/python3.6/site-packages/django/db/backends/mysql/base.py",
line 71, in execute
    return self.cursor.execute(query, args)

  File 
"/opt/virtual_setting/release/lib/python3.6/site-packages/MySQLdb/cursors.py",
line 250, in execute
    self.errorhandler(self, exc, value)

  File 
"/opt/virtual_setting/release/lib/python3.6/site-packages/MySQLdb/connections.py",
line 50, in defaulterrorhandler
    raise errorvalue

  File 
"/opt/virtual_setting/release/lib/python3.6/site-packages/MySQLdb/cursors.py",
line 247, in execute
    res = self._query(query)

  File 
"/opt/virtual_setting/release/lib/python3.6/site-packages/MySQLdb/cursors.py",
line 412, in _query
    rowcount = self._do_query(q)

  File 
"/opt/virtual_setting/release/lib/python3.6/site-packages/MySQLdb/cursors.py",
line 375, in _do_query
    db.query(q)

  File 
"/opt/virtual_setting/release/lib/python3.6/site-packages/MySQLdb/connections.py",
line 276, in query
    _mysql.connection.query(self, query)

_mysql_exceptions.OperationalError: (1305, 'FUNCTION
scanner.REGEXP_LIKE does not exist')


The above exception was the direct cause of the following exception:


-- 
==============================
Hiroyuki Yamashita 山下 裕之
==============================

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPfm6S0%2BzfGFOhd3MYCRSzca3XEO1ZJGQmde2zkBwGqO4yHNVQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to