Skip to content

Commit

Permalink
fix(sqlite): list temp tables when no database is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Sep 7, 2024
1 parent 7bfc9f7 commit 415e298
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions ibis/backends/sqlite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,24 @@ def list_tables(
Database to list tables from. Default behavior is to show tables in
the current database.
"""
if database is None:
if show_temp := (database is None):
database = "main"

schemas = [sge.convert(database)]
if show_temp:
schemas.append(sge.convert("temp"))

sql = (
sg.select("name")
.from_(F.pragma_table_list())
.where(
C.schema.eq(sge.convert(database)),
C.schema.isin(*schemas),
C.type.isin(sge.convert("table"), sge.convert("view")),
~(
C.name.isin(
sge.convert("sqlite_schema"),
sge.convert("sqlite_master"),
sge.convert("sqlite_temp_schema"),
sge.convert("sqlite_temp_master"),
)
~C.name.isin(
sge.convert("sqlite_schema"),
sge.convert("sqlite_master"),
sge.convert("sqlite_temp_schema"),
sge.convert("sqlite_temp_master"),
),
)
.sql(self.name)
Expand Down

0 comments on commit 415e298

Please sign in to comment.