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
e48d65df
Commit
e48d65df
authored
Jun 25, 2020
by
Semih Serhat Karakaya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
respect to platform restrictions when creating an identfier name for oracle
parent
9daede40
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
2 deletions
+51
-2
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+18
-2
PlatformRestrictionsTest.php
...sts/DBAL/Functional/Platform/PlatformRestrictionsTest.php
+33
-0
No files found.
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
e48d65df
...
...
@@ -586,6 +586,22 @@ END;';
return
$identifier
->
isQuoted
()
?
$identifier
:
new
Identifier
(
strtoupper
(
$name
));
}
/**
* Adds suffix to identifier,
*
* if the new string exceeds max identifier length,
* keeps $suffix, cuts from $identifier as much as the part exceeding.
*/
private
function
addSuffix
(
string
$identifier
,
string
$suffix
)
:
string
{
$maxPossibleLengthWithoutSuffix
=
$this
->
getMaxIdentifierLength
()
-
strlen
(
$suffix
);
if
(
strlen
(
$identifier
)
>
$maxPossibleLengthWithoutSuffix
)
{
$identifier
=
substr
(
$identifier
,
0
,
$maxPossibleLengthWithoutSuffix
);
}
return
$identifier
.
$suffix
;
}
/**
* Returns the autoincrement primary key identifier name for the given table identifier.
*
...
...
@@ -598,7 +614,7 @@ END;';
*/
private
function
getAutoincrementIdentifierName
(
Identifier
$table
)
{
$identifierName
=
$t
able
->
getName
()
.
'_AI_PK'
;
$identifierName
=
$t
his
->
addSuffix
(
$table
->
getName
(),
'_AI_PK'
)
;
return
$table
->
isQuoted
()
?
$this
->
quoteSingleIdentifier
(
$identifierName
)
...
...
@@ -966,7 +982,7 @@ SQL
$table
=
new
Identifier
(
$tableName
);
// No usage of column name to preserve BC compatibility with <2.5
$identitySequenceName
=
$t
able
->
getName
()
.
'_SEQ'
;
$identitySequenceName
=
$t
his
->
addSuffix
(
$table
->
getName
(),
'_SEQ'
)
;
if
(
$table
->
isQuoted
())
{
$identitySequenceName
=
'"'
.
$identitySequenceName
.
'"'
;
...
...
tests/Doctrine/Tests/DBAL/Functional/Platform/PlatformRestrictionsTest.php
0 → 100644
View file @
e48d65df
<?php
namespace
Doctrine\Tests\DBAL\Functional\Platform
;
use
Doctrine\DBAL\Schema\Table
;
use
Doctrine\Tests\DbalFunctionalTestCase
;
use
function
str_repeat
;
/**
* This class holds tests that make sure generated SQL statements respect to platform restrictions
* like maximum element name length
*/
class
PlatformRestrictionsTest
extends
DbalFunctionalTestCase
{
/**
* Tests element names that are at the boundary of the identifier length limit.
* Ensures generated auto-increment identifier name respects to platform restrictions.
*/
public
function
testMaxIdentifierLengthLimitWithAutoIncrement
()
:
void
{
$platform
=
$this
->
connection
->
getDatabasePlatform
();
$tableName
=
str_repeat
(
'x'
,
$platform
->
getMaxIdentifierLength
());
$columnName
=
str_repeat
(
'y'
,
$platform
->
getMaxIdentifierLength
());
$table
=
new
Table
(
$tableName
);
$table
->
addColumn
(
$columnName
,
'integer'
,
[
'autoincrement'
=>
true
]);
$table
->
setPrimaryKey
([
$columnName
]);
$this
->
connection
->
getSchemaManager
()
->
dropAndCreateTable
(
$table
);
$createdTable
=
$this
->
connection
->
getSchemaManager
()
->
listTableDetails
(
$tableName
);
$this
->
assertTrue
(
$createdTable
->
hasColumn
(
$columnName
));
$this
->
assertTrue
(
$createdTable
->
hasPrimaryKey
());
}
}
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