Gzip datatype added
This commit is contained in:
parent
ed1f7aca93
commit
43980029d4
@ -68,6 +68,7 @@ class Doctrine_DataDict {
|
||||
case "array":
|
||||
case "object":
|
||||
case "string":
|
||||
case "gzip":
|
||||
if($length <= 255)
|
||||
return "C($length)";
|
||||
elseif($length <= 4000)
|
||||
|
@ -274,7 +274,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
private function cleanData() {
|
||||
private function cleanData($debug = false) {
|
||||
$tmp = $this->data;
|
||||
|
||||
$this->data = array();
|
||||
@ -303,8 +303,19 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
$this->data[$name] = $value;
|
||||
}
|
||||
break;
|
||||
case "enum":
|
||||
case "gzip":
|
||||
|
||||
if($tmp[$name] !== self::$null) {
|
||||
$value = gzuncompress($tmp[$name]);
|
||||
|
||||
|
||||
if($value === false)
|
||||
throw new Doctrine_Record_Exception("Uncompressing of $name failed.");
|
||||
|
||||
$this->data[$name] = $value;
|
||||
}
|
||||
break;
|
||||
case "enum":
|
||||
$this->data[$name] = $this->table->enumValue($name, $tmp[$name]);
|
||||
break;
|
||||
default:
|
||||
@ -314,6 +325,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $count;
|
||||
}
|
||||
/**
|
||||
@ -500,7 +512,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
$this->data = array_change_key_case($this->data, CASE_LOWER);
|
||||
|
||||
$this->modified = array();
|
||||
$this->cleanData();
|
||||
$this->cleanData(true);
|
||||
|
||||
$this->prepareIdentifiers();
|
||||
|
||||
@ -864,7 +876,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
||||
case 'array':
|
||||
case 'object':
|
||||
$a[$v] = serialize($this->data[$v]);
|
||||
break;;
|
||||
break;
|
||||
case 'gzip':
|
||||
$a[$v] = gzcompress($this->data[$v],5);
|
||||
break;
|
||||
case 'enum':
|
||||
$a[$v] = $this->table->enumIndex($v,$this->data[$v]);
|
||||
break;
|
||||
|
@ -239,6 +239,7 @@ class Doctrine_Validator {
|
||||
case 'mbstring':
|
||||
case 'timestamp':
|
||||
case 'date':
|
||||
case 'gzip':
|
||||
return 'string';
|
||||
break;
|
||||
default:
|
||||
|
@ -6,8 +6,31 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
|
||||
public function prepareTables() {
|
||||
$this->tables[] = "enumTest";
|
||||
$this->tables[] = "fieldNameTest";
|
||||
$this->tables[] = "GzipTest";
|
||||
parent::prepareTables();
|
||||
}
|
||||
public function testGzipType() {
|
||||
$gzip = new GzipTest();
|
||||
$gzip->gzip = "compressed";
|
||||
|
||||
$this->assertEqual($gzip->gzip, "compressed");
|
||||
$gzip->save();
|
||||
$this->assertEqual($gzip->gzip, "compressed");
|
||||
$gzip->refresh();
|
||||
$this->assertEqual($gzip->gzip, "compressed");
|
||||
|
||||
$this->connection->clear();
|
||||
$gzip = $gzip->getTable()->find($gzip->id);
|
||||
$this->assertEqual($gzip->gzip, "compressed");
|
||||
|
||||
$gzip->gzip = "compressed 2";
|
||||
|
||||
$this->assertEqual($gzip->gzip, "compressed 2");
|
||||
$gzip->save();
|
||||
$this->assertEqual($gzip->gzip, "compressed 2");
|
||||
$gzip->refresh();
|
||||
$this->assertEqual($gzip->gzip, "compressed 2");
|
||||
}
|
||||
|
||||
public function testEnumType() {
|
||||
|
||||
|
@ -409,7 +409,11 @@ class DateTest extends Doctrine_Record {
|
||||
$this->hasColumn("date", "date", 20);
|
||||
}
|
||||
}
|
||||
|
||||
class GzipTest extends Doctrine_Record {
|
||||
public function setTableDefinition() {
|
||||
$this->hasColumn("gzip", "gzip", 100000);
|
||||
}
|
||||
}
|
||||
|
||||
class Tag extends Doctrine_Record {
|
||||
public function setUp() {
|
||||
|
Loading…
Reference in New Issue
Block a user