Skip to content

Commit

Permalink
allow for any directory
Browse files Browse the repository at this point in the history
  • Loading branch information
kabulov kozim committed Apr 18, 2024
1 parent c2eba74 commit b1f0d0e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def drop_table(self, base, engine):
base.metadata.drop_all(engine)

def test_directories(self):
engine_good = sa.create_engine(config.db_url, directories=["dir"])
engine_good = sa.create_engine(config.db_url, has_directories=True)
base, Table, session = self.prepare_table(engine_good)
row = self.try_update(session, Table)
assert row.id == 2
Expand Down
9 changes: 4 additions & 5 deletions ydb_sqlalchemy/sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ def __init__(
json_serializer=None,
json_deserializer=None,
_add_declare_for_yql_stmt_vars=False,
directories=[],
has_directories=False,
**kwargs,
):
super().__init__(**kwargs)
Expand All @@ -599,7 +599,7 @@ def __init__(
# NOTE: _add_declare_for_yql_stmt_vars is temporary and is soon to be removed.
# no need in declare in yql statement here since ydb 24-1
self._add_declare_for_yql_stmt_vars = _add_declare_for_yql_stmt_vars
self._directories = directories
self._has_directories = has_directories

def _describe_table(self, connection, table_name, schema=None):
if schema is not None:
Expand Down Expand Up @@ -682,9 +682,8 @@ def do_commit(self, dbapi_connection: dbapi.Connection) -> None:
dbapi_connection.commit()

def _fix_variable_name(self, variable):
for directory in self._directories:
if variable.startswith(f"{directory}/"):
return f"{directory}_" + variable[len(directory) + 1 :]
if self._has_directories:
return variable.replace("/", "_")
return variable

def _format_variables(
Expand Down

0 comments on commit b1f0d0e

Please sign in to comment.