Handle SQLite substr syntax

Addresses https://github.com/torchbox/wagtail/issues/11
pull/13/merge
Tom Dyson 2014-02-08 23:44:42 +00:00 zatwierdzone przez Matt Westcott
rodzic 439b5e664a
commit c23ff87235
1 zmienionych plików z 14 dodań i 5 usunięć

Wyświetl plik

@ -248,11 +248,20 @@ class Page(MP_Node, ClusterableModel, Indexed):
def _update_descendant_url_paths(self, old_url_path, new_url_path):
cursor = connection.cursor()
cursor.execute("""
UPDATE wagtailcore_page
SET url_path = %s || substring(url_path from %s)
WHERE path LIKE %s AND id <> %s
""", [new_url_path, len(old_url_path) + 1, self.path + '%', self.id])
if connection.vendor == 'sqlite':
update_statement = """
UPDATE wagtailcore_page
SET url_path = %s || substr(url_path, %s)
WHERE path LIKE %s AND id <> %s
"""
else:
update_statement = """
UPDATE wagtailcore_page
SET url_path = %s || substring(url_path from %s)
WHERE path LIKE %s AND id <> %s
"""
cursor.execute(update_statement,
[new_url_path, len(old_url_path) + 1, self.path + '%', self.id])
def object_indexed(self):
# Exclude root node from index