From 8399829b263d63ba5a2db663c601913f36bdf2d9 Mon Sep 17 00:00:00 2001 From: Stephen Fuhry Date: Mon, 4 Sep 2017 00:14:17 +0000 Subject: [PATCH 1/4] don't include excluded properties --- sqlalchemy_continuum/relationship_builder.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sqlalchemy_continuum/relationship_builder.py b/sqlalchemy_continuum/relationship_builder.py index 7cf62814..f3dc368d 100644 --- a/sqlalchemy_continuum/relationship_builder.py +++ b/sqlalchemy_continuum/relationship_builder.py @@ -346,7 +346,10 @@ def __call__(self): except ClassNotVersioned: self.remote_cls = self.property.mapper.class_ - if self.property.secondary is not None and not self.property.viewonly: + if (self.property.secondary is not None and + not self.property.viewonly and + not self.manager.is_excluded_property( + self.model, self.property.key)): self.build_association_version_tables() # store remote cls to association table column pairs From 4e222f203760744b3a2c98d6d6a3dbe843cbc1af Mon Sep 17 00:00:00 2001 From: Stephen Fuhry Date: Mon, 4 Sep 2017 12:00:10 +0000 Subject: [PATCH 2/4] add mypy & .cache to gitignore --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index a015a2d6..fe795a50 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,9 @@ nosetests.xml .mr.developer.cfg .project .pydevproject + +# mypy +.mypy_cache/ + +# Unit test / coverage reports +.cache From d540483319a74c0d687ae05131032bfc674443c9 Mon Sep 17 00:00:00 2001 From: Stephen Fuhry Date: Wed, 11 Oct 2017 14:30:51 +0000 Subject: [PATCH 3/4] add test for excluded relationship --- tests/test_column_inclusion_and_exclusion.py | 49 ++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/test_column_inclusion_and_exclusion.py b/tests/test_column_inclusion_and_exclusion.py index e8530d2d..e916b383 100644 --- a/tests/test_column_inclusion_and_exclusion.py +++ b/tests/test_column_inclusion_and_exclusion.py @@ -53,3 +53,52 @@ class TextItem(self.Model): content = sa.Column('_content', sa.UnicodeText) self.TextItem = TextItem + + +class TestColumnExclusionWithRelationship(TestCase): + def create_models(self): + + class Word(self.Model): + __tablename__ = 'word' + id = sa.Column(sa.Integer, autoincrement=True, primary_key=True) + word = sa.Column(sa.Unicode(255)) + + class TextItemWord(self.Model): + __tablename__ = 'text_item_word' + id = sa.Column(sa.Integer, autoincrement=True, primary_key=True) + text_item_id = sa.Column(sa.Integer, sa.ForeignKey('text_item.id'), nullable=False) + word_id = sa.Column(sa.Integer, sa.ForeignKey('word.id'), nullable=False) + + class TextItem(self.Model): + __tablename__ = 'text_item' + __versioned__ = { + 'exclude': ['content'] + } + + id = sa.Column(sa.Integer, autoincrement=True, primary_key=True) + name = sa.Column(sa.Unicode(255)) + content = sa.orm.relationship(Word, secondary='text_item_word') + + self.TextItem = TextItem + self.Word = Word + + def test_excluded_columns_not_included_in_version_class(self): + cls = version_class(self.TextItem) + manager = cls._sa_class_manager + assert 'content' not in manager.keys() + + def test_versioning_with_column_exclusion(self): + item = self.TextItem(name=u'Some textitem', + content=[self.Word(word=u'bird')]) + self.session.add(item) + self.session.commit() + + assert item.versions[0].name == u'Some textitem' + + def test_does_not_create_record_if_only_excluded_column_updated(self): + item = self.TextItem(name=u'Some textitem') + self.session.add(item) + self.session.commit() + item.content.append(self.Word(word=u'Some content')) + self.session.commit() + assert item.versions.count() == 1 From a9ac2fb28bbd086bb4bc1fe71798f6e6bb14635c Mon Sep 17 00:00:00 2001 From: Stephen Fuhry Date: Wed, 8 Nov 2017 22:59:51 +0000 Subject: [PATCH 4/4] add python 3.6, remove 3.3 to travis --- .travis.yml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6ee80dba..d5187594 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,9 +15,9 @@ before_script: language: python python: - 2.7 - - 3.3 - 3.4 - 3.5 + - 3.6 install: - pip install -e ".[test]" script: diff --git a/setup.py b/setup.py index 439b821d..6dbcf5a6 100644 --- a/setup.py +++ b/setup.py @@ -77,9 +77,9 @@ def get_version(): 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 'Topic :: Software Development :: Libraries :: Python Modules' ]