Revision history [back]
mysql: Duplicate entry on inserting line to autolinking patterns
Hello! and welcome to the Black Mesa...
Sorry for new long post, but it is very interesting project to me and I want to help it in a way I can.
After some experiments with autolinkink patterns I found strange error on inserting any new line to existing autolinking patterns:
uawiki:((.+))
(ru|en)wiki:((.+))
вики:((.+))
google:((.+))
поиск:((.+))
вопрос№(\d+)http://uk.wikipedia.org/wiki/\1
http://\1.wikipedia.org/wiki/\2
http://ru.wikipedia.org/wiki/\1
https://google.com/search?q=\1
https://google.com/search?q=\1
http://help.local/question/\1
It all starts when I try to use supergreed quantificator (+) in pattern regexp. When I change/delete any (first or last) pattern or add any new line - error shows up. When I delete all patterns, reload page and add one or all patterns again, all works fine but only if I don't change patterns again.
Next strange thing is when I delete all the patterns (and leave an empty field) they don't remove from DB:
mysql> select * from livesettings_longsetting where livesettings_longsetting.group like '%MARKUP%';
id | site_id | group | key | value |
---|---|---|---|---|
11 | 1 | MARKUP | AUTO_LINK_URLS | http://uk.wikipedia.org/wiki/\1 http://\1.wikipedia.org/wiki/\2 http://ru.wikipedia.org/wiki/\1 https://google.com/search?q=\1 https://google.com/search?q=\1 http://help.local/question/\1 |
12 | 1 | MARKUP | AUTO_LINK_PATTERNS | uawiki:\((.+)\) (ru|en)wiki:\((.+)\) ����:\((.+)\) google:\((.+)\) �����:\((.+)\) ������?(\d+) |
2 rows in set (0.00 sec)
Traceback (most recent call last):
File "/var/src/askbot-devel/askbot_env/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/var/src/askbot-devel/askbot_env/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/views/decorators/cache.py", line 79, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/var/src/askbot-devel/askbot_env/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/contrib/admin/views/decorators.py", line 19, in _checklogin
return view_func(request, *args, **kwargs)
File "/var/src/askbot-devel/askbot/deps/livesettings/views.py", line 45, in group_settings
if cfg.update(value):
File "/var/src/askbot-devel/askbot/deps/livesettings/values.py", line 366, in update
s.save()
File "/var/src/askbot-devel/askbot/deps/livesettings/models.py", line 165, in save
super(LongSetting, self).save(force_insert=force_insert, force_update=force_update)
File "/var/src/askbot-devel/askbot_env/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/db/models/base.py", line 460, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/var/src/askbot-devel/askbot_env/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/db/models/base.py", line 553, in save_base
result = manager._insert(values, return_id=update_pk, using=using)
File "/var/src/askbot-devel/askbot_env/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/db/models/manager.py", line 195, in _insert
return insert_query(self.model, values, **kwargs)
File "/var/src/askbot-devel/askbot_env/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/db/models/query.py", line 1436, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "/var/src/askbot-devel/askbot_env/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/db/models/sql/compiler.py", line 791, in execute_sql
cursor = super(SQLInsertCompiler, self).execute_sql(None)
File "/var/src/askbot-devel/askbot_env/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/db/models/sql/compiler.py", line 735, in execute_sql
cursor.execute(sql, params)
File "/var/src/askbot-devel/askbot_env/local/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/db/backends/mysql/base.py", line 86, in execute
return self.cursor.execute(query, args)
File "/var/src/askbot-devel/askbot_env/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "/var/src/askbot-devel/askbot_env/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
IntegrityError: (1062, "Duplicate entry '1-MARKUP-AUTO_LINK_URLS' for key 2")