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
75dbc8c8
Commit
75dbc8c8
authored
Jul 21, 2007
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Several bugfixes for the export module (expecially pgsql).
parent
6348e5f7
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1885 additions
and
1813 deletions
+1885
-1813
Pgsql.php
lib/Doctrine/DataDict/Pgsql.php
+621
-621
Export.php
lib/Doctrine/Export.php
+1094
-1093
Pgsql.php
lib/Doctrine/Export/Pgsql.php
+63
-0
PgsqlTestCase.php
tests/Export/PgsqlTestCase.php
+98
-98
SingleRootTestCase.php
tests/NestedSet/SingleRootTestCase.php
+8
-0
run.php
tests/run.php
+1
-1
No files found.
lib/Doctrine/DataDict/Pgsql.php
View file @
75dbc8c8
...
...
@@ -496,7 +496,7 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict
if
(
preg_match
(
'/^(is|has)/'
,
$field
[
'name'
]))
{
$type
=
array_reverse
(
$type
);
}
}
elseif
(
strstr
(
$db
_type
,
'text'
))
{
}
elseif
(
strstr
(
$db
Type
,
'text'
))
{
$type
[]
=
'clob'
;
}
if
(
$fixed
!==
false
)
{
...
...
@@ -545,7 +545,7 @@ class Doctrine_DataDict_Pgsql extends Doctrine_DataDict
$length
=
null
;
break
;
default
:
throw
new
Doctrine_DataDict_Exception
(
'unknown database attribute type: '
.
$db
_type
);
throw
new
Doctrine_DataDict_Exception
(
'unknown database attribute type: '
.
$db
Type
);
}
return
array
(
'type'
=>
$type
,
...
...
lib/Doctrine/Export.php
View file @
75dbc8c8
...
...
@@ -44,6 +44,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
'date'
=>
'1970-01-01'
,
'clob'
=>
''
,
'blob'
=>
''
,
'string'
=>
''
);
/**
...
...
@@ -426,7 +427,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
$query
=
'CREATE '
.
$type
.
'INDEX '
.
$name
.
' ON '
.
$table
;
$fields
=
array
();
foreach
(
array_keys
(
$definition
[
'fields'
])
as
$field
)
{
foreach
(
$definition
[
'fields'
]
as
$field
)
{
$fields
[]
=
$this
->
conn
->
quoteIdentifier
(
$field
);
}
$query
.=
' ('
.
implode
(
', '
,
$fields
)
.
')'
;
...
...
@@ -672,7 +673,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
?
null
:
$this
->
valid_default_values
[
$field
[
'type'
]];
if
(
$field
[
'default'
]
===
''
&&
(
$
conn
->
getAttribute
(
Doctrine
::
ATTR_PORTABILITY
)
&
Doctrine
::
PORTABILITY_EMPTY_TO_NULL
))
{
(
$
this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_PORTABILITY
)
&
Doctrine
::
PORTABILITY_EMPTY_TO_NULL
))
{
$field
[
'default'
]
=
null
;
}
}
...
...
lib/Doctrine/Export/Pgsql.php
View file @
75dbc8c8
...
...
@@ -283,5 +283,68 @@ class Doctrine_Export_Pgsql extends Doctrine_Export
return
'DROP SEQUENCE '
.
$sequenceName
;
}
/**
* Creates a table.
*
* @param unknown_type $name
* @param array $fields
* @param array $options
* @return unknown
*/
public
function
createTableSql
(
$name
,
array
$fields
,
array
$options
=
array
())
{
if
(
!
$name
)
{
throw
new
Doctrine_Export_Exception
(
'no valid table name specified'
);
}
if
(
empty
(
$fields
))
{
throw
new
Doctrine_Export_Exception
(
'no fields specified for table '
.
$name
);
}
$queryFields
=
$this
->
getFieldDeclarationList
(
$fields
);
if
(
isset
(
$options
[
'primary'
])
&&
!
empty
(
$options
[
'primary'
]))
{
$queryFields
.=
', PRIMARY KEY('
.
implode
(
', '
,
array_values
(
$options
[
'primary'
]))
.
')'
;
}
$name
=
$this
->
conn
->
quoteIdentifier
(
$name
,
true
);
$query
=
'CREATE TABLE '
.
$name
.
' ('
.
$queryFields
.
')'
;
$sql
[]
=
$query
;
if
(
isset
(
$options
[
'indexes'
])
&&
!
empty
(
$options
[
'indexes'
]))
{
foreach
(
$options
[
'indexes'
]
as
$index
=>
$definition
)
{
$sql
[]
=
$this
->
createIndexSql
(
$name
,
$index
,
$definition
);
}
}
if
(
isset
(
$options
[
'foreignKeys'
]))
{
foreach
((
array
)
$options
[
'foreignKeys'
]
as
$k
=>
$definition
)
{
if
(
is_array
(
$definition
))
{
$sql
[]
=
$this
->
createForeignKeySql
(
$name
,
$definition
);
}
}
}
return
$sql
;
}
/**
* createForeignKeySql
*
* @param string $table name of the table on which the foreign key is to be created
* @param array $definition associative array that defines properties of the foreign key to be created.
* @return string
*/
public
function
createForeignKeySql
(
$table
,
array
$definition
)
{
$table
=
$this
->
conn
->
quoteIdentifier
(
$table
);
$query
=
'ALTER TABLE '
.
$table
.
' ADD '
.
$this
->
getForeignKeyDeclaration
(
$definition
);
return
$query
;
}
}
tests/Export/PgsqlTestCase.php
View file @
75dbc8c8
...
...
@@ -88,10 +88,10 @@ class Doctrine_Export_Pgsql_TestCase extends Doctrine_UnitTestCase
4
=>
'CREATE TABLE foo_bar_record (fooid BIGINT, barid BIGINT, PRIMARY KEY(fooid, barid))'
,
5
=>
'CREATE TABLE foo (id BIGSERIAL, name VARCHAR(200) NOT NULL, parent_id BIGINT, local_foo BIGINT, PRIMARY KEY(id))'
,
6
=>
'CREATE TABLE bar (id BIGSERIAL, name VARCHAR(200), PRIMARY KEY(id))'
,
7
=>
'ALTER TABLE foo_reference ADD
CONSTRAINT FOREIGN KEY (foo1) REFERENCES foo(foo1, foo2) NOT DEFERRABLE INITIALLY IMMEDIATE'
,
8
=>
'ALTER TABLE foo_bar_record ADD
CONSTRAINT FOREIGN KEY (fooId) REFERENCES foo(fooid, barid) NOT DEFERRABLE INITIALLY IMMEDIATE'
,
9
=>
'ALTER TABLE foo ADD
CONSTRAINT FOREIGN KEY (parent_id) REFERENCES foo(id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'
,
10
=>
'ALTER TABLE foo ADD
CONSTRAINT FOREIGN KEY (local_foo) REFERENCES foo_locally_owned(id) ON DELETE RESTRICT NOT DEFERRABLE INITIALLY IMMEDIATE'
,
7
=>
'ALTER TABLE foo_reference ADD
FOREIGN KEY (foo1) REFERENCES foo(id) NOT DEFERRABLE INITIALLY IMMEDIATE'
,
8
=>
'ALTER TABLE foo_bar_record ADD
FOREIGN KEY (fooId) REFERENCES foo(id) NOT DEFERRABLE INITIALLY IMMEDIATE'
,
9
=>
'ALTER TABLE foo ADD
FOREIGN KEY (parent_id) REFERENCES foo(id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'
,
10
=>
'ALTER TABLE foo ADD
FOREIGN KEY (local_foo) REFERENCES foo_locally_owned(id) ON DELETE RESTRICT NOT DEFERRABLE INITIALLY IMMEDIATE'
,
));
}
}
...
...
tests/NestedSet/SingleRootTestCase.php
View file @
75dbc8c8
...
...
@@ -50,6 +50,14 @@ class Doctrine_NestedSet_SingleRoot_TestCase extends Doctrine_UnitTestCase
$node2
->
getNode
()
->
insertAsLastChildOf
(
$node
);
}
public
function
testLftRgtValues
()
{
$treeMngr
=
$this
->
conn
->
getTable
(
'NestedSetTest_SingleRootNode'
)
->
getTree
();
$root
=
$treeMngr
->
fetchRoot
();
$this
->
assertEqual
(
1
,
$root
[
'lft'
]);
$this
->
assertEqual
(
4
,
$root
[
'rgt'
]);
}
public
function
testGetDescendants
()
{
$treeMngr
=
$this
->
conn
->
getTable
(
'NestedSetTest_SingleRootNode'
)
->
getTree
();
...
...
tests/run.php
View file @
75dbc8c8
...
...
@@ -336,7 +336,7 @@ $test->addTestCase(new Doctrine_Search_TestCase());
//$test->addTestCase(new Doctrine_AuditLog_TestCase());
//
$test->addTestCase(new Doctrine_NestedSet_SingleRoot_TestCase());
$test
->
addTestCase
(
new
Doctrine_NestedSet_SingleRoot_TestCase
());
// Cache tests
//$test->addTestCase(new Doctrine_Cache_Query_SqliteTestCase());
...
...
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