Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix republishing of binders with trees latest flag set to null #131

Merged
merged 1 commit into from
Jul 1, 2016

Conversation

karenc
Copy link
Contributor

@karenc karenc commented Jun 30, 2016

Binders published using cnx-publishing (at the time of writing) always
have trees latest flag set to true, but there are lots of binders in the
database with trees latest flag set to null. The code for republishing
a binder doesn't use the new module_ident / documentid when inserting
into the trees table, causing this error.

======================================================================
ERROR: test_republish_binder_tree_not_latest (cnxpublishing.tests.test_publish.RepublishTestCase)
Verify republishing of binders that has trees with latest flag set
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/karen/cnx-publishing/cnxpublishing/tests/testing.py", line 66, in wrapped
    return method(self, cursor, *args, **kwargs)
  File "/home/karen/cnx-publishing/cnxpublishing/tests/test_publish.py", line 612, in test_republish_binder_tree_not_latest
    self.call_target(cursor, [page_one])
  File "/home/karen/cnx-publishing/cnxpublishing/tests/test_publish.py", line 497, in call_target
    return republish_binders(*args, **kwargs)
  File "/home/karen/cnx-publishing/cnxpublishing/publish.py", line 506, in republish_binders
    rebuild_collection_tree(cursor, ident_hash, history_mapping)
  File "/home/karen/cnx-publishing/cnxpublishing/publish.py", line 688, in rebuild_collection_tree
    build_tree(root_node, None)
  File "/home/karen/cnx-publishing/cnxpublishing/publish.py", line 683, in build_tree
    new_nodeid = insert(data)
  File "/home/karen/cnx-publishing/cnxpublishing/publish.py", line 664, in insert
    cursor.execute(tree_insert_sql, fields)
IntegrityError: duplicate key value violates unique constraint "trees_unique_doc_idx"
DETAIL:  Key (documentid, is_collated)=(5, f) already exists.

Binders published using cnx-publishing (at the time of writing) always
have trees latest flag set to true, but there are lots of binders in the
database with trees latest flag set to null.  The code for republishing
a binder doesn't use the new module_ident / documentid when inserting
into the trees table, causing this error.

```
======================================================================
ERROR: test_republish_binder_tree_not_latest (cnxpublishing.tests.test_publish.RepublishTestCase)
Verify republishing of binders that has trees with latest flag set
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/karen/cnx-publishing/cnxpublishing/tests/testing.py", line 66, in wrapped
    return method(self, cursor, *args, **kwargs)
  File "/home/karen/cnx-publishing/cnxpublishing/tests/test_publish.py", line 612, in test_republish_binder_tree_not_latest
    self.call_target(cursor, [page_one])
  File "/home/karen/cnx-publishing/cnxpublishing/tests/test_publish.py", line 497, in call_target
    return republish_binders(*args, **kwargs)
  File "/home/karen/cnx-publishing/cnxpublishing/publish.py", line 506, in republish_binders
    rebuild_collection_tree(cursor, ident_hash, history_mapping)
  File "/home/karen/cnx-publishing/cnxpublishing/publish.py", line 688, in rebuild_collection_tree
    build_tree(root_node, None)
  File "/home/karen/cnx-publishing/cnxpublishing/publish.py", line 683, in build_tree
    new_nodeid = insert(data)
  File "/home/karen/cnx-publishing/cnxpublishing/publish.py", line 664, in insert
    cursor.execute(tree_insert_sql, fields)
IntegrityError: duplicate key value violates unique constraint "trees_unique_doc_idx"
DETAIL:  Key (documentid, is_collated)=(5, f) already exists.
```
@coveralls
Copy link

Coverage Status

Coverage remained the same at 94.478% when pulling 211d6c8 on fix-republishing-binder-not-latest into 915ea4f on master.

@reedstrm reedstrm merged commit 77a8fe6 into master Jul 1, 2016
@reedstrm reedstrm deleted the fix-republishing-binder-not-latest branch July 1, 2016 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants