Skip to content

Commit

Permalink
fix(data): create a session will default to config values
Browse files Browse the repository at this point in the history
Fixes: #448
  • Loading branch information
piraz committed Apr 21, 2024
1 parent 0bc6560 commit 98345ea
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions firenado/data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2015-2023 Flavio Garcia
# Copyright 2015-2024 Flavio Garcia
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -147,7 +147,7 @@ def __init__(self, data_connected):
self.__connection = {
'backend': None,
'session': {
'autoflush': True,
'autoflush': False,
'expire_on_commit': True,
'info': None
}
Expand Down Expand Up @@ -273,14 +273,16 @@ def get_a_session(self, **kwargs) -> Session:
Default parameters based on: https://bit.ly/3MjWDzF
:param dict kwargs:
:key bool autoflush: Default to True
:key bool expire_on_commit: Default to False
:key bool autoflush: Default to False
:key bool expire_on_commit: Default to True
:key dict info: Default to None
:return Session:
"""
autoflush = kwargs.get("autoflush", True)
expire_on_commit = kwargs.get("expire_on_commit", True)
info = kwargs.get("info")
session_config = self.__connection['session']
autoflush = kwargs.get("autoflush", session_config['autoflush'])
expire_on_commit = kwargs.get("expire_on_commit",
session_config['expire_on_commit'])
info = kwargs.get("info", session_config['info'])

from sqlalchemy.orm import sessionmaker
Session = sessionmaker(bind=self.__engine, autoflush=autoflush,
Expand Down

0 comments on commit 98345ea

Please sign in to comment.