Skip to content

Commit

Permalink
Add config_path to Schema and QueryBuilder classes
Browse files Browse the repository at this point in the history
  • Loading branch information
matt2930 committed Dec 5, 2023
1 parent 879a904 commit 7a09edd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/masoniteorm/connections/ConnectionResolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def __init__(self, config_path=None):
MSSQLConnection,
)

self.config_path = config_path
from ..connections import ConnectionFactory

self.connection_factory = ConnectionFactory(config_path=config_path)
Expand Down
6 changes: 4 additions & 2 deletions src/masoniteorm/query/QueryBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(
scopes=None,
schema=None,
dry=False,
config_path=None
):
"""QueryBuilder initializer
Expand All @@ -57,6 +58,7 @@ def __init__(
connection {masoniteorm.connection.Connection} -- A connection class (default: {None})
table {str} -- the name of the table (default: {""})
"""
self.config_path = config_path
self.grammar = grammar
self.table(table)
self.dry = dry
Expand Down Expand Up @@ -103,7 +105,7 @@ def __init__(
self.set_action("select")

if not self._connection_details:
DB = load_config().DB
DB = load_config(config_path=self.config_path).DB
self._connection_details = DB.get_connection_details()

self.on(connection)
Expand Down Expand Up @@ -382,7 +384,7 @@ def method(*args, **kwargs):
)

def on(self, connection):
DB = load_config().DB
DB = load_config(self.config_path).DB

if connection == "default":
self.connection = self._connection_details.get("default")
Expand Down
4 changes: 3 additions & 1 deletion src/masoniteorm/schema/Schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def __init__(
grammar=None,
connection_details=None,
schema=None,
config_path=None
):
self._dry = dry
self.connection = connection
Expand All @@ -68,6 +69,7 @@ def __init__(
self._blueprint = None
self._sql = None
self.schema = schema
self.config_path = config_path

if not self.connection_class:
self.on(self.connection)
Expand All @@ -85,7 +87,7 @@ def on(self, connection_key):
Returns:
cls
"""
DB = load_config().DB
DB = load_config(config_path=self.config_path).DB

if connection_key == "default":
self.connection = self.connection_details.get("default")
Expand Down

0 comments on commit 7a09edd

Please sign in to comment.