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
ba4ab893
Commit
ba4ab893
authored
Dec 22, 2013
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge upstream
parents
c40a24f7
d2845256
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
114 additions
and
2 deletions
+114
-2
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+31
-0
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+17
-1
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+17
-1
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+17
-0
OraclePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+16
-0
PostgreSqlPlatformTest.php
.../Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
+16
-0
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
ba4ab893
...
...
@@ -2618,6 +2618,37 @@ abstract class AbstractPlatform
return
false
;
}
/**
* Whether the platform emulates identity columns through sequences.
*
* Some platforms that do not support identity columns natively
* but support sequences can emulate identity columns by using
* sequences.
*
* @return boolean
*/
public
function
usesSequenceEmulatedIdentityColumns
()
{
return
false
;
}
/**
* Returns the name of the sequence for a particular identity column in a particular table.
*
* @param string $tableName The name of the table to return the sequence name for.
* @param string $columnName The name of the identity column in the table to return the sequence name for.
*
* @return string
*
* @throws \Doctrine\DBAL\DBALException If not supported on this platform.
*
* @see usesSequenceEmulatedIdentityColumns
*/
public
function
getIdentitySequenceName
(
$tableName
,
$columnName
)
{
throw
DBALException
::
notSupported
(
__METHOD__
);
}
/**
* Whether the platform supports indexes.
*
...
...
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
ba4ab893
...
...
@@ -448,7 +448,7 @@ BEGIN
END IF;
END;'
;
$sequenceName
=
$t
able
.
'_'
.
$name
.
'_SEQ'
;
$sequenceName
=
$t
his
->
getIdentitySequenceName
(
$table
,
$name
)
;
$sequence
=
new
Sequence
(
$sequenceName
,
$start
);
$sql
[]
=
$this
->
getCreateSequenceSQL
(
$sequence
);
...
...
@@ -695,6 +695,22 @@ LEFT JOIN user_cons_columns r_cols
return
true
;
}
/**
* {@inheritdoc}
*/
public
function
usesSequenceEmulatedIdentityColumns
()
{
return
true
;
}
/**
* {@inheritdoc}
*/
public
function
getIdentitySequenceName
(
$tableName
,
$columnName
)
{
return
$tableName
.
'_'
.
$columnName
.
'_SEQ'
;
}
/**
* {@inheritDoc}
*/
...
...
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
ba4ab893
...
...
@@ -180,6 +180,22 @@ class PostgreSqlPlatform extends AbstractPlatform
return
true
;
}
/**
* {@inheritdoc}
*/
public
function
usesSequenceEmulatedIdentityColumns
()
{
return
true
;
}
/**
* {@inheritdoc}
*/
public
function
getIdentitySequenceName
(
$tableName
,
$columnName
)
{
return
$tableName
.
'_'
.
$columnName
.
'_seq'
;
}
/**
* {@inheritDoc}
*/
...
...
@@ -466,7 +482,7 @@ class PostgreSqlPlatform extends AbstractPlatform
if
(
$columnDiff
->
hasChanged
(
'autoincrement'
))
{
if
(
$column
->
getAutoincrement
())
{
// add autoincrement
$seqName
=
$
diff
->
name
.
'_'
.
$oldColumnName
.
'_seq'
;
$seqName
=
$
this
->
getIdentitySequenceName
(
$diff
->
name
,
$oldColumnName
)
;
$sql
[]
=
"CREATE SEQUENCE "
.
$seqName
;
$sql
[]
=
"SELECT setval('"
.
$seqName
.
"', (SELECT MAX("
.
$oldColumnName
.
") FROM "
.
$diff
->
getName
()
->
getQuotedName
(
$this
)
.
"))"
;
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
ba4ab893
...
...
@@ -530,4 +530,21 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
implode
(
';'
,
$this
->
_platform
->
getAlterTableSQL
(
$tableDiff
))
);
}
/**
* @group DBAL-563
*/
public
function
testUsesSequenceEmulatedIdentityColumns
()
{
$this
->
assertFalse
(
$this
->
_platform
->
usesSequenceEmulatedIdentityColumns
());
}
/**
* @group DBAL-563
* @expectedException \Doctrine\DBAL\DBALException
*/
public
function
testReturnsIdentitySequenceName
()
{
$this
->
_platform
->
getIdentitySequenceName
(
'mytable'
,
'mycolumn'
);
}
}
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
View file @
ba4ab893
...
...
@@ -330,4 +330,20 @@ class OraclePlatformTest extends AbstractPlatformTestCase
);
$this
->
assertEquals
(
$expectedSql
,
$this
->
_platform
->
getAlterTableSQL
(
$tableDiff
));
}
/**
* @group DBAL-563
*/
public
function
testUsesSequenceEmulatedIdentityColumns
()
{
$this
->
assertTrue
(
$this
->
_platform
->
usesSequenceEmulatedIdentityColumns
());
}
/**
* @group DBAL-563
*/
public
function
testReturnsIdentitySequenceName
()
{
$this
->
assertSame
(
'mytable_mycolumn_SEQ'
,
$this
->
_platform
->
getIdentitySequenceName
(
'mytable'
,
'mycolumn'
));
}
}
tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
View file @
ba4ab893
...
...
@@ -410,4 +410,20 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
$this
->
assertEquals
(
$expectedSql
,
$sql
);
}
/**
* @group DBAL-563
*/
public
function
testUsesSequenceEmulatedIdentityColumns
()
{
$this
->
assertTrue
(
$this
->
_platform
->
usesSequenceEmulatedIdentityColumns
());
}
/**
* @group DBAL-563
*/
public
function
testReturnsIdentitySequenceName
()
{
$this
->
assertSame
(
'mytable_mycolumn_seq'
,
$this
->
_platform
->
getIdentitySequenceName
(
'mytable'
,
'mycolumn'
));
}
}
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