Andreasburmeister has submitted this change and it was merged.

Change subject: Renamed column in violations table
......................................................................


Renamed column in violations table

constraint_claim_guid -> constraint_id

Change-Id: I5f638f01e26c407c705a9317e2bebc926886c80e
---
M includes/Violations/ViolationLookup.php
M includes/Violations/ViolationQuery.php
M includes/Violations/ViolationStore.php
M sql/create_wdqa_violations.sql
M tests/phpunit/Violations/ViolationLookupTest.php
M tests/phpunit/Violations/ViolationQueryTest.php
M tests/phpunit/Violations/ViolationStoreTest.php
7 files changed, 27 insertions(+), 27 deletions(-)

Approvals:
  Andreasburmeister: Checked; Looks good to me, approved



diff --git a/includes/Violations/ViolationLookup.php 
b/includes/Violations/ViolationLookup.php
index 4047a77..72ff228 100644
--- a/includes/Violations/ViolationLookup.php
+++ b/includes/Violations/ViolationLookup.php
@@ -42,7 +42,7 @@
                        $violation = new Violation(
                                new ItemId( $result->entity_id ),
                                array ( 'pid' => new PropertyId( $result->pid 
), 'claimGuid' => $result->claim_guid ),
-                               $result->constraint_claim_guid,
+                               $result->constraint_id,
                                new ItemId( $result->constraint_type_entity_id 
),
                                (int) $result->revision_id,
                                $result->status,
diff --git a/includes/Violations/ViolationQuery.php 
b/includes/Violations/ViolationQuery.php
index 7115734..b0cb442 100644
--- a/includes/Violations/ViolationQuery.php
+++ b/includes/Violations/ViolationQuery.php
@@ -34,7 +34,7 @@
                'entityId' => 'entity_id',
                'propertyId' => 'pid',
                'claimGuid' => 'claim_guid',
-               'constraintClaimGuid' => 'constraint_claim_guid',
+               'constraintId' => 'constraint_id',
                'constraintTypeEntityId' => 'constraint_type_entity_id',
                'additionalInfo' => 'additional_info',
                'updatedAt' => 'updated_at',
@@ -95,16 +95,16 @@
        }
 
        /**
-        * @param $constraintClaimGuid
+        * @param $constraintId
         */
-       public function setConstraintClaimGuid( $constraintClaimGuid ) {
-               $this->testParamType( $constraintClaimGuid, __FUNCTION__ );
-               $key = $this->keys[ 'constraintClaimGuid' ];
-               $this->conditions[ $key ] = $key . '="' . $constraintClaimGuid 
. '"';
+       public function setConstraintClaimGuid( $constraintId ) {
+               $this->testParamType( $constraintId, __FUNCTION__ );
+               $key = $this->keys[ 'constraintId' ];
+               $this->conditions[ $key ] = $key . '="' . $constraintId . '"';
        }
 
        public function unsetConstraintClaimGuid() {
-               unset( $this->conditions[ $this->keys[ 'constraintClaimGuid' ] 
] );
+               unset( $this->conditions[ $this->keys[ 'constraintId' ] ] );
        }
 
        /**
diff --git a/includes/Violations/ViolationStore.php 
b/includes/Violations/ViolationStore.php
index 83a5cde..a60653e 100644
--- a/includes/Violations/ViolationStore.php
+++ b/includes/Violations/ViolationStore.php
@@ -45,7 +45,7 @@
                                'entity_id' => 
$violation->getEntityId()->getSerialization(),
                                'pid' => 
$violation->getPropertyId()->getSerialization(),
                                'claim_guid' => $violation->getClaimGuid(),
-                               'constraint_claim_guid' => 
$violation->getConstraintClaimGuid(),
+                               'constraint_id' => 
$violation->getConstraintClaimGuid(),
                                'constraint_type_entity_id' => 
$violation->getConstraintTypeEntityId(),//TODO: use this line: 
->getSerialization(),
                                'additional_info' => 
$violation->getAdditionalInfo(),
                                'updated_at' => $updatedAt,
@@ -77,7 +77,7 @@
 
                $success = $this->db->delete( VIOLATION_TABLE, array (
                        "claim_guid=\"$claimGuid\"",
-                       "constraint_claim_guid=\"$constraintClaimGuid\""
+                       "constraint_id=\"$constraintClaimGuid\""
                ) );
 
                return $success;
@@ -102,10 +102,10 @@
                $claimGuid = $violation->getClaimGuid();
                $constraintClaimGuid = $violation->getConstraintClaimGuid();
                $existing = $this->db->selectRow( VIOLATION_TABLE,
-                                                                               
  array ( 'claim_guid', 'constraint_claim_guid' ),
+                                                                               
  array ( 'claim_guid', 'constraint_id' ),
                                                                                
  array (
                                                                                
          "claim_guid=\"$claimGuid\"",
-                                                                               
          "constraint_claim_guid=\"$constraintClaimGuid\""
+                                                                               
          "constraint_id=\"$constraintClaimGuid\""
                                                                                
  ) );
                return $existing ? true : false;
        }
@@ -127,11 +127,11 @@
         */
        private function updateViolation( array $accumulator ) {
                $claimGuid = $accumulator[ 'claim_guid' ];
-               $constraintClaimGuid = $accumulator[ 'constraint_claim_guid' ];
+               $constraintClaimGuid = $accumulator[ 'constraint_id' ];
                $success = $this->db->update(
                        VIOLATION_TABLE,
                        $accumulator,
-                       array ( "claim_guid=\"$claimGuid\"", 
"constraint_claim_guid=\"$constraintClaimGuid\"" )
+                       array ( "claim_guid=\"$claimGuid\"", 
"constraint_id=\"$constraintClaimGuid\"" )
                );
                return $success;
        }
diff --git a/sql/create_wdqa_violations.sql b/sql/create_wdqa_violations.sql
index 371fa14..6d9d058 100644
--- a/sql/create_wdqa_violations.sql
+++ b/sql/create_wdqa_violations.sql
@@ -2,7 +2,7 @@
   entity_id                     VARBINARY(15)     NOT NULL,
   pid                           VARBINARY(15)     NOT NULL,
   claim_guid                    VARBINARY(63)     NOT NULL,
-  constraint_claim_guid         VARBINARY(63)     NOT NULL,
+  constraint_id                 VARBINARY(63)     NOT NULL,
   constraint_type_entity_id     VARBINARY(15)     NOT NULL,
   additional_info               TEXT              DEFAULT NULL,
   updated_at                    VARBINARY(31)     NOT NULL,
diff --git a/tests/phpunit/Violations/ViolationLookupTest.php 
b/tests/phpunit/Violations/ViolationLookupTest.php
index 822acfc..27497a1 100644
--- a/tests/phpunit/Violations/ViolationLookupTest.php
+++ b/tests/phpunit/Violations/ViolationLookupTest.php
@@ -59,7 +59,7 @@
                                'entity_id' => 'Q42',
                                'pid' => 'P13',
                                'claim_guid' => 'P13$1-2-3-4',
-                               'constraint_claim_guid' => 'P666$1-2-3-4',
+                               'constraint_id' => 'P666$1-2-3-4',
                                'constraint_type_entity_id' => 'Q666',
                                'additional_info' => 'first',
                                'updated_at' => '20141015150000',
@@ -70,7 +70,7 @@
                                'entity_id' => 'Q42',
                                'pid' => 'P13',
                                'claim_guid' => 'P13$1-2-3-4',
-                               'constraint_claim_guid' => 'P667$1-2-3-4',
+                               'constraint_id' => 'P667$1-2-3-4',
                                'constraint_type_entity_id' => 'Q666',
                                'additional_info' => 'second',
                                'updated_at' => '20141015150000',
@@ -81,7 +81,7 @@
                                'entity_id' => 'Q42',
                                'pid' => 'P13',
                                'claim_guid' => 'P13$1-2-3-4',
-                               'constraint_claim_guid' => 'P668$1-2-3-4',
+                               'constraint_id' => 'P668$1-2-3-4',
                                'constraint_type_entity_id' => 'Q666',
                                'additional_info' => 'third',
                                'updated_at' => '20141015150000',
diff --git a/tests/phpunit/Violations/ViolationQueryTest.php 
b/tests/phpunit/Violations/ViolationQueryTest.php
index d42a4a6..aa889e2 100644
--- a/tests/phpunit/Violations/ViolationQueryTest.php
+++ b/tests/phpunit/Violations/ViolationQueryTest.php
@@ -27,7 +27,7 @@
 
                $queryCondition->setConstraintClaimGuid( 'value' );
                $conditionArray = $queryCondition->toArray();
-               $this->assertEquals( 'constraint_claim_guid="value"', 
$conditionArray[ 2 ], "Test ConstraintClaimGuidSetter" );
+               $this->assertEquals( 'constraint_id="value"', $conditionArray[ 
2 ], "Test ConstraintClaimGuidSetter" );
 
                $queryCondition->setConstraintTypeEntityId( 'value' );
                $conditionArray = $queryCondition->toArray();
diff --git a/tests/phpunit/Violations/ViolationStoreTest.php 
b/tests/phpunit/Violations/ViolationStoreTest.php
index 3a7dbb7..a549789 100644
--- a/tests/phpunit/Violations/ViolationStoreTest.php
+++ b/tests/phpunit/Violations/ViolationStoreTest.php
@@ -30,16 +30,16 @@
 
                $actual = $this->db->selectRow( VIOLATION_TABLE, array (
                        'claim_guid',
-                       'constraint_claim_guid'
-               ), array ( 'claim_guid="P13$1-2-3-4"', 
'constraint_claim_guid="P666$1-2-3-4"' ) );
+                       'constraint_id'
+               ), array ( 'claim_guid="P13$1-2-3-4"', 
'constraint_id="P666$1-2-3-4"' ) );
                $this->assertNotNull( $actual );
 
                $violationStore->removeViolationWith( 'P13$1-2-3-4', 
'P666$1-2-3-4' );
 
                $actual = $this->db->selectRow( VIOLATION_TABLE, array (
                        'claim_guid',
-                       'constraint_claim_guid'
-               ), array ( 'claim_guid="P13$1-2-3-4"', 
'constraint_claim_guid="P666$1-2-3-4"' ) );
+                       'constraint_id'
+               ), array ( 'claim_guid="P13$1-2-3-4"', 
'constraint_id="P666$1-2-3-4"' ) );
                $this->assertFalse( $actual );
        }
 
@@ -66,12 +66,12 @@
 
                $count = $this->db->select( VIOLATION_TABLE, array (
                        'claim_guid',
-                       'constraint_claim_guid'
+                       'constraint_id'
                ), array ( 'claim_guid="P13$1-2-3-4"' ) )->numRows();
                $violationStore->insertViolations( array ( $violation, 
$anotherViolation ) );
                $newCount = $this->db->select( VIOLATION_TABLE, array (
                        'claim_guid',
-                       'constraint_claim_guid'
+                       'constraint_id'
                ), array ( 'claim_guid="P13$1-2-3-4"' ) )->numRows();
                $this->assertEquals( $count + 2, $newCount );
        }
@@ -91,7 +91,7 @@
 
                $updated = $this->db->selectRow( VIOLATION_TABLE, array( 
'status', 'updated_at' ), array (
                        'claim_guid="P13$1-2-3-4"',
-                       'constraint_claim_guid="P666$1-2-3-4"'
+                       'constraint_id="P666$1-2-3-4"'
                ) );
                $this->assertEquals( 'unverified', $updated->status );
                $this->assertNotEquals( '20141015150000', $updated->updated_at 
);
@@ -119,7 +119,7 @@
                                                           'entity_id' => 'Q42',
                                                           'pid' => 'P13',
                                                           'claim_guid' => 
'P13$1-2-3-4',
-                                                          
'constraint_claim_guid' => 'P666$1-2-3-4',
+                                                          'constraint_id' => 
'P666$1-2-3-4',
                                                           
'constraint_type_entity_id' => 'Q666',
                                                           'additional_info' => 
null,
                                                           'updated_at' => 
wfTimestamp( TS_MW, '2014-10-15T15:00:00Z' ),

-- 
To view, visit https://gerrit.wikimedia.org/r/205252
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I5f638f01e26c407c705a9317e2bebc926886c80e
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/WikidataQuality
Gerrit-Branch: master
Gerrit-Owner: Tamslo <tamaraslosa...@gmail.com>
Gerrit-Reviewer: Andreasburmeister <andreas.burmeis...@student.hpi.de>
Gerrit-Reviewer: Springle <sprin...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to