Skip to content

Commit

Permalink
Upgrade requirements + sqlachemy 2.0 prep (#94)
Browse files Browse the repository at this point in the history
Issue #90
  • Loading branch information
Wim-De-Clercq authored Jan 11, 2023
1 parent fc5ddd2 commit e2d4f36
Show file tree
Hide file tree
Showing 9 changed files with 329 additions and 225 deletions.
13 changes: 5 additions & 8 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@
--requirement requirements.txt

# Postgresql database access
psycopg2==2.9.2
psycopg2==2.9.5

# Documentation
Sphinx==4.3.1
Sphinx==6.0.0

# Testing
pytest==6.2.5
pytest-cov==3.0.0
pytest==7.2.0
pytest-cov==4.0.0
coveralls==3.3.1

# Linting
flake8==4.0.1
mccabe==0.6.1
pep8==1.7.1
pyflakes==2.4.0
flake8==6.0.0
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
SQLAlchemy==1.4.28
skosprovider==1.1.0
SQLAlchemy==1.4.45
skosprovider==1.2.0
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/usr/bin/env python

import os
import sys

try:
from setuptools import setup
except ImportError:
Expand All @@ -13,7 +10,7 @@
]

requires = [
'skosprovider>=1.1.0',
'skosprovider>=1.2.0',
'sqlalchemy',
]

Expand Down
18 changes: 11 additions & 7 deletions skosprovider_sqlalchemy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
from sqlalchemy import Text
from sqlalchemy import UniqueConstraint
from sqlalchemy import event
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import orm
from sqlalchemy.ext.hybrid import hybrid_property
from sqlalchemy.orm import backref
from sqlalchemy.orm import relationship

log = logging.getLogger(__name__)
Base = declarative_base()
Base = orm.declarative_base()

concept_label = Table(
'concept_label',
Expand Down Expand Up @@ -199,7 +199,9 @@ class Thing(Base):
single_parent=True
)

conceptscheme = relationship('ConceptScheme', backref='concepts')
conceptscheme = relationship(
'ConceptScheme', backref=orm.backref('concepts', cascade_backrefs=False)
)
conceptscheme_id = Column(
Integer,
ForeignKey('conceptscheme.id'),
Expand Down Expand Up @@ -253,19 +255,21 @@ class Concept(Thing):
narrower_concepts = relationship(
'Concept',
secondary=concept_hierarchy_concept,
backref=backref('broader_concepts', collection_class=set),
backref=backref('broader_concepts', collection_class=set, cascade_backrefs=False),
primaryjoin='Concept.id==concept_hierarchy_concept.c.concept_id_broader',
secondaryjoin='Concept.id==concept_hierarchy_concept.c.concept_id_narrower',
collection_class=set
collection_class=set,
cascade_backrefs=False,
)

narrower_collections = relationship(
'Collection',
secondary=concept_hierarchy_collection,
backref=backref('broader_concepts', collection_class=set),
backref=backref('broader_concepts', collection_class=set, cascade_backrefs=False),
primaryjoin='Concept.id==concept_hierarchy_collection.c.concept_id_broader',
secondaryjoin='Concept.id==concept_hierarchy_collection.c.collection_id_narrower',
collection_class=set
collection_class=set,
cascade_backrefs=False,
)

__mapper_args__ = {
Expand Down
Loading

0 comments on commit e2d4f36

Please sign in to comment.