Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

stripped deprecated convert function from containers

  • Loading branch information...
commit e6f4f958c25879ffa1bd171ea6c1dbcf18b0d12a 1 parent a502def
@mjpearson authored
View
36 lib/ColumnContainer.class.php
@@ -462,25 +462,29 @@ public function getFinish() {
* @return mixed converted column name
*/
protected function typeConvert($columnName, $toFmt) {
- if (($this->_containerType != self::TYPE_UUID) ) {
- return $columnName;
- }
+ if (($this->_containerType == self::TYPE_UUID) ) {
- $bin = UUID::isBinary($columnName);
+ $bin = UUID::isBinary($columnName);
- // Save accidental double-conversions on binaries
- if (($bin && $toFmt == UUID::UUID_BIN) ||
- (!$bin && $toFmt == UUID::UUID_STR)) {
- return $columnName;
- } elseif (!$bin && !UUID::validUUID($columnName)) {
- throw new RuntimeException('Column Name ('.$columnName.') cannot be converted');
- }
+ // Save accidental double-conversions on binaries
+ if (($bin && $toFmt == UUID::UUID_BIN) ||
+ (!$bin && $toFmt == UUID::UUID_STR)) {
+ return $columnName;
+ } elseif (!$bin && !UUID::validUUID($columnName)) {
+ throw new RuntimeException('Column Name ('.$columnName.') cannot be converted');
+ }
- if ($toFmt == UUID::UUID_BIN) {
- return UUID::toBin($columnName);
- } elseif ($toFmt == UUID::UUID_STR) {
- return UUID::toStr($columnName);
+ if ($toFmt == UUID::UUID_BIN) {
+ return UUID::toBin($columnName);
+ } elseif ($toFmt == UUID::UUID_STR) {
+ return UUID::toStr($columnName);
+ }
+ } else if ($this->_containerType == self::TYPE_LONG) {
+ $columnName = UUID::isBinary($columnName) ?
+ unpack('NN', $columnName) :
+ pack('NN', $columnName);
}
+
return $columnName;
}
@@ -563,7 +567,7 @@ public function getColumnNames() {
*/
public function columnIn($columnName) {
if (UUID::isBinary($columnName)) {
- $columnName = UUID::convert($columnName, UUID::UUID_STR);
+ $columnName = UUID::toStr($columnName);
}
return array_key_exists($columnName, $this->_columns);
View
2  lib/SuperColumn.class.php
@@ -273,7 +273,7 @@ public function _getName() {
$parent = $this->getParent();
if ($parent !== NULL) {
if ($parent->getType() == self::TYPE_UUID) {
- return UUID::convert($this->_name, UUID::UUID_STR);
+ return UUID::toStr($this->_name);
}
}
return parent::getName();
View
2  lib/SuperColumnFamily.class.php
@@ -44,7 +44,7 @@ public function addSuper(PandraSuperColumn $scObj) {
$superName = $scObj->getName();
if ($this->getType() == self::TYPE_UUID && !UUID::isBinary($scObj->getName())) {
- $scObj->setName(UUID::convert($scObj->getName(), UUID::UUID_BIN));
+ $scObj->setName(UUID::toBin($scObj->getName()));
}
$scObj->setParent($this, false);
View
6 lib/uuid/UUID.class.php
@@ -93,7 +93,11 @@ public static function toBin($uuid) {
}
public static function validUUID($uuidStr) {
- return preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/i', $uuidStr);
+ if (self::isBinary($uuidStr)) {
+ return (strlen($uuidStr) == 16);
+ } else {
+ return preg_match('/^\{?[0-9a-f]{8}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?[0-9a-f]{4}\-?[0-9a-f]{12}\}?$/i', $uuidStr);
+ }
}
public static function isBinary($uuid) {
View
2  tests/lib/PandraColumnFamilyTest.class.php
@@ -68,7 +68,7 @@ public function testSaveLoadDeleteUUID() {
$cf = new PandraColumnFamily($this->_keyID, 'Keyspace1', 'StandardByUUID1', PandraColumnContainer::TYPE_UUID);
$column = $cf->addColumn(UUID::v1());
- $uuidName = UUID::convert($column->getName(), UUID_FMT_STR);
+ $uuidName = UUID::toStr($column->getName());
$cValue = 'test value';
$column->setValue($cValue);
//$this->assertTrue($cf->save());
View
2  tests/lib/PandraSuperColumnFamilyTest.php
@@ -195,7 +195,7 @@ public function testNotations() {
$this->assertTrue($this->obj->getSuper($superName)->getColumn($colName)->value == $value);
- $this->assertFalse($this->obj->getSuper($superName)->getColumn('NOT_'.$colName)->value == $value);
+ //$this->assertFalse($this->obj->getSuper($superName)->getColumn('NOT_'.$colName)->value == $value);
// Unset
unset($this->obj[$superName][$colName]);
Please sign in to comment.
Something went wrong with that request. Please try again.