Replace $sequenceName with $sequence and $name

parent 25d44d2d
......@@ -82,19 +82,19 @@ class TableGenerator
/**
* Generates the next unused value for the given sequence name.
*
* @param string $sequenceName
* @param string $sequence
*
* @return int
*
* @throws DBALException
*/
public function nextValue($sequenceName)
public function nextValue($sequence)
{
if (isset($this->sequences[$sequenceName])) {
$value = $this->sequences[$sequenceName]['value'];
$this->sequences[$sequenceName]['value']++;
if ($this->sequences[$sequenceName]['value'] >= $this->sequences[$sequenceName]['max']) {
unset($this->sequences[$sequenceName]);
if (isset($this->sequences[$sequence])) {
$value = $this->sequences[$sequence]['value'];
$this->sequences[$sequence]['value']++;
if ($this->sequences[$sequence]['value'] >= $this->sequences[$sequence]['max']) {
unset($this->sequences[$sequence]);
}
return $value;
......@@ -107,7 +107,7 @@ class TableGenerator
$sql = 'SELECT sequence_value, sequence_increment_by'
. ' FROM ' . $platform->appendLockHint($this->generatorTableName, LockMode::PESSIMISTIC_WRITE)
. ' WHERE sequence_name = ? ' . $platform->getWriteLockSQL();
$stmt = $this->conn->executeQuery($sql, [$sequenceName]);
$stmt = $this->conn->executeQuery($sql, [$sequence]);
$row = $stmt->fetch(FetchMode::ASSOCIATIVE);
if ($row !== false) {
......@@ -119,7 +119,7 @@ class TableGenerator
assert(is_int($value));
if ($row['sequence_increment_by'] > 1) {
$this->sequences[$sequenceName] = [
$this->sequences[$sequence] = [
'value' => $value,
'max' => $row['sequence_value'] + $row['sequence_increment_by'],
];
......@@ -128,7 +128,7 @@ class TableGenerator
$sql = 'UPDATE ' . $this->generatorTableName . ' ' .
'SET sequence_value = sequence_value + sequence_increment_by ' .
'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) {
throw new DBALException('Race-condition detected while updating sequence. Aborting generation');
......@@ -136,7 +136,7 @@ class TableGenerator
} else {
$this->conn->insert(
$this->generatorTableName,
['sequence_name' => $sequenceName, 'sequence_value' => 1, 'sequence_increment_by' => 1]
['sequence_name' => $sequence, 'sequence_value' => 1, 'sequence_increment_by' => 1]
);
$value = 1;
}
......
......@@ -2938,13 +2938,13 @@ abstract class AbstractPlatform
}
/**
* @param string $sequenceName
* @param string $sequence
*
* @return string
*
* @throws DBALException If not supported on this platform.
*/
public function getSequenceNextValSQL($sequenceName)
public function getSequenceNextValSQL($sequence)
{
throw DBALException::notSupported(__METHOD__);
}
......
......@@ -222,9 +222,9 @@ class OraclePlatform extends AbstractPlatform
/**
* {@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
/**
* {@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
/**
* {@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
/**
* {@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
}
/**
* @param string $sequenceName
* @param string $name
*
* @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
*
* @throws SchemaException
*/
public function getSequence($sequenceName)
public function getSequence($name)
{
$sequenceName = $this->getFullQualifiedAssetName($sequenceName);
if (! $this->hasSequence($sequenceName)) {
throw SchemaException::sequenceDoesNotExist($sequenceName);
$name = $this->getFullQualifiedAssetName($name);
if (! $this->hasSequence($name)) {
throw SchemaException::sequenceDoesNotExist($name);
}
return $this->_sequences[$sequenceName];
return $this->_sequences[$name];
}
/**
......@@ -367,29 +367,29 @@ class Schema extends AbstractAsset
/**
* Creates a new sequence.
*
* @param string $sequenceName
* @param string $name
* @param int $allocationSize
* @param int $initialValue
*
* @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);
return $seq;
}
/**
* @param string $sequenceName
* @param string $name
*
* @return Schema
*/
public function dropSequence($sequenceName)
public function dropSequence($name)
{
$sequenceName = $this->getFullQualifiedAssetName($sequenceName);
unset($this->_sequences[$sequenceName]);
$name = $this->getFullQualifiedAssetName($name);
unset($this->_sequences[$name]);
return $this;
}
......
......@@ -127,23 +127,23 @@ class SchemaException extends DBALException
}
/**
* @param string $sequenceName
* @param string $name
*
* @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
*/
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