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
bb844961
Commit
bb844961
authored
Nov 14, 2011
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DBAL-144 - Dont throw exception when no primary key exists
parent
4138d8ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
15 deletions
+18
-15
Table.php
lib/Doctrine/DBAL/Schema/Table.php
+13
-10
Graphviz.php
lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php
+5
-5
No files found.
lib/Doctrine/DBAL/Schema/Table.php
View file @
bb844961
...
@@ -88,11 +88,11 @@ class Table extends AbstractAsset
...
@@ -88,11 +88,11 @@ class Table extends AbstractAsset
$this
->
_setName
(
$tableName
);
$this
->
_setName
(
$tableName
);
$this
->
_idGeneratorType
=
$idGeneratorType
;
$this
->
_idGeneratorType
=
$idGeneratorType
;
foreach
(
$columns
AS
$column
)
{
foreach
(
$columns
AS
$column
)
{
$this
->
_addColumn
(
$column
);
$this
->
_addColumn
(
$column
);
}
}
foreach
(
$indexes
AS
$idx
)
{
foreach
(
$indexes
AS
$idx
)
{
$this
->
_addIndex
(
$idx
);
$this
->
_addIndex
(
$idx
);
}
}
...
@@ -252,7 +252,7 @@ class Table extends AbstractAsset
...
@@ -252,7 +252,7 @@ class Table extends AbstractAsset
/**
/**
* Change Column Details
* Change Column Details
*
*
* @param string $columnName
* @param string $columnName
* @param array $options
* @param array $options
* @return Table
* @return Table
...
@@ -266,7 +266,7 @@ class Table extends AbstractAsset
...
@@ -266,7 +266,7 @@ class Table extends AbstractAsset
/**
/**
* Drop Column from Table
* Drop Column from Table
*
*
* @param string $columnName
* @param string $columnName
* @return Table
* @return Table
*/
*/
...
@@ -344,7 +344,7 @@ class Table extends AbstractAsset
...
@@ -344,7 +344,7 @@ class Table extends AbstractAsset
throw
SchemaException
::
columnDoesNotExist
(
$columnName
,
$this
->
_name
);
throw
SchemaException
::
columnDoesNotExist
(
$columnName
,
$this
->
_name
);
}
}
}
}
$constraint
=
new
ForeignKeyConstraint
(
$constraint
=
new
ForeignKeyConstraint
(
$localColumnNames
,
$foreignTableName
,
$foreignColumnNames
,
$name
,
$options
$localColumnNames
,
$foreignTableName
,
$foreignColumnNames
,
$name
,
$options
);
);
...
@@ -381,7 +381,7 @@ class Table extends AbstractAsset
...
@@ -381,7 +381,7 @@ class Table extends AbstractAsset
/**
/**
* Add index to table
* Add index to table
*
*
* @param Index $indexCandidate
* @param Index $indexCandidate
* @return Table
* @return Table
*/
*/
...
@@ -422,7 +422,7 @@ class Table extends AbstractAsset
...
@@ -422,7 +422,7 @@ class Table extends AbstractAsset
protected
function
_addForeignKeyConstraint
(
ForeignKeyConstraint
$constraint
)
protected
function
_addForeignKeyConstraint
(
ForeignKeyConstraint
$constraint
)
{
{
$constraint
->
setLocalTable
(
$this
);
$constraint
->
setLocalTable
(
$this
);
if
(
strlen
(
$constraint
->
getName
()))
{
if
(
strlen
(
$constraint
->
getName
()))
{
$name
=
$constraint
->
getName
();
$name
=
$constraint
->
getName
();
}
else
{
}
else
{
...
@@ -475,7 +475,7 @@ class Table extends AbstractAsset
...
@@ -475,7 +475,7 @@ class Table extends AbstractAsset
$pkCols
=
array
();
$pkCols
=
array
();
$fkCols
=
array
();
$fkCols
=
array
();
if
(
$this
->
has
Index
(
$this
->
_primaryKeyName
))
{
if
(
$this
->
has
PrimaryKey
(
))
{
$pkCols
=
$this
->
getPrimaryKey
()
->
getColumns
();
$pkCols
=
$this
->
getPrimaryKey
()
->
getColumns
();
}
}
foreach
(
$this
->
getForeignKeys
()
AS
$fk
)
{
foreach
(
$this
->
getForeignKeys
()
AS
$fk
)
{
...
@@ -505,7 +505,7 @@ class Table extends AbstractAsset
...
@@ -505,7 +505,7 @@ class Table extends AbstractAsset
/**
/**
* Get a column instance
* Get a column instance
*
*
* @param string $columnName
* @param string $columnName
* @return Column
* @return Column
*/
*/
...
@@ -520,10 +520,13 @@ class Table extends AbstractAsset
...
@@ -520,10 +520,13 @@ class Table extends AbstractAsset
}
}
/**
/**
* @return Index
* @return Index
|null
*/
*/
public
function
getPrimaryKey
()
public
function
getPrimaryKey
()
{
{
if
(
!
$this
->
hasPrimaryKey
())
{
return
null
;
}
return
$this
->
getIndex
(
$this
->
_primaryKeyName
);
return
$this
->
getIndex
(
$this
->
_primaryKeyName
);
}
}
...
...
lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php
View file @
bb844961
...
@@ -35,7 +35,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
...
@@ -35,7 +35,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
public
function
acceptColumn
(
Table
$table
,
Column
$column
)
public
function
acceptColumn
(
Table
$table
,
Column
$column
)
{
{
}
}
public
function
acceptForeignKey
(
Table
$localTable
,
ForeignKeyConstraint
$fkConstraint
)
public
function
acceptForeignKey
(
Table
$localTable
,
ForeignKeyConstraint
$fkConstraint
)
...
@@ -53,7 +53,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
...
@@ -53,7 +53,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
public
function
acceptIndex
(
Table
$table
,
Index
$index
)
public
function
acceptIndex
(
Table
$table
,
Index
$index
)
{
{
}
}
public
function
acceptSchema
(
Schema
$schema
)
public
function
acceptSchema
(
Schema
$schema
)
...
@@ -68,7 +68,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
...
@@ -68,7 +68,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
public
function
acceptSequence
(
Sequence
$sequence
)
public
function
acceptSequence
(
Sequence
$sequence
)
{
{
}
}
public
function
acceptTable
(
Table
$table
)
public
function
acceptTable
(
Table
$table
)
...
@@ -99,7 +99,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
...
@@ -99,7 +99,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
$label
.=
'<FONT COLOR="#2e3436" FACE="Helvetica" POINT-SIZE="12">'
.
$columnLabel
.
'</FONT>'
;
$label
.=
'<FONT COLOR="#2e3436" FACE="Helvetica" POINT-SIZE="12">'
.
$columnLabel
.
'</FONT>'
;
$label
.=
'</TD><TD BORDER="0" ALIGN="LEFT" BGCOLOR="#eeeeec"><FONT COLOR="#2e3436" FACE="Helvetica" POINT-SIZE="10">'
.
strtolower
(
$column
->
getType
())
.
'</FONT></TD>'
;
$label
.=
'</TD><TD BORDER="0" ALIGN="LEFT" BGCOLOR="#eeeeec"><FONT COLOR="#2e3436" FACE="Helvetica" POINT-SIZE="10">'
.
strtolower
(
$column
->
getType
())
.
'</FONT></TD>'
;
$label
.=
'<TD BORDER="0" ALIGN="RIGHT" BGCOLOR="#eeeeec" PORT="col'
.
$column
->
getName
()
.
'">'
;
$label
.=
'<TD BORDER="0" ALIGN="RIGHT" BGCOLOR="#eeeeec" PORT="col'
.
$column
->
getName
()
.
'">'
;
if
(
in_array
(
$column
->
getName
(),
$table
->
getPrimaryKey
()
->
getColumns
()))
{
if
(
$table
->
hasPrimaryKey
()
&&
in_array
(
$column
->
getName
(),
$table
->
getPrimaryKey
()
->
getColumns
()))
{
$label
.=
"
\xe2\x9c\xb7
"
;
$label
.=
"
\xe2\x9c\xb7
"
;
}
}
$label
.=
'</TD></TR>'
;
$label
.=
'</TD></TR>'
;
...
@@ -139,7 +139,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
...
@@ -139,7 +139,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
* You have to convert the output into a viewable format. For example use "neato" on linux systems
* You have to convert the output into a viewable format. For example use "neato" on linux systems
* and execute:
* and execute:
*
*
* neato -Tpng -o er.png er.dot
* neato -Tpng -o er.png er.dot
*
*
* @param string $filename
* @param string $filename
* @return void
* @return void
...
...
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