Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
0afeb17d
Unverified
Commit
0afeb17d
authored
Jul 17, 2020
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace $sequenceName with $sequence and $name
parent
25d44d2d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
44 additions
and
44 deletions
+44
-44
TableGenerator.php
lib/Doctrine/DBAL/Id/TableGenerator.php
+11
-11
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+2
-2
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+2
-2
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+2
-2
SQLAnywhere12Platform.php
lib/Doctrine/DBAL/Platforms/SQLAnywhere12Platform.php
+2
-2
SQLServer2012Platform.php
lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php
+2
-2
Schema.php
lib/Doctrine/DBAL/Schema/Schema.php
+17
-17
SchemaException.php
lib/Doctrine/DBAL/Schema/SchemaException.php
+6
-6
No files found.
lib/Doctrine/DBAL/Id/TableGenerator.php
View file @
0afeb17d
...
...
@@ -82,19 +82,19 @@ class TableGenerator
/**
* Generates the next unused value for the given sequence name.
*
* @param string $sequence
Name
* @param string $sequence
*
* @return int
*
* @throws DBALException
*/
public
function
nextValue
(
$sequence
Name
)
public
function
nextValue
(
$sequence
)
{
if
(
isset
(
$this
->
sequences
[
$sequence
Name
]))
{
$value
=
$this
->
sequences
[
$sequence
Name
][
'value'
];
$this
->
sequences
[
$sequence
Name
][
'value'
]
++
;
if
(
$this
->
sequences
[
$sequence
Name
][
'value'
]
>=
$this
->
sequences
[
$sequenceNam
e
][
'max'
])
{
unset
(
$this
->
sequences
[
$sequence
Name
]);
if
(
isset
(
$this
->
sequences
[
$sequence
]))
{
$value
=
$this
->
sequences
[
$sequence
][
'value'
];
$this
->
sequences
[
$sequence
][
'value'
]
++
;
if
(
$this
->
sequences
[
$sequence
][
'value'
]
>=
$this
->
sequences
[
$sequenc
e
][
'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
,
[
$sequence
Name
]);
$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
[
$sequence
Name
]
=
[
$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
,
[
$sequence
Name
,
$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'
=>
$sequence
Name
,
'sequence_value'
=>
1
,
'sequence_increment_by'
=>
1
]
[
'sequence_name'
=>
$sequence
,
'sequence_value'
=>
1
,
'sequence_increment_by'
=>
1
]
);
$value
=
1
;
}
...
...
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
0afeb17d
...
...
@@ -2938,13 +2938,13 @@ abstract class AbstractPlatform
}
/**
* @param string $sequence
Name
* @param string $sequence
*
* @return string
*
* @throws DBALException If not supported on this platform.
*/
public
function
getSequenceNextValSQL
(
$sequence
Name
)
public
function
getSequenceNextValSQL
(
$sequence
)
{
throw
DBALException
::
notSupported
(
__METHOD__
);
}
...
...
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
0afeb17d
...
...
@@ -222,9 +222,9 @@ class OraclePlatform extends AbstractPlatform
/**
* {@inheritDoc}
*/
public
function
getSequenceNextValSQL
(
$sequence
Name
)
public
function
getSequenceNextValSQL
(
$sequence
)
{
return
'SELECT '
.
$sequence
Name
.
'.nextval FROM DUAL'
;
return
'SELECT '
.
$sequence
.
'.nextval FROM DUAL'
;
}
/**
...
...
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
0afeb17d
...
...
@@ -927,9 +927,9 @@ SQL
/**
* {@inheritDoc}
*/
public
function
getSequenceNextValSQL
(
$sequence
Name
)
public
function
getSequenceNextValSQL
(
$sequence
)
{
return
"SELECT NEXTVAL('"
.
$sequence
Name
.
"')"
;
return
"SELECT NEXTVAL('"
.
$sequence
.
"')"
;
}
/**
...
...
lib/Doctrine/DBAL/Platforms/SQLAnywhere12Platform.php
View file @
0afeb17d
...
...
@@ -70,9 +70,9 @@ class SQLAnywhere12Platform extends SQLAnywhere11Platform
/**
* {@inheritdoc}
*/
public
function
getSequenceNextValSQL
(
$sequence
Name
)
public
function
getSequenceNextValSQL
(
$sequence
)
{
return
'SELECT '
.
$sequence
Name
.
'.NEXTVAL'
;
return
'SELECT '
.
$sequence
.
'.NEXTVAL'
;
}
/**
...
...
lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php
View file @
0afeb17d
...
...
@@ -68,9 +68,9 @@ class SQLServer2012Platform extends SQLServer2008Platform
/**
* {@inheritdoc}
*/
public
function
getSequenceNextValSQL
(
$sequence
Name
)
public
function
getSequenceNextValSQL
(
$sequence
)
{
return
'SELECT NEXT VALUE FOR '
.
$sequence
Name
;
return
'SELECT NEXT VALUE FOR '
.
$sequence
;
}
/**
...
...
lib/Doctrine/DBAL/Schema/Schema.php
View file @
0afeb17d
...
...
@@ -252,32 +252,32 @@ class Schema extends AbstractAsset
}
/**
* @param string $
sequenceN
ame
* @param string $
n
ame
*
* @return bool
*/
public
function
hasSequence
(
$
sequenceN
ame
)
public
function
hasSequence
(
$
n
ame
)
{
$
sequenceName
=
$this
->
getFullQualifiedAssetName
(
$sequenceN
ame
);
$
name
=
$this
->
getFullQualifiedAssetName
(
$n
ame
);
return
isset
(
$this
->
_sequences
[
$
sequenceN
ame
]);
return
isset
(
$this
->
_sequences
[
$
n
ame
]);
}
/**
* @param string $
sequenceN
ame
* @param string $
n
ame
*
* @return Sequence
*
* @throws SchemaException
*/
public
function
getSequence
(
$
sequenceN
ame
)
public
function
getSequence
(
$
n
ame
)
{
$
sequenceName
=
$this
->
getFullQualifiedAssetName
(
$sequenceN
ame
);
if
(
!
$this
->
hasSequence
(
$
sequenceN
ame
))
{
throw
SchemaException
::
sequenceDoesNotExist
(
$
sequenceN
ame
);
$
name
=
$this
->
getFullQualifiedAssetName
(
$n
ame
);
if
(
!
$this
->
hasSequence
(
$
n
ame
))
{
throw
SchemaException
::
sequenceDoesNotExist
(
$
n
ame
);
}
return
$this
->
_sequences
[
$
sequenceN
ame
];
return
$this
->
_sequences
[
$
n
ame
];
}
/**
...
...
@@ -367,29 +367,29 @@ class Schema extends AbstractAsset
/**
* Creates a new sequence.
*
* @param string $
sequenceN
ame
* @param string $
n
ame
* @param int $allocationSize
* @param int $initialValue
*
* @return Sequence
*/
public
function
createSequence
(
$
sequenceN
ame
,
$allocationSize
=
1
,
$initialValue
=
1
)
public
function
createSequence
(
$
n
ame
,
$allocationSize
=
1
,
$initialValue
=
1
)
{
$seq
=
new
Sequence
(
$
sequenceN
ame
,
$allocationSize
,
$initialValue
);
$seq
=
new
Sequence
(
$
n
ame
,
$allocationSize
,
$initialValue
);
$this
->
_addSequence
(
$seq
);
return
$seq
;
}
/**
* @param string $
sequenceN
ame
* @param string $
n
ame
*
* @return Schema
*/
public
function
dropSequence
(
$
sequenceN
ame
)
public
function
dropSequence
(
$
n
ame
)
{
$
sequenceName
=
$this
->
getFullQualifiedAssetName
(
$sequenceN
ame
);
unset
(
$this
->
_sequences
[
$
sequenceN
ame
]);
$
name
=
$this
->
getFullQualifiedAssetName
(
$n
ame
);
unset
(
$this
->
_sequences
[
$
n
ame
]);
return
$this
;
}
...
...
lib/Doctrine/DBAL/Schema/SchemaException.php
View file @
0afeb17d
...
...
@@ -127,23 +127,23 @@ class SchemaException extends DBALException
}
/**
* @param string $
sequenceN
ame
* @param string $
n
ame
*
* @return SchemaException
*/
public
static
function
sequenceAlreadyExists
(
$
sequenceN
ame
)
public
static
function
sequenceAlreadyExists
(
$
n
ame
)
{
return
new
self
(
"The sequence '"
.
$
sequenceN
ame
.
"' already exists."
,
self
::
SEQUENCE_ALREADY_EXISTS
);
return
new
self
(
"The sequence '"
.
$
n
ame
.
"' already exists."
,
self
::
SEQUENCE_ALREADY_EXISTS
);
}
/**
* @param string $
sequenceN
ame
* @param string $
n
ame
*
* @return SchemaException
*/
public
static
function
sequenceDoesNotExist
(
$
sequenceN
ame
)
public
static
function
sequenceDoesNotExist
(
$
n
ame
)
{
return
new
self
(
"There exists no sequence with the name '"
.
$
sequenceN
ame
.
"'."
,
self
::
SEQUENCE_DOENST_EXIST
);
return
new
self
(
"There exists no sequence with the name '"
.
$
n
ame
.
"'."
,
self
::
SEQUENCE_DOENST_EXIST
);
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment