From 952a2f84d8c79596711efcfbea6aede8192eaed4 Mon Sep 17 00:00:00 2001 From: "David H. Irving" Date: Mon, 6 Jan 2025 09:36:38 -0700 Subject: [PATCH] Remove defunct table name mangling code 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. --- .../butler/registry/interfaces/_database.py | 32 ++----------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/python/lsst/daf/butler/registry/interfaces/_database.py b/python/lsst/daf/butler/registry/interfaces/_database.py index aab8bcfdee..0de21f6118 100644 --- a/python/lsst/daf/butler/registry/interfaces/_database.py +++ b/python/lsst/daf/butler/registry/interfaces/_database.py @@ -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. @@ -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, ) @@ -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 ] @@ -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()):