Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Deque mutated during iteration #24550

Merged
merged 2 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions superset/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,23 +850,23 @@ def ping_connection(connection: Connection, branch: bool) -> None:
# restore 'close with result'
connection.should_close_with_result = save_should_close_with_result

if some_engine.dialect.name == "sqlite":

@event.listens_for(some_engine, "connect")
def set_sqlite_pragma( # pylint: disable=unused-argument
connection: sqlite3.Connection,
*args: Any,
) -> None:
r"""
Enable foreign key support for SQLite.

:param connection: The SQLite connection
:param \*args: Additional positional arguments
:see: https://docs.sqlalchemy.org/en/latest/dialects/sqlite.html
"""

with closing(connection.cursor()) as cursor:
cursor.execute("PRAGMA foreign_keys=ON")
if some_engine.dialect.name == "sqlite":

@event.listens_for(some_engine, "connect")
def set_sqlite_pragma( # pylint: disable=unused-argument
connection: sqlite3.Connection,
*args: Any,
) -> None:
r"""
Enable foreign key support for SQLite.

:param connection: The SQLite connection
:param \*args: Additional positional arguments
:see: https://docs.sqlalchemy.org/en/latest/dialects/sqlite.html
"""

with closing(connection.cursor()) as cursor:
cursor.execute("PRAGMA foreign_keys=ON")


def send_email_smtp( # pylint: disable=invalid-name,too-many-arguments,too-many-locals
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/databases/ssh_tunnel/dao_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_create_ssh_tunnel():
"password": "bar",
}

result = SSHTunnelDAO.create(properties)
result = SSHTunnelDAO.create(properties, commit=False)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hughhhh I set commit=False to mimic the other tests in the ssh_tunnel/commands folder which use CreateSSHTunnelCommand that has commit=False by default. If we enable the commit in this test or in the command ones, they will fail because there's no database with id = 1. If an actual commit is required for the tests, I suggest opening a follow-up PR and fixing not only this test but the ones in the commands folder.


assert result is not None
assert isinstance(result, SSHTunnel)