Fixes #1346 Indexes SQL errors

Fixes #1346