Closed reidfrasier closed 9 years ago
Just a heads up, but you are correct in your assumptions. Assertiveness allows you to reassert the reliability that a positor holds towards a posit, even if the reliability has not changed. Disallowing this should require a revaluation of the reliability (a different one) or the insert will be ignored. I am going to look into this now.
As it turned out, your usage of the insert trigger was not correct. However, when I corrected the script I found another bug nevertheless, which has now been fixed. See the corrected script below, which now works in the test version:
------------------------------------
-- test assertiveness on latest view
------------------------------------
-- Insert an initial value for the assertive attribute 'A' into the latest view for 'ST_StaticThing'.
INSERT INTO [dbo].[lST_StaticThing] (Positor, ST_AXX_PositedAt, ST_AXX_Reliability, ST_AXX_StaticThing_A)
VALUES (0, '2015-10-14', 100, 1000);
-- The statement above will now have created an instance with ST_ID = 1, this need to be referred to in the
-- statments below, or new instances will be created for each of them.
SELECT * FROM [dbo].[lST_StaticThing]
-- Insert the same value for the assertive attribute 'A' which has different positing time into the latest view for 'ST_StaticThing'.
-- The expected behavior is that the insert should succeed without any errors.
INSERT INTO [dbo].[lST_StaticThing] (ST_ID, Positor, ST_AXX_PositedAt, ST_AXX_Reliability, ST_AXX_StaticThing_A)
VALUES (1, 0, '2015-10-15', 100, 1000);
-- The column ST_AXX_ST_ID indicates that we are talking about the same instance. The column ST_AXX_ID indicates that we are also
-- talking about the same posit (again).
SELECT * FROM [dbo].[ST_AXX_StaticThing_A];
-- Insert the same value for the assertive attribute 'A' which now has the same positing time into the latest view for 'ST_StaticThing'.
-- The expected behavior is that the insert should return errors because the positing time is the same as another posit and so the annex table
-- will not be updated.
INSERT INTO [dbo].[lST_StaticThing] (ST_ID, Positor, ST_AXX_PositedAt, ST_AXX_Reliability, ST_AXX_StaticThing_A)
VALUES (1, 0, '2015-10-15', 100, 1000);
I am doing some unit testing on the features in general and in that case on assertiveness. Below I will provide some code to replicate this issue but first let me summarize my understanding of the assertiveness feature. I understand it to mean that when checked the annex table for a static or historized attribute will only allow an insert (or update) of a new (old) row if the positing time is different from the any previous or following positing time. And if it is unchecked, then the same condition holds with the additional constraint that the reliability must also be different in order for an insert or update to be recorded. Does that sound correct? If not please ignore the rest of the message and correct my understanding.
Many thanks and below is my XML schema and some code to unit test these inserts:
Here is the XML schema:
Here are the inserts: