diff --git a/core/src/zeit/connector/postgresql.py b/core/src/zeit/connector/postgresql.py index 7563738a83..f18a9bd102 100644 --- a/core/src/zeit/connector/postgresql.py +++ b/core/src/zeit/connector/postgresql.py @@ -73,8 +73,8 @@ def _build_filter(expr): elif op == 'eq': (var, value) = expr.operands name = var.name - namespace = var.namespace.replace(Property.NS, '', 1) - return Property.unsorted[namespace][name].as_string() == value + namespace = var.namespace.replace(Content.NS, '', 1) + return Content.unsorted[namespace][name].as_string() == value else: raise RuntimeError(f'Unknown operand {op!r} while building search query') @@ -208,7 +208,7 @@ def add(self, resource, verify_etag=True): props = self._get_properties(uniqueid) exists = props is not None if not exists: - props = Property() + props = Content() path = Path(properties=props) self.session.add(path) else: @@ -305,7 +305,7 @@ def copy(self, old_id, new_id): ) old_resource = self[old_id] old_properties = self._get_properties(old_id) - new_properties = Property() + new_properties = Content() new_properties.unsorted = old_properties.unsorted new_resource = Resource( new_id, @@ -435,10 +435,10 @@ def search(self, attrlist, expr): for item in result: yield (f'{ID_NAMESPACE}{item.parent_path}/{item.name}', item.id) else: - query = select(Path).join(Property).filter(_build_filter(expr)) + query = select(Path).join(Content).filter(_build_filter(expr)) result = self.session.execute(query) itemgetters = [ - (itemgetter(a.namespace.replace(Property.NS, '', 1)), itemgetter(a.name)) + (itemgetter(a.namespace.replace(Content.NS, '', 1)), itemgetter(a.name)) for a in attrlist ] for item in result.scalars(): @@ -468,7 +468,7 @@ class Path(DBObject): index=True, ) properties = relationship( - 'Property', + 'Content', uselist=False, lazy='joined', backref=backref('path', uselist=False, cascade='all, delete-orphan', passive_deletes=True), @@ -505,7 +505,7 @@ def create(cls, path, principal, until): return stmt, token -class Property(DBObject): +class Content(DBObject): __tablename__ = 'properties' id = Column(Uuid(as_uuid=False), primary_key=True) diff --git a/core/src/zeit/connector/tests/test_postgresql.py b/core/src/zeit/connector/tests/test_postgresql.py index 6ac2c135b4..0e2b5bf0b8 100644 --- a/core/src/zeit/connector/tests/test_postgresql.py +++ b/core/src/zeit/connector/tests/test_postgresql.py @@ -128,7 +128,7 @@ def test_delete_ignores_nonexistent_gcs_blob(self): del self.connector[res.id] def test_delete_removes_rows_from_all_tables(self): - from zeit.connector.postgresql import Path, Property + from zeit.connector.postgresql import Content, Path res = self.get_resource('foo', b'mybody') self.connector.add(res) @@ -137,7 +137,7 @@ def test_delete_removes_rows_from_all_tables(self): del self.connector[res.id] transaction.commit() self.assertEqual(None, self.connector.session.get(Path, self.connector._pathkey(res.id))) - self.assertEqual(None, self.connector.session.get(Property, uuid)) + self.assertEqual(None, self.connector.session.get(Content, uuid)) def test_search_for_uuid_uses_indexed_column(self): res = self.get_resource('foo', b'mybody')