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
6bed1f4e
Unverified
Commit
6bed1f4e
authored
Mar 16, 2019
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Assert that the username is specified on the connection when listing DB2 tables
parent
0db36a96
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
DB2SchemaManager.php
lib/Doctrine/DBAL/Schema/DB2SchemaManager.php
+8
-4
DB2SchemaManagerTest.php
tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php
+12
-7
No files found.
lib/Doctrine/DBAL/Schema/DB2SchemaManager.php
View file @
6bed1f4e
...
@@ -6,7 +6,9 @@ use Doctrine\DBAL\Platforms\DB2Platform;
...
@@ -6,7 +6,9 @@ use Doctrine\DBAL\Platforms\DB2Platform;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\DBAL\Types\Type
;
use
const
CASE_LOWER
;
use
const
CASE_LOWER
;
use
function
array_change_key_case
;
use
function
array_change_key_case
;
use
function
assert
;
use
function
is_resource
;
use
function
is_resource
;
use
function
is_string
;
use
function
preg_match
;
use
function
preg_match
;
use
function
str_replace
;
use
function
str_replace
;
use
function
strpos
;
use
function
strpos
;
...
@@ -24,12 +26,14 @@ class DB2SchemaManager extends AbstractSchemaManager
...
@@ -24,12 +26,14 @@ class DB2SchemaManager extends AbstractSchemaManager
* Apparently creator is the schema not the user who created it:
* Apparently creator is the schema not the user who created it:
* {@link http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.sqlref/db2z_sysibmsystablestable.htm}
* {@link http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.sqlref/db2z_sysibmsystablestable.htm}
*/
*/
public
function
listTableNames
()
public
function
listTableNames
()
:
array
{
{
$
sql
=
$this
->
_platform
->
getListTablesSQL
();
$
username
=
$this
->
_conn
->
getUsername
();
$sql
.=
' AND CREATOR = UPPER('
.
$this
->
_conn
->
quote
(
$this
->
_conn
->
getUsername
())
.
')'
;
assert
(
is_string
(
$username
))
;
$tables
=
$this
->
_conn
->
fetchAll
(
$sql
);
$sql
=
$this
->
_platform
->
getListTablesSQL
()
.
' AND CREATOR = UPPER(?)'
;
$tables
=
$this
->
_conn
->
fetchAll
(
$sql
,
[
$username
]);
return
$this
->
filterAssetNames
(
$this
->
_getPortableTablesList
(
$tables
));
return
$this
->
filterAssetNames
(
$this
->
_getPortableTablesList
(
$tables
));
}
}
...
...
tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php
View file @
6bed1f4e
...
@@ -30,9 +30,14 @@ final class DB2SchemaManagerTest extends TestCase
...
@@ -30,9 +30,14 @@ final class DB2SchemaManagerTest extends TestCase
$platform
=
$this
->
createMock
(
DB2Platform
::
class
);
$platform
=
$this
->
createMock
(
DB2Platform
::
class
);
$this
->
conn
=
$this
$this
->
conn
=
$this
->
getMockBuilder
(
Connection
::
class
)
->
getMockBuilder
(
Connection
::
class
)
->
onlyMethods
([
'fetchAll'
,
'
quot
e'
])
->
onlyMethods
([
'fetchAll'
,
'
getUsernam
e'
])
->
setConstructorArgs
([[
'platform'
=>
$platform
],
$driverMock
,
new
Configuration
(),
$eventManager
])
->
setConstructorArgs
([[
'platform'
=>
$platform
],
$driverMock
,
new
Configuration
(),
$eventManager
])
->
getMock
();
->
getMock
();
$this
->
conn
->
expects
(
$this
->
any
())
->
method
(
'getUsername'
)
->
willReturn
(
'db2inst1'
);
$this
->
manager
=
new
DB2SchemaManager
(
$this
->
conn
);
$this
->
manager
=
new
DB2SchemaManager
(
$this
->
conn
);
}
}
...
@@ -95,7 +100,7 @@ final class DB2SchemaManagerTest extends TestCase
...
@@ -95,7 +100,7 @@ final class DB2SchemaManagerTest extends TestCase
$this
->
conn
->
getConfiguration
()
->
setSchemaAssetsFilter
(
static
function
(
$assetName
)
use
(
$accepted
)
{
$this
->
conn
->
getConfiguration
()
->
setSchemaAssetsFilter
(
static
function
(
$assetName
)
use
(
$accepted
)
{
return
in_array
(
$assetName
,
$accepted
);
return
in_array
(
$assetName
,
$accepted
);
});
});
$this
->
conn
->
expects
(
$this
->
any
())
->
method
(
'quote'
);
$this
->
conn
->
expects
(
$this
->
once
())
->
method
(
'fetchAll'
)
->
will
(
$this
->
returnValue
([
$this
->
conn
->
expects
(
$this
->
once
())
->
method
(
'fetchAll'
)
->
will
(
$this
->
returnValue
([
[
'name'
=>
'FOO'
],
[
'name'
=>
'FOO'
],
[
'name'
=>
'T_FOO'
],
[
'name'
=>
'T_FOO'
],
...
@@ -120,7 +125,7 @@ final class DB2SchemaManagerTest extends TestCase
...
@@ -120,7 +125,7 @@ final class DB2SchemaManagerTest extends TestCase
$this
->
conn
->
getConfiguration
()
->
setSchemaAssetsFilter
(
static
function
(
$assetName
)
use
(
$accepted
)
{
$this
->
conn
->
getConfiguration
()
->
setSchemaAssetsFilter
(
static
function
(
$assetName
)
use
(
$accepted
)
{
return
in_array
(
$assetName
,
$accepted
);
return
in_array
(
$assetName
,
$accepted
);
});
});
$this
->
conn
->
expects
(
$this
->
any
())
->
method
(
'quote'
);
$this
->
conn
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'fetchAll'
)
->
will
(
$this
->
returnValue
([
$this
->
conn
->
expects
(
$this
->
atLeastOnce
())
->
method
(
'fetchAll'
)
->
will
(
$this
->
returnValue
([
[
'name'
=>
'FOO'
],
[
'name'
=>
'FOO'
],
[
'name'
=>
'T_FOO'
],
[
'name'
=>
'T_FOO'
],
...
...
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