Skip to content

Commit

Permalink
fix: small fixes for the meta DB (#25067)
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida authored Aug 23, 2023
1 parent 80fcbfa commit 3630d68
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions superset/extensions/metadb.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
)
from shillelagh.filters import Equal, Filter, Range
from shillelagh.typing import RequestedOrder, Row
from sqlalchemy import MetaData, Table
from sqlalchemy import func, MetaData, Table
from sqlalchemy.engine.url import URL
from sqlalchemy.exc import NoSuchTableError
from sqlalchemy.sql import Select, select
Expand Down Expand Up @@ -397,6 +397,13 @@ def insert_row(self, row: Row) -> int:
raise ProgrammingError(f"Invalid rowid specified: {row_id}")
row[self._rowid] = row_id

if (
self._rowid
and row[self._rowid] is None
and self._table.c[self._rowid].autoincrement
):
row.pop(self._rowid)

query = self._table.insert().values(**row)

with self.engine_context() as engine:
Expand All @@ -407,7 +414,7 @@ def insert_row(self, row: Row) -> int:
if self._rowid:
return result.inserted_primary_key[0]

query = self._table.count()
query = select([func.count()]).select_from(self._table)
return connection.execute(query).scalar()

@check_dml
Expand Down

0 comments on commit 3630d68

Please sign in to comment.