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
6ccd739c
Commit
6ccd739c
authored
Jul 20, 2014
by
chris rehfeld
Committed by
Steve Müller
Sep 11, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove testwhich was unsuitable for test suite
parent
3abb3ea2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
144 deletions
+0
-144
DoctrineDb2v10AdaptorTest.php
...ctrine/Tests/DBAL/Platforms/DoctrineDb2v10AdaptorTest.php
+0
-144
No files found.
tests/Doctrine/Tests/DBAL/Platforms/DoctrineDb2v10AdaptorTest.php
deleted
100644 → 0
View file @
3abb3ea2
<?php
class
DoctrineDb2v10AdaptorTest
extends
PHPUnit_Framework_TestCase
{
// The only difference this query has compared to the original is that
// I cast the column named "DEFAULT" to varchar(254). I don't feel this will
// affect the ability of the DISTINCT clause from doing it's job properly, because
// I don't feel we would ever have any rows which only differ in the value of that column.
// I had to do this to get it to run on db2 v10.
private
$oldSql
=
"
SELECT DISTINCT
c.tabschema,
c.tabname,
c.colname,
c.colno,
c.typename,
CAST(c.default AS VARCHAR(254)) AS DEFAULT,
c.nulls,
c.length,
c.scale,
c.identity,
tc.type AS tabconsttype,
k.colseq,
CASE
WHEN c.generated = 'D' THEN 1
ELSE 0
END AS autoincrement
FROM syscat.columns c
LEFT JOIN (syscat.keycoluse k JOIN syscat.tabconst tc
ON (k.tabschema = tc.tabschema
AND k.tabname = tc.tabname
AND tc.type = 'P'))
ON (c.tabschema = k.tabschema
AND c.tabname = k.tabname
AND c.colname = k.colname)
WHERE UPPER(c.tabname) = UPPER(?)
ORDER BY c.colno
"
;
// This query wraps the original query into a subquery, but omits the column named "DEFAULT".
// This way the distinct clause can operate on the remaining columns without error, and then we join the
// results back to the syscat.columns table in order to attach the values of the column we omitted.
private
$newSql
=
"
SELECT
cols.default,
subq.*
FROM (
SELECT DISTINCT
c.tabschema,
c.tabname,
c.colname,
c.colno,
c.typename,
c.nulls,
c.length,
c.scale,
c.identity,
tc.type AS tabconsttype,
k.colseq,
CASE
WHEN c.generated = 'D' THEN 1
ELSE 0
END AS autoincrement
FROM syscat.columns c
LEFT JOIN (syscat.keycoluse k JOIN syscat.tabconst tc
ON (k.tabschema = tc.tabschema
AND k.tabname = tc.tabname
AND tc.type = 'P'))
ON (c.tabschema = k.tabschema
AND c.tabname = k.tabname
AND c.colname = k.colname)
WHERE UPPER(c.tabname) = UPPER(?)
ORDER BY c.colno
) subq
JOIN syscat.columns cols
ON subq.tabschema = cols.tabschema
AND subq.tabname = cols.tabname
AND subq.colno = cols.colno
ORDER BY subq.colno
"
;
private
$conn
;
function
setUp
()
{
$config
=
require
'../../config/autoload/global.php'
;
extract
(
$config
[
'doctrine'
][
'connection'
][
'orm_default'
][
'params'
]);
$this
->
conn
=
db2_connect
(
"DRIVER={IBM DB2 ODBC DRIVER};HOSTNAME=
$host
;PORT=
$port
;DATABASE=
$dbname
;PROTOCOL=TCPIP;UID=
$user
;PWD=
$password
;"
,
$user
,
$password
);
}
function
testQueriesProduceIdenticalRowsForAllTables
()
{
foreach
(
$this
->
getAllTables
()
as
$tbl
)
{
$this
->
checkRowsMatchForTable
(
$tbl
);
}
}
private
function
checkRowsMatchForTable
(
$tbl
)
{
// run each query and fetch the rows they produce
$oldRows
=
$this
->
fetchall
(
$this
->
oldSql
,
array
(
$tbl
),
$this
->
conn
);
$newRows
=
$this
->
fetchall
(
$this
->
newSql
,
array
(
$tbl
),
$this
->
conn
);
// compare the num of rows
$this
->
assertEquals
(
count
(
$oldRows
),
count
(
$newRows
));
// sort them so that I can compare the correct rows
$cmp
=
function
(
$a
,
$b
)
{
$fmt
=
"%s,%s,%s"
;
return
strcmp
(
sprintf
(
$fmt
,
$a
[
'TABSCHEMA'
],
$a
[
'TABNAME'
],
$a
[
'COLNO'
]),
sprintf
(
$fmt
,
$b
[
'TABSCHEMA'
],
$b
[
'TABNAME'
],
$b
[
'COLNO'
])
);
};
usort
(
$oldRows
,
$cmp
);
usort
(
$newRows
,
$cmp
);
$this
->
assertEquals
(
$newRows
,
$oldRows
);
}
private
function
getAllTables
()
{
$sql
=
"
select distinct TABNAME
from syscat.columns
"
;
return
array_map
(
function
(
$row
)
{
return
$row
[
'TABNAME'
];
},
$this
->
fetchAll
(
$sql
,
array
(),
$this
->
conn
));
}
private
function
fetchAll
(
$sql
,
$args
,
$conn
)
{
$ret
=
array
();
$stmt
=
db2_prepare
(
$conn
,
$sql
);
db2_execute
(
$stmt
,
$args
);
while
(
$row
=
db2_fetch_assoc
(
$stmt
))
{
$ret
[]
=
$row
;
}
return
$ret
;
}
}
\ No newline at end of file
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