Fixes #1346 Indexes SQL errors

#1346