Replace $sequenceName with $sequence and $name

parent 25d44d2d
...@@ -82,19 +82,19 @@ class TableGenerator ...@@ -82,19 +82,19 @@ class TableGenerator
/** /**
* Generates the next unused value for the given sequence name. * Generates the next unused value for the given sequence name.
* *
* @param string $sequenceName * @param string $sequence
* *
* @return int * @return int
* *
* @throws DBALException * @throws DBALException
*/ */
public function nextValue($sequenceName) public function nextValue($sequence)
{ {
if (isset($this->sequences[$sequenceName])) { if (isset($this->sequences[$sequence])) {
$value = $this->sequences[$sequenceName]['value']; $value = $this->sequences[$sequence]['value'];
$this->sequences[$sequenceName]['value']++; $this->sequences[$sequence]['value']++;
if ($this->sequences[$sequenceName]['value'] >= $this->sequences[$sequenceName]['max']) { if ($this->sequences[$sequence]['value'] >= $this->sequences[$sequence]['max']) {
unset($this->sequences[$sequenceName]); unset($this->sequences[$sequence]);
} }
return $value; return $value;
...@@ -107,7 +107,7 @@ class TableGenerator ...@@ -107,7 +107,7 @@ class TableGenerator
$sql = 'SELECT sequence_value, sequence_increment_by' $sql = 'SELECT sequence_value, sequence_increment_by'
. ' FROM ' . $platform->appendLockHint($this->generatorTableName, LockMode::PESSIMISTIC_WRITE) . ' FROM ' . $platform->appendLockHint($this->generatorTableName, LockMode::PESSIMISTIC_WRITE)
. ' WHERE sequence_name = ? ' . $platform->getWriteLockSQL(); . ' WHERE sequence_name = ? ' . $platform->getWriteLockSQL();
$stmt = $this->conn->executeQuery($sql, [$sequenceName]); $stmt = $this->conn->executeQuery($sql, [$sequence]);
$row = $stmt->fetch(FetchMode::ASSOCIATIVE); $row = $stmt->fetch(FetchMode::ASSOCIATIVE);
if ($row !== false) { if ($row !== false) {
...@@ -119,7 +119,7 @@ class TableGenerator ...@@ -119,7 +119,7 @@ class TableGenerator
assert(is_int($value)); assert(is_int($value));
if ($row['sequence_increment_by'] > 1) { if ($row['sequence_increment_by'] > 1) {
$this->sequences[$sequenceName] = [ $this->sequences[$sequence] = [
'value' => $value, 'value' => $value,
'max' => $row['sequence_value'] + $row['sequence_increment_by'], 'max' => $row['sequence_value'] + $row['sequence_increment_by'],
]; ];
...@@ -128,7 +128,7 @@ class TableGenerator ...@@ -128,7 +128,7 @@ class TableGenerator
$sql = 'UPDATE ' . $this->generatorTableName . ' ' . $sql = 'UPDATE ' . $this->generatorTableName . ' ' .
'SET sequence_value = sequence_value + sequence_increment_by ' . 'SET sequence_value = sequence_value + sequence_increment_by ' .
'WHERE sequence_name = ? AND sequence_value = ?'; 'WHERE sequence_name = ? AND sequence_value = ?';
$rows = $this->conn->executeUpdate($sql, [$sequenceName, $row['sequence_value']]); $rows = $this->conn->executeUpdate($sql, [$sequence, $row['sequence_value']]);
if ($rows !== 1) { if ($rows !== 1) {
throw new DBALException('Race-condition detected while updating sequence. Aborting generation'); throw new DBALException('Race-condition detected while updating sequence. Aborting generation');
...@@ -136,7 +136,7 @@ class TableGenerator ...@@ -136,7 +136,7 @@ class TableGenerator
} else { } else {
$this->conn->insert( $this->conn->insert(
$this->generatorTableName, $this->generatorTableName,
['sequence_name' => $sequenceName, 'sequence_value' => 1, 'sequence_increment_by' => 1] ['sequence_name' => $sequence, 'sequence_value' => 1, 'sequence_increment_by' => 1]
); );
$value = 1; $value = 1;
} }
......
...@@ -2938,13 +2938,13 @@ abstract class AbstractPlatform ...@@ -2938,13 +2938,13 @@ abstract class AbstractPlatform
} }
/** /**
* @param string $sequenceName * @param string $sequence
* *
* @return string * @return string
* *
* @throws DBALException If not supported on this platform. * @throws DBALException If not supported on this platform.
*/ */
public function getSequenceNextValSQL($sequenceName) public function getSequenceNextValSQL($sequence)
{ {
throw DBALException::notSupported(__METHOD__); throw DBALException::notSupported(__METHOD__);
} }
......
...@@ -222,9 +222,9 @@ class OraclePlatform extends AbstractPlatform ...@@ -222,9 +222,9 @@ class OraclePlatform extends AbstractPlatform
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getSequenceNextValSQL($sequenceName) public function getSequenceNextValSQL($sequence)
{ {
return 'SELECT ' . $sequenceName . '.nextval FROM DUAL'; return 'SELECT ' . $sequence . '.nextval FROM DUAL';
} }
/** /**
......
...@@ -927,9 +927,9 @@ SQL ...@@ -927,9 +927,9 @@ SQL
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getSequenceNextValSQL($sequenceName) public function getSequenceNextValSQL($sequence)
{ {
return "SELECT NEXTVAL('" . $sequenceName . "')"; return "SELECT NEXTVAL('" . $sequence . "')";
} }
/** /**
......
...@@ -70,9 +70,9 @@ class SQLAnywhere12Platform extends SQLAnywhere11Platform ...@@ -70,9 +70,9 @@ class SQLAnywhere12Platform extends SQLAnywhere11Platform
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getSequenceNextValSQL($sequenceName) public function getSequenceNextValSQL($sequence)
{ {
return 'SELECT ' . $sequenceName . '.NEXTVAL'; return 'SELECT ' . $sequence . '.NEXTVAL';
} }
/** /**
......
...@@ -68,9 +68,9 @@ class SQLServer2012Platform extends SQLServer2008Platform ...@@ -68,9 +68,9 @@ class SQLServer2012Platform extends SQLServer2008Platform
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function getSequenceNextValSQL($sequenceName) public function getSequenceNextValSQL($sequence)
{ {
return 'SELECT NEXT VALUE FOR ' . $sequenceName; return 'SELECT NEXT VALUE FOR ' . $sequence;
} }
/** /**
......
...@@ -252,32 +252,32 @@ class Schema extends AbstractAsset ...@@ -252,32 +252,32 @@ class Schema extends AbstractAsset
} }
/** /**
* @param string $sequenceName * @param string $name
* *
* @return bool * @return bool
*/ */
public function hasSequence($sequenceName) public function hasSequence($name)
{ {
$sequenceName = $this->getFullQualifiedAssetName($sequenceName); $name = $this->getFullQualifiedAssetName($name);
return isset($this->_sequences[$sequenceName]); return isset($this->_sequences[$name]);
} }
/** /**
* @param string $sequenceName * @param string $name
* *
* @return Sequence * @return Sequence
* *
* @throws SchemaException * @throws SchemaException
*/ */
public function getSequence($sequenceName) public function getSequence($name)
{ {
$sequenceName = $this->getFullQualifiedAssetName($sequenceName); $name = $this->getFullQualifiedAssetName($name);
if (! $this->hasSequence($sequenceName)) { if (! $this->hasSequence($name)) {
throw SchemaException::sequenceDoesNotExist($sequenceName); throw SchemaException::sequenceDoesNotExist($name);
} }
return $this->_sequences[$sequenceName]; return $this->_sequences[$name];
} }
/** /**
...@@ -367,29 +367,29 @@ class Schema extends AbstractAsset ...@@ -367,29 +367,29 @@ class Schema extends AbstractAsset
/** /**
* Creates a new sequence. * Creates a new sequence.
* *
* @param string $sequenceName * @param string $name
* @param int $allocationSize * @param int $allocationSize
* @param int $initialValue * @param int $initialValue
* *
* @return Sequence * @return Sequence
*/ */
public function createSequence($sequenceName, $allocationSize = 1, $initialValue = 1) public function createSequence($name, $allocationSize = 1, $initialValue = 1)
{ {
$seq = new Sequence($sequenceName, $allocationSize, $initialValue); $seq = new Sequence($name, $allocationSize, $initialValue);
$this->_addSequence($seq); $this->_addSequence($seq);
return $seq; return $seq;
} }
/** /**
* @param string $sequenceName * @param string $name
* *
* @return Schema * @return Schema
*/ */
public function dropSequence($sequenceName) public function dropSequence($name)
{ {
$sequenceName = $this->getFullQualifiedAssetName($sequenceName); $name = $this->getFullQualifiedAssetName($name);
unset($this->_sequences[$sequenceName]); unset($this->_sequences[$name]);
return $this; return $this;
} }
......
...@@ -127,23 +127,23 @@ class SchemaException extends DBALException ...@@ -127,23 +127,23 @@ class SchemaException extends DBALException
} }
/** /**
* @param string $sequenceName * @param string $name
* *
* @return SchemaException * @return SchemaException
*/ */
public static function sequenceAlreadyExists($sequenceName) public static function sequenceAlreadyExists($name)
{ {
return new self("The sequence '" . $sequenceName . "' already exists.", self::SEQUENCE_ALREADY_EXISTS); return new self("The sequence '" . $name . "' already exists.", self::SEQUENCE_ALREADY_EXISTS);
} }
/** /**
* @param string $sequenceName * @param string $name
* *
* @return SchemaException * @return SchemaException
*/ */
public static function sequenceDoesNotExist($sequenceName) public static function sequenceDoesNotExist($name)
{ {
return new self("There exists no sequence with the name '" . $sequenceName . "'.", self::SEQUENCE_DOENST_EXIST); return new self("There exists no sequence with the name '" . $name . "'.", self::SEQUENCE_DOENST_EXIST);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment