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
583e141a
Commit
583e141a
authored
Nov 14, 2011
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DBAL-168 - Fix bug with PostgreSQL schema handling
parent
64329fcb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
5 deletions
+38
-5
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+11
-5
DBAL168Test.php
tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php
+27
-0
No files found.
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
583e141a
...
...
@@ -210,8 +210,7 @@ class PostgreSqlPlatform extends AbstractPlatform
(
SELECT c.oid
FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n
WHERE "
.
$this
->
getTableWhereClause
(
$table
)
.
"
AND n.oid = c.relnamespace
WHERE "
.
$this
->
getTableWhereClause
(
$table
)
.
" AND n.oid = c.relnamespace
)
AND r.contype = 'f'"
;
}
...
...
@@ -259,15 +258,22 @@ class PostgreSqlPlatform extends AbstractPlatform
) AND pg_index.indexrelid = oid"
;
}
/**
* @param string $table
* @param string $classAlias
* @param string $namespaceAlias
* @return string
*/
private
function
getTableWhereClause
(
$table
,
$classAlias
=
'c'
,
$namespaceAlias
=
'n'
)
{
$whereClause
=
"
"
;
$whereClause
=
$namespaceAlias
.
".nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') AND
"
;
if
(
strpos
(
$table
,
"."
)
!==
false
)
{
list
(
$schema
,
$table
)
=
explode
(
"."
,
$table
);
$whereClause
=
"
$classAlias
.relname = '"
.
$table
.
"' AND
$namespaceAlias
.nspname = '"
.
$schema
.
"'"
;
$whereClause
.
=
"
$classAlias
.relname = '"
.
$table
.
"' AND
$namespaceAlias
.nspname = '"
.
$schema
.
"'"
;
}
else
{
$whereClause
=
"
$classAlias
.relname = '"
.
$table
.
"'"
;
$whereClause
.
=
"
$classAlias
.relname = '"
.
$table
.
"'"
;
}
return
$whereClause
;
}
...
...
tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php
0 → 100644
View file @
583e141a
<?php
namespace
Doctrine\Tests\DBAL\Functional\Ticket
;
/**
* @group DBAL-168
*/
class
DBAL168Test
extends
\Doctrine\Tests\DbalFunctionalTestCase
{
public
function
testDomainsTable
()
{
if
(
$this
->
_conn
->
getDatabasePlatform
()
->
getName
()
!=
"postgresql"
)
{
$this
->
markTestSkipped
(
'PostgreSQL only test'
);
}
$table
=
new
\Doctrine\DBAL\Schema\Table
(
"domains"
);
$table
->
addColumn
(
'id'
,
'integer'
);
$table
->
addColumn
(
'parent_id'
,
'integer'
);
$table
->
setPrimaryKey
(
array
(
'id'
));
$table
->
addForeignKeyConstraint
(
'domains'
,
array
(
'parent_id'
),
array
(
'id'
));
$this
->
_conn
->
getSchemaManager
()
->
createTable
(
$table
);
$table
=
$this
->
_conn
->
getSchemaManager
()
->
listTableDetails
(
'domains'
);
$this
->
assertEquals
(
'domains'
,
$table
->
getName
());
}
}
\ 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