Handle SQLite substr syntax

Addresses https://github.com/torchbox/wagtail/issues/11