You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should be able to specify a different default schema at the DB level from the beginning, and have all operations operate in that scope without further annotation. If I want to set a default schema on initialization with Postgres, I have to use the options binding to specify -c search_path=<schema> as a string. There should be a native way to set the schema.
There are also hard-coded assumptions that we are in the default schema. For example, dbapiprovider.py:split_table_name starts with this:
def split_table_name(provider, table_name):
if isinstance(table_name, str): return provider.default_schema_name, table_name
Given a table name, it hard codes its schema scope to the default_schema_name, even if the current DB connection is using a different schema. This is called by DBAPIProvider.table_exists to check if a table should be created when mappings are being generated. The default schema hard-code causes this to return False, as it's looking for the tables in the wrong schema, causing it to attempt to create a table that already exists (because the connection it uses to attempt to then create it is in the correct schema).
As a workaround, I subclassed the PGProvider and overrode split_table_name to return the current schema, but the correct solution is for the native Provider to handle this.
class MyPGProvider(PGProvider):
def __init__(self, *args, schema: str = None, **kwargs):
self._schema = schema
super().__init__(*args, **kwargs)
def split_table_name(self, table_name):
if self._schema:
return self._schema, table_name
else:
return super(self.__class__.__base__, self).split_table_name(table_name) # Let it use the default schema
The text was updated successfully, but these errors were encountered:
We should be able to specify a different default schema at the DB level from the beginning, and have all operations operate in that scope without further annotation. If I want to set a default schema on initialization with Postgres, I have to use the
options
binding to specify-c search_path=<schema>
as a string. There should be a native way to set the schema.There are also hard-coded assumptions that we are in the default schema. For example,
dbapiprovider.py:split_table_name
starts with this:Given a table name, it hard codes its schema scope to the default_schema_name, even if the current DB connection is using a different schema. This is called by
DBAPIProvider.table_exists
to check if a table should be created when mappings are being generated. The default schema hard-code causes this to returnFalse
, as it's looking for the tables in the wrong schema, causing it to attempt to create a table that already exists (because the connection it uses to attempt to then create it is in the correct schema).As a workaround, I subclassed the
PGProvider
and overrodesplit_table_name
to return the current schema, but the correct solution is for the native Provider to handle this.The text was updated successfully, but these errors were encountered: