Rename Trade.session to Trade._session
This commit is contained in:
parent
ea0b47a7f9
commit
7132aefd60
@ -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
|
# https://docs.sqlalchemy.org/en/13/orm/contextual.html#thread-local-scope
|
||||||
# Scoped sessions proxy requests to the appropriate thread-local session.
|
# Scoped sessions proxy requests to the appropriate thread-local session.
|
||||||
# We should use the scoped_session object - not a seperately initialized version
|
# We should use the scoped_session object - not a seperately initialized version
|
||||||
Trade.session = scoped_session(sessionmaker(bind=engine, autoflush=True, autocommit=True))
|
Trade._session = scoped_session(sessionmaker(bind=engine, autoflush=True, autocommit=True))
|
||||||
Trade.query = Trade.session.query_property()
|
Trade.query = Trade._session.query_property()
|
||||||
Order.query = Trade.session.query_property()
|
Order.query = Trade._session.query_property()
|
||||||
PairLock.query = Trade.session.query_property()
|
PairLock.query = Trade._session.query_property()
|
||||||
|
|
||||||
previous_tables = inspect(engine).get_table_names()
|
previous_tables = inspect(engine).get_table_names()
|
||||||
_DECL_BASE.metadata.create_all(engine)
|
_DECL_BASE.metadata.create_all(engine)
|
||||||
|
@ -18,8 +18,8 @@ from tests.conftest import create_mock_trades, log_has, log_has_re
|
|||||||
def test_init_create_session(default_conf):
|
def test_init_create_session(default_conf):
|
||||||
# Check if init create a session
|
# Check if init create a session
|
||||||
init_db(default_conf['db_url'], default_conf['dry_run'])
|
init_db(default_conf['db_url'], default_conf['dry_run'])
|
||||||
assert hasattr(Trade, 'session')
|
assert hasattr(Trade, '_session')
|
||||||
assert 'scoped_session' in type(Trade.session).__name__
|
assert 'scoped_session' in type(Trade._session).__name__
|
||||||
|
|
||||||
|
|
||||||
def test_init_custom_db_url(default_conf, tmpdir):
|
def test_init_custom_db_url(default_conf, tmpdir):
|
||||||
|
Loading…
Reference in New Issue
Block a user