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
6252da0c
Commit
6252da0c
authored
May 16, 2014
by
Marco Pivetta
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #546 from deeky666/DBAL-474
[DBAL-474] Fix filtering sequence names on PostgreSQL
parents
ea5ac958
3e32874e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
0 deletions
+102
-0
PostgreSqlSchemaManager.php
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
+26
-0
PostgreSQLSchemaManagerTest.php
...octrine/Tests/DBAL/Schema/PostgreSQLSchemaManagerTest.php
+76
-0
No files found.
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
View file @
6252da0c
...
...
@@ -257,6 +257,32 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
return
$database
[
'datname'
];
}
/**
* {@inheritdoc}
*/
protected
function
_getPortableSequencesList
(
$sequences
)
{
$sequenceDefinitions
=
array
();
foreach
(
$sequences
as
$sequence
)
{
if
(
$sequence
[
'schemaname'
]
!=
'public'
)
{
$sequenceName
=
$sequence
[
'schemaname'
]
.
"."
.
$sequence
[
'relname'
];
}
else
{
$sequenceName
=
$sequence
[
'relname'
];
}
$sequenceDefinitions
[
$sequenceName
]
=
$sequence
;
}
$list
=
array
();
foreach
(
$this
->
filterAssetNames
(
array_keys
(
$sequenceDefinitions
))
as
$sequenceName
)
{
$list
[]
=
$this
->
_getPortableSequenceDefinition
(
$sequenceDefinitions
[
$sequenceName
]);
}
return
$list
;
}
/**
* {@inheritdoc}
*/
...
...
tests/Doctrine/Tests/DBAL/Schema/PostgreSQLSchemaManagerTest.php
0 → 100644
View file @
6252da0c
<?php
namespace
Doctrine\Tests\DBAL\Schema
;
use
Doctrine\DBAL\Configuration
;
use
Doctrine\DBAL\Schema\PostgreSqlSchemaManager
;
use
Doctrine\DBAL\Schema\Sequence
;
use
Doctrine\Tests\DBAL\Mocks
;
class
PostgreSQLSchemaManagerTest
extends
\PHPUnit_Framework_TestCase
{
/**
* @var \Doctrine\DBAL\Schema\PostgreSQLSchemaManager
*/
private
$schemaManager
;
/**
* @var \Doctrine\DBAL\Connection|\PHPUnit_Framework_MockObject_MockObject
*/
private
$connection
;
protected
function
setUp
()
{
$driverMock
=
$this
->
getMock
(
'Doctrine\DBAL\Driver'
);
$platform
=
$this
->
getMock
(
'Doctrine\DBAL\Platforms\PostgreSqlPlatform'
);
$this
->
connection
=
$this
->
getMock
(
'Doctrine\DBAL\Connection'
,
array
(),
array
(
array
(
'platform'
=>
$platform
),
$driverMock
)
);
$this
->
schemaManager
=
new
PostgreSqlSchemaManager
(
$this
->
connection
,
$platform
);
}
/**
* @group DBAL-474
*/
public
function
testFiltersSequences
()
{
$configuration
=
new
Configuration
();
$configuration
->
setFilterSchemaAssetsExpression
(
'/^schema/'
);
$sequences
=
array
(
array
(
'relname'
=>
'foo'
,
'schemaname'
=>
'schema'
),
array
(
'relname'
=>
'bar'
,
'schemaname'
=>
'schema'
),
array
(
'relname'
=>
'baz'
,
'schemaname'
=>
''
),
array
(
'relname'
=>
'bloo'
,
'schemaname'
=>
'bloo_schema'
),
);
$this
->
connection
->
expects
(
$this
->
any
())
->
method
(
'getConfiguration'
)
->
will
(
$this
->
returnValue
(
$configuration
));
$this
->
connection
->
expects
(
$this
->
at
(
0
))
->
method
(
'fetchAll'
)
->
will
(
$this
->
returnValue
(
$sequences
));
$this
->
connection
->
expects
(
$this
->
at
(
1
))
->
method
(
'fetchAll'
)
->
will
(
$this
->
returnValue
(
array
(
array
(
'min_value'
=>
1
,
'increment_by'
=>
1
))));
$this
->
connection
->
expects
(
$this
->
at
(
2
))
->
method
(
'fetchAll'
)
->
will
(
$this
->
returnValue
(
array
(
array
(
'min_value'
=>
2
,
'increment_by'
=>
2
))));
$this
->
connection
->
expects
(
$this
->
exactly
(
3
))
->
method
(
'fetchAll'
);
$this
->
assertEquals
(
array
(
new
Sequence
(
'schema.foo'
,
2
,
2
),
new
Sequence
(
'schema.bar'
,
1
,
1
),
),
$this
->
schemaManager
->
listSequences
(
'database'
)
);
}
}
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