Skip to content

Commit

Permalink
Remove defunct table name mangling code
Browse files Browse the repository at this point in the history
This table name mangling logic is a holdover from the Oracle implementation and the current implementation is a no-op.  The logic was being inconsistently applied so none of this would have worked even in a new implementation that had a real implementation of the mangling function.
  • Loading branch information
dhirving committed Jan 6, 2025
1 parent 4c0370c commit 952a2f8
Showing 1 changed file with 2 additions and 30 deletions.
32 changes: 2 additions & 30 deletions python/lsst/daf/butler/registry/interfaces/_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,30 +856,6 @@ def expandDatabaseEntityName(self, shrunk: str) -> str:
"""
return shrunk

def _mangleTableName(self, name: str) -> str:
"""Map a logical, user-visible table name to the true table name used
in the database.
The default implementation returns the given name unchanged.
Parameters
----------
name : `str`
Input table name. Should not include a namespace (i.e. schema)
prefix.
Returns
-------
mangled : `str`
Mangled version of the table name (still with no namespace prefix).
Notes
-----
Reimplementations of this method must be idempotent - mangling an
already-mangled name must have no effect.
"""
return name

def _makeColumnConstraints(self, table: str, spec: ddl.FieldSpec) -> list[sqlalchemy.CheckConstraint]:
"""Create constraints based on this spec.
Expand Down Expand Up @@ -972,13 +948,11 @@ def _convertForeignKeySpec(
SQLAlchemy representation of the constraint.
"""
name = self.shrinkDatabaseEntityName(
"_".join(
["fkey", table, self._mangleTableName(spec.table)] + list(spec.target) + list(spec.source)
)
"_".join(["fkey", table, spec.table] + list(spec.target) + list(spec.source))
)
return sqlalchemy.schema.ForeignKeyConstraint(
spec.source,
[f"{self._mangleTableName(spec.table)}.{col}" for col in spec.target],
[f"{spec.table}.{col}" for col in spec.target],
name=name,
ondelete=spec.onDelete,
)
Expand Down Expand Up @@ -1048,7 +1022,6 @@ def _convertTableSpec(
avoid circular dependencies. These are added by higher-level logic in
`ensureTableExists`, `getExistingTable`, and `declareStaticTables`.
"""
name = self._mangleTableName(name)
args: list[sqlalchemy.schema.SchemaItem] = [
self._convertFieldSpec(name, fieldSpec, metadata) for fieldSpec in spec.fields
]
Expand Down Expand Up @@ -1188,7 +1161,6 @@ def getExistingTable(self, name: str, spec: ddl.TableSpec) -> sqlalchemy.schema.
Subclasses may override this method, but usually should not need to.
"""
assert self._metadata is not None, "Static tables must be declared before dynamic tables."
name = self._mangleTableName(name)
table = self._metadata.get_table(name)
if table is not None:
if spec.fields.names != set(table.columns.keys()):
Expand Down

0 comments on commit 952a2f8

Please sign in to comment.