Browse Source

Restoring primary key validation

Jose Lorenzo Rodriguez 12 years ago
parent
commit
ad3f08a95f

+ 1 - 1
src/Console/Command/Task/ModelTask.php

@@ -411,7 +411,7 @@ class ModelTask extends BakeTask {
  * @return array Array of validation for the field.
  */
 	public function fieldValidation($fieldName, array $metaData, $primaryKey) {
-		$ignoreFields = array_merge($primaryKey, ['created', 'modified', 'updated']);
+		$ignoreFields = ['created', 'modified', 'updated'];
 		if (in_array($fieldName, $ignoreFields)) {
 			return false;
 		}

+ 3 - 1
tests/TestCase/Console/Command/Task/ModelTaskTest.php

@@ -427,6 +427,7 @@ class ModelTaskTest extends TestCase {
 			'title' => ['rule' => false, 'allowEmpty' => false],
 			'body' => ['rule' => false, 'allowEmpty' => true],
 			'published' => ['rule' => 'boolean', 'allowEmpty' => true],
+			'id' => ['rule' => 'numeric', 'allowEmpty' => 'create']
 		];
 		$this->assertEquals($expected, $result);
 
@@ -436,7 +437,8 @@ class ModelTaskTest extends TestCase {
 			'bake_article_id' => ['rule' => 'numeric', 'allowEmpty' => false],
 			'bake_user_id' => ['rule' => 'numeric', 'allowEmpty' => false],
 			'comment' => ['rule' => false, 'allowEmpty' => true],
-			'published' => ['rule' => false,'allowEmpty' => true]
+			'published' => ['rule' => false,'allowEmpty' => true],
+			'otherid' => ['rule' => 'numeric', 'allowEmpty' => 'create']
 		];
 		$this->assertEquals($expected, $result);
 	}