jeremyevans/sequel — Issue #422: #table_exists? does not work with partial permissions
Author: xaviershay
Created: 2012-01-12 20:04:13+00:00
State: open

The use for a SELECT for `table_exists?` does not work when the client only has partial permissions on a table in MySQL.

The following should demonstrate (on many dev mysql installs every user has access to everything though which won't allow the bug to be demonstrated - you'll have to revoke this first).

```
CREATE DATABASE test_db;
CREATE TABLE test_db.test_table (col1 int, col2 int);
GRANT SELECT (col1) ON test_db.test_table TO test_user;

-- as test_user
SELECT * FROM test_db.test_table LIMIT 1; -- wil raise an exception
```

I am using the following code instead:

```
begin
db.schema(table_name)
rescue Sequel::DatabaseError
false
end
```

Not sure if there's a good reason you're not doing it this way already.