From 7132aefd608ab8495932f438bc66695d18d4d70f Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 5 Apr 2021 08:46:12 +0200 Subject: [PATCH] Rename Trade.session to Trade._session --- freqtrade/persistence/models.py | 8 ++++---- tests/test_persistence.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/freqtrade/persistence/models.py b/freqtrade/persistence/models.py index a82c047c3..a22e75e1e 100644 --- a/freqtrade/persistence/models.py +++ b/freqtrade/persistence/models.py @@ -59,10 +59,10 @@ def init_db(db_url: str, clean_open_orders: bool = False) -> None: # https://docs.sqlalchemy.org/en/13/orm/contextual.html#thread-local-scope # Scoped sessions proxy requests to the appropriate thread-local session. # We should use the scoped_session object - not a seperately initialized version - Trade.session = scoped_session(sessionmaker(bind=engine, autoflush=True, autocommit=True)) - Trade.query = Trade.session.query_property() - Order.query = Trade.session.query_property() - PairLock.query = Trade.session.query_property() + Trade._session = scoped_session(sessionmaker(bind=engine, autoflush=True, autocommit=True)) + Trade.query = Trade._session.query_property() + Order.query = Trade._session.query_property() + PairLock.query = Trade._session.query_property() previous_tables = inspect(engine).get_table_names() _DECL_BASE.metadata.create_all(engine) diff --git a/tests/test_persistence.py b/tests/test_persistence.py index d53386287..3336e4e66 100644 --- a/tests/test_persistence.py +++ b/tests/test_persistence.py @@ -18,8 +18,8 @@ from tests.conftest import create_mock_trades, log_has, log_has_re def test_init_create_session(default_conf): # Check if init create a session init_db(default_conf['db_url'], default_conf['dry_run']) - assert hasattr(Trade, 'session') - assert 'scoped_session' in type(Trade.session).__name__ + assert hasattr(Trade, '_session') + assert 'scoped_session' in type(Trade._session).__name__ def test_init_custom_db_url(default_conf, tmpdir):