BUG: fix checking of table name in read_sql (GH7826)

Closes #7826.