You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix schema handling in SQLTools for table inspection (#3060)
## Summary
Fixes SQLAlchemy schema handling in the SQLTools class. Currently, the
schema parameter is accepted in the constructor but not properly used
when listing tables or describing table structure. This causes errors
when working with databases where tables exist in non-default schemas
(outside of "public" in PostgreSQL).
## Type of change
- [x] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Improvement
- [ ] Model update
- [ ] Other:
---
## Checklist
- [x] Code complies with style guidelines
- [x] Ran format/validation scripts (`./scripts/format.sh` and
`./scripts/validate.sh`)
- [x] Self-review completed
- [x] Documentation updated (comments, docstrings)
- [ ] Examples and guides: Relevant cookbook examples have been included
or updated (if applicable)
- [x] Tested in clean environment
- [ ] Tests added/updated (if applicable)
---
## Additional Notes
The core issue is that SQLAlchemy defaults to the "public" schema in
PostgreSQL when no schema is specified in the inspector methods. Even
though a schema parameter is provided to the SQLTools constructor, it
wasn't being passed to the underlying inspector calls.
This fix ensures that:
1. When listing tables with `list_tables()`, we properly pass the schema
parameter to `get_table_names()`
2. When describing a table with `describe_table()`, we correctly use the
schema parameter with `get_columns()`
3. Error logging has been improved throughout the class
This resolves the "table not found" errors that occur when working with
databases where tables are located in non-default schemas, such as when
using a schema other than "public" in PostgreSQL.
Tested with PostgreSQL database with tables in custom schemas to verify
the fix works properly.
---------
Co-authored-by: Tiberiu Scarlat <tiberiu.scarlat@arnia.ro>
Co-authored-by: Yash Pratap Solanky <101447028+ysolanky@users.noreply.github.com>
0 commit comments