Commit 4e99e918 authored by Rafael Monnerat's avatar Rafael Monnerat

Updates for consistency table

See merge request nexedi/slapos.core!493
parents 133bd4bd e24c1c65
DELETE FROM REPLACE INTO
consistency
WHERE
<dtml-in uid>
uid=<dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else> OR </dtml-if>
</dtml-in>
;
<dtml-var "'\0'">
INSERT INTO
consistency consistency
(`uid`, `consistency_error`)
VALUES VALUES
<dtml-in prefix="loop" expr="_.range(_.len(uid))"> <dtml-in prefix="loop" expr="_.range(_.len(uid))">
( (
<dtml-sqlvar expr="uid[loop_item]" type="int">, <dtml-sqlvar expr="uid[loop_item]" type="int">,
<dtml-sqlvar expr="int(len(checkConsistency[loop_item]) > 0)" type="int"> <dtml-sqlvar expr="int((checkConsistency[loop_item] is None) or len(checkConsistency[loop_item]) > 0)" type="int">
) )
<dtml-if sequence-end><dtml-else>,</dtml-if> <dtml-if sequence-end>
<dtml-else>
,
</dtml-if>
</dtml-in> </dtml-in>
...@@ -43,13 +43,13 @@ checkConsistency</string> </value> ...@@ -43,13 +43,13 @@ checkConsistency</string> </value>
</item> </item>
<item> <item>
<key> <string>expression</string> </key> <key> <string>expression</string> </key>
<value> <string>python: context.getPortalType() in ["Sale Invoice Transaction", "Subscription Request"]</string> </value> <value> <string>python: context.getRelativeUrl().count(\'/\') == 1</string> </value>
</item> </item>
<item> <item>
<key> <string>expression_cache_key</string> </key> <key> <string>expression_cache_key</string> </key>
<value> <value>
<tuple> <tuple>
<string>portal_type</string> <string>relative_url</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
CREATE TABLE `consistency` ( CREATE TABLE `consistency` (
`uid` BIGINT UNSIGNED NOT NULL, `uid` BIGINT UNSIGNED NOT NULL,
`consistency_error` BOOL DEFAULT 0, `consistency_error` BOOL DEFAULT 0,
PRIMARY KEY (`uid`, `consistency_error`) PRIMARY KEY (`uid`),
KEY `consistency_error` (`consistency_error`)
) ENGINE=InnoDB; ) ENGINE=InnoDB;
...@@ -34,7 +34,7 @@ class TestSlapOSCatalogConsistency(SlapOSTestCaseMixin): ...@@ -34,7 +34,7 @@ class TestSlapOSCatalogConsistency(SlapOSTestCaseMixin):
def afterSetUp(self): def afterSetUp(self):
SlapOSTestCaseMixin.afterSetUp(self) SlapOSTestCaseMixin.afterSetUp(self)
def testSaleInvoiceTransaction(self): def testDocument(self):
from Products.ERP5Type.Base import Base from Products.ERP5Type.Base import Base
sale_invoice_transaction = self.portal.accounting_module.newContent( sale_invoice_transaction = self.portal.accounting_module.newContent(
...@@ -85,112 +85,4 @@ class TestSlapOSCatalogConsistency(SlapOSTestCaseMixin): ...@@ -85,112 +85,4 @@ class TestSlapOSCatalogConsistency(SlapOSTestCaseMixin):
) )
self.assertEqual(document, None) self.assertEqual(document, None)
finally: finally:
Base.checkConsistency = original_checkConsistency Base.checkConsistency = original_checkConsistency
\ No newline at end of file
def testSubscriptionRequest(self):
from Products.ERP5Type.Base import Base
subscription_request = self.portal.subscription_request_module.newContent(
portal_type="Subscription Request"
)
original_checkConsistency = Base.checkConsistency
Base.checkConsistency = checkConsistencyWithoutError
try:
transaction.commit()
subscription_request.immediateReindexObject()
self.tic()
document = self.portal.portal_catalog.getResultValue(
portal_type="Subscription Request",
consistency_error=0,
uid=subscription_request.getUid()
)
self.assertEqual(document, subscription_request)
document = self.portal.portal_catalog.getResultValue(
portal_type="Subscription Request",
consistency_error=1,
uid=subscription_request.getUid()
)
self.assertEqual(document, None)
Base.checkConsistency = checkConsistencyWithError
transaction.commit()
subscription_request.immediateReindexObject()
self.tic()
document = self.portal.portal_catalog.getResultValue(
portal_type="Subscription Request",
consistency_error=1,
uid=subscription_request.getUid()
)
self.assertEqual(document, subscription_request)
document = self.portal.portal_catalog.getResultValue(
portal_type="Subscription Request",
consistency_error=0,
uid=subscription_request.getUid(),
)
self.assertEqual(document, None)
finally:
Base.checkConsistency = original_checkConsistency
def testNotIndexedOnConsistencyTable(self):
from Products.ERP5Type.Base import Base
person = self.portal.person_module.newContent(
portal_type="Person"
)
original_checkConsistency = Base.checkConsistency
Base.checkConsistency = checkConsistencyWithoutError
try:
transaction.commit()
person.immediateReindexObject()
self.tic()
document = self.portal.portal_catalog.getResultValue(
portal_type="Person",
consistency_error=0,
uid=person.getUid()
)
self.assertEqual(document, None)
document = self.portal.portal_catalog.getResultValue(
portal_type="Person",
consistency_error=1,
uid=person.getUid()
)
self.assertEqual(document, None)
Base.checkConsistency = checkConsistencyWithError
transaction.commit()
person.immediateReindexObject()
self.tic()
document = self.portal.portal_catalog.getResultValue(
portal_type="Person",
consistency_error=1,
uid=person.getUid()
)
self.assertEqual(document, None)
document = self.portal.portal_catalog.getResultValue(
portal_type="Person",
consistency_error=0,
uid=person.getUid(),
)
self.assertEqual(document, None)
finally:
Base.checkConsistency = original_checkConsistency
\ No newline at end of file
...@@ -6,12 +6,6 @@ ...@@ -6,12 +6,6 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSCatalogConsistency</string> </value> <value> <string>testSlapOSCatalogConsistency</string> </value>
...@@ -61,28 +55,13 @@ ...@@ -61,28 +55,13 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -95,7 +74,7 @@ ...@@ -95,7 +74,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -104,7 +83,7 @@ ...@@ -104,7 +83,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment