Skip to content

Commit

Permalink
fix(db-engine-spec): execute oracle DML statement bug in sqllab (apac…
Browse files Browse the repository at this point in the history
…he#10706)

* fix execute oracle DML statement bug in sqllab

when i execute oracle sql statements like update in SQLLAB, get "oracle error: not a query" error. 

Refer https://www.python.org/dev/peps/pep-0249/, superset old version use
`cursor.description` ,because this attribute will be None for operations that do not return rows or if the cursor has not had an operation invoked via the .execute*() method yet.

* Apply suggestions from code review

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>

* Update oracle.py

* Update oracle.py

* Update oracle.py

* Apply suggestions from code review

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>

* Update oracle.py

* Update superset/db_engine_specs/oracle.py

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
  • Loading branch information
chuancyzhang and villebro committed Sep 16, 2020
1 parent 45e6c0c commit 8f109a5
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion superset/db_engine_specs/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
from datetime import datetime
from typing import Optional
from typing import Any, List, Optional, Tuple

from superset.db_engine_specs.base import BaseEngineSpec, LimitMethod
from superset.utils import core as utils
Expand Down Expand Up @@ -57,3 +57,16 @@ def epoch_to_dttm(cls) -> str:
@classmethod
def epoch_ms_to_dttm(cls) -> str:
return "TO_DATE('1970-01-01','YYYY-MM-DD')+(1/24/60/60/1000)*{col}"

@classmethod
def fetch_data(
cls, cursor: Any, limit: Optional[int] = None
) -> List[Tuple[Any, ...]]:
"""
:param cursor: Cursor instance
:param limit: Maximum number of rows to be returned by the cursor
:return: Result of query
"""
if not cursor.description:
return []
return super().fetch_data(cursor, limit)

0 comments on commit 8f109a5

Please sign in to comment.