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
ea700de1
Commit
ea700de1
authored
Jun 13, 2010
by
beberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch DBAL-2 into master
parents
6c069bc6
b016a5e4
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
74 additions
and
118 deletions
+74
-118
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+2
-5
SqlitePlatform.php
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
+5
-0
AbstractSchemaManager.php
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
+1
-8
Column.php
lib/Doctrine/DBAL/Schema/Column.php
+17
-2
Comparator.php
lib/Doctrine/DBAL/Schema/Comparator.php
+5
-1
MySqlSchemaManager.php
lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
+1
-5
PostgreSqlSchemaManager.php
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
+4
-13
SqliteSchemaManager.php
lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
+1
-3
Table.php
lib/Doctrine/DBAL/Schema/Table.php
+1
-47
SchemaManagerFunctionalTestCase.php
...BAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
+21
-2
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+1
-2
ColumnTest.php
tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php
+1
-0
ComparatorTest.php
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
+13
-2
TableTest.php
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
+1
-27
SchemaSqlCollectorTest.php
...rine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php
+0
-1
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
ea700de1
...
@@ -700,7 +700,7 @@ abstract class AbstractPlatform
...
@@ -700,7 +700,7 @@ abstract class AbstractPlatform
$columnData
[
'type'
]
=
$column
->
getType
();
$columnData
[
'type'
]
=
$column
->
getType
();
$columnData
[
'length'
]
=
$column
->
getLength
();
$columnData
[
'length'
]
=
$column
->
getLength
();
$columnData
[
'notnull'
]
=
$column
->
getNotNull
();
$columnData
[
'notnull'
]
=
$column
->
getNotNull
();
$columnData
[
'unique'
]
=
(
$column
->
hasPlatformOption
(
"unique"
))
?
$column
->
getPlatformOption
(
'unique'
)
:
false
;
$columnData
[
'unique'
]
=
false
;
// TODO: what do we do about this?
$columnData
[
'version'
]
=
(
$column
->
hasPlatformOption
(
"version"
))
?
$column
->
getPlatformOption
(
'version'
)
:
false
;
$columnData
[
'version'
]
=
(
$column
->
hasPlatformOption
(
"version"
))
?
$column
->
getPlatformOption
(
'version'
)
:
false
;
if
(
strtolower
(
$columnData
[
'type'
])
==
"string"
&&
$columnData
[
'length'
]
===
null
)
{
if
(
strtolower
(
$columnData
[
'type'
])
==
"string"
&&
$columnData
[
'length'
]
===
null
)
{
$columnData
[
'length'
]
=
255
;
$columnData
[
'length'
]
=
255
;
...
@@ -709,13 +709,10 @@ abstract class AbstractPlatform
...
@@ -709,13 +709,10 @@ abstract class AbstractPlatform
$columnData
[
'scale'
]
=
$column
->
getScale
();
$columnData
[
'scale'
]
=
$column
->
getScale
();
$columnData
[
'default'
]
=
$column
->
getDefault
();
$columnData
[
'default'
]
=
$column
->
getDefault
();
$columnData
[
'columnDefinition'
]
=
$column
->
getColumnDefinition
();
$columnData
[
'columnDefinition'
]
=
$column
->
getColumnDefinition
();
$columnData
[
'autoincrement'
]
=
$column
->
getAutoincrement
();
if
(
in_array
(
$column
->
getName
(),
$options
[
'primary'
]))
{
if
(
in_array
(
$column
->
getName
(),
$options
[
'primary'
]))
{
$columnData
[
'primary'
]
=
true
;
$columnData
[
'primary'
]
=
true
;
if
(
$table
->
isIdGeneratorIdentity
())
{
$columnData
[
'autoincrement'
]
=
true
;
}
}
}
$columns
[
$columnData
[
'name'
]]
=
$columnData
;
$columns
[
$columnData
[
'name'
]]
=
$columnData
;
...
...
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
View file @
ea700de1
...
@@ -376,6 +376,11 @@ class SqlitePlatform extends AbstractPlatform
...
@@ -376,6 +376,11 @@ class SqlitePlatform extends AbstractPlatform
return
false
;
return
false
;
}
}
public
function
supportsIdentityColumns
()
{
return
true
;
}
/**
/**
* Get the platform name for this instance
* Get the platform name for this instance
*
*
...
...
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
View file @
ea700de1
...
@@ -215,14 +215,7 @@ abstract class AbstractSchemaManager
...
@@ -215,14 +215,7 @@ abstract class AbstractSchemaManager
}
}
$indexes
=
$this
->
listTableIndexes
(
$tableName
);
$indexes
=
$this
->
listTableIndexes
(
$tableName
);
$idGeneratorType
=
Table
::
ID_NONE
;
return
new
Table
(
$tableName
,
$columns
,
$indexes
,
$foreignKeys
,
false
,
array
());
foreach
(
$columns
AS
$column
)
{
if
(
$column
->
hasPlatformOption
(
'autoincrement'
)
&&
$column
->
getPlatformOption
(
'autoincrement'
))
{
$idGeneratorType
=
Table
::
ID_IDENTITY
;
}
}
return
new
Table
(
$tableName
,
$columns
,
$indexes
,
$foreignKeys
,
$idGeneratorType
,
array
());
}
}
/**
/**
...
...
lib/Doctrine/DBAL/Schema/Column.php
View file @
ea700de1
<?php
<?php
/*
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
@@ -75,6 +73,11 @@ class Column extends AbstractAsset
...
@@ -75,6 +73,11 @@ class Column extends AbstractAsset
*/
*/
protected
$_default
=
null
;
protected
$_default
=
null
;
/**
* @var bool
*/
protected
$_autoincrement
=
false
;
/**
/**
* @var array
* @var array
*/
*/
...
@@ -302,6 +305,17 @@ class Column extends AbstractAsset
...
@@ -302,6 +305,17 @@ class Column extends AbstractAsset
return
$this
->
_columnDefinition
;
return
$this
->
_columnDefinition
;
}
}
public
function
getAutoincrement
()
{
return
$this
->
_autoincrement
;
}
public
function
setAutoincrement
(
$flag
)
{
$this
->
_autoincrement
=
$flag
;
return
$this
;
}
/**
/**
* @param Visitor $visitor
* @param Visitor $visitor
*/
*/
...
@@ -325,6 +339,7 @@ class Column extends AbstractAsset
...
@@ -325,6 +339,7 @@ class Column extends AbstractAsset
'scale'
=>
$this
->
_scale
,
'scale'
=>
$this
->
_scale
,
'fixed'
=>
$this
->
_fixed
,
'fixed'
=>
$this
->
_fixed
,
'unsigned'
=>
$this
->
_unsigned
,
'unsigned'
=>
$this
->
_unsigned
,
'autoincrement'
=>
$this
->
_autoincrement
,
'columnDefinition'
=>
$this
->
_columnDefinition
,
'columnDefinition'
=>
$this
->
_columnDefinition
,
),
$this
->
_platformOptions
);
),
$this
->
_platformOptions
);
}
}
...
...
lib/Doctrine/DBAL/Schema/Comparator.php
View file @
ea700de1
...
@@ -325,6 +325,10 @@ class Comparator
...
@@ -325,6 +325,10 @@ class Comparator
}
}
}
}
if
(
$column1
->
getAutoincrement
()
!=
$column2
->
getAutoincrement
())
{
$changedProperties
[]
=
'autoincrement'
;
}
return
$changedProperties
;
return
$changedProperties
;
}
}
...
@@ -367,4 +371,4 @@ class Comparator
...
@@ -367,4 +371,4 @@ class Comparator
return
false
;
return
false
;
}
}
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
View file @
ea700de1
...
@@ -153,11 +153,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
...
@@ -153,11 +153,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
'notnull'
=>
(
bool
)
(
$tableColumn
[
'Null'
]
!=
'YES'
),
'notnull'
=>
(
bool
)
(
$tableColumn
[
'Null'
]
!=
'YES'
),
'scale'
=>
null
,
'scale'
=>
null
,
'precision'
=>
null
,
'precision'
=>
null
,
'platformOptions'
=>
array
(
'autoincrement'
=>
(
bool
)
(
strpos
(
$tableColumn
[
'Extra'
],
'auto_increment'
)
!==
false
),
'primary'
=>
(
strtolower
(
$tableColumn
[
'Key'
])
==
'pri'
)
?
true
:
false
,
'unique'
=>
(
strtolower
(
$tableColumn
[
'Key'
])
==
'uni'
)
?
true
:
false
,
'autoincrement'
=>
(
bool
)
(
strpos
(
$tableColumn
[
'Extra'
],
'auto_increment'
)
!==
false
),
),
);
);
if
(
$scale
!==
null
&&
$precision
!==
null
)
{
if
(
$scale
!==
null
&&
$precision
!==
null
)
{
...
...
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
View file @
ea700de1
...
@@ -168,10 +168,12 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
...
@@ -168,10 +168,12 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
}
}
$matches
=
array
();
$matches
=
array
();
$autoincrement
=
false
;
if
(
preg_match
(
"/^nextval\('(.*)'(::.*)?\)$/"
,
$tableColumn
[
'default'
],
$matches
))
{
if
(
preg_match
(
"/^nextval\('(.*)'(::.*)?\)$/"
,
$tableColumn
[
'default'
],
$matches
))
{
$tableColumn
[
'sequence'
]
=
$matches
[
1
];
$tableColumn
[
'sequence'
]
=
$matches
[
1
];
$tableColumn
[
'default'
]
=
null
;
$tableColumn
[
'default'
]
=
null
;
$autoincrement
=
true
;
}
}
if
(
stripos
(
$tableColumn
[
'default'
],
'NULL'
)
===
0
)
{
if
(
stripos
(
$tableColumn
[
'default'
],
'NULL'
)
===
0
)
{
...
@@ -198,25 +200,16 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
...
@@ -198,25 +200,16 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$dbType
=
strtolower
(
$tableColumn
[
'type'
]);
$dbType
=
strtolower
(
$tableColumn
[
'type'
]);
$type
=
$this
->
_platform
->
getDoctrineTypeMapping
(
$dbType
);
$type
=
$this
->
_platform
->
getDoctrineTypeMapping
(
$dbType
);
$autoincrement
=
false
;
switch
(
$dbType
)
{
switch
(
$dbType
)
{
case
'smallint'
:
case
'smallint'
:
case
'int2'
:
case
'int2'
:
$length
=
null
;
$length
=
null
;
break
;
break
;
case
'serial'
:
case
'serial4'
:
$autoincrement
=
true
;
// break missing intentionally
case
'int'
:
case
'int'
:
case
'int4'
:
case
'int4'
:
case
'integer'
:
case
'integer'
:
$length
=
null
;
$length
=
null
;
break
;
break
;
case
'bigserial'
:
case
'serial8'
:
$autoincrement
=
true
;
// break missing intentionally
case
'bigint'
:
case
'bigint'
:
case
'int8'
:
case
'int8'
:
$length
=
null
;
$length
=
null
;
...
@@ -266,9 +259,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
...
@@ -266,9 +259,7 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
'scale'
=>
$scale
,
'scale'
=>
$scale
,
'fixed'
=>
$fixed
,
'fixed'
=>
$fixed
,
'unsigned'
=>
false
,
'unsigned'
=>
false
,
'platformDetails'
=>
array
(
'autoincrement'
=>
$autoincrement
,
'autoincrement'
=>
$autoincrement
,
),
);
);
return
new
Column
(
$tableColumn
[
'field'
],
\Doctrine\DBAL\Types\Type
::
getType
(
$type
),
$options
);
return
new
Column
(
$tableColumn
[
'field'
],
\Doctrine\DBAL\Types\Type
::
getType
(
$type
),
$options
);
...
...
lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
View file @
ea700de1
...
@@ -168,9 +168,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
...
@@ -168,9 +168,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
'default'
=>
$default
,
'default'
=>
$default
,
'precision'
=>
$precision
,
'precision'
=>
$precision
,
'scale'
=>
$scale
,
'scale'
=>
$scale
,
'platformDetails'
=>
array
(
'autoincrement'
=>
(
bool
)
$tableColumn
[
'pk'
],
'autoincrement'
=>
(
bool
)
$tableColumn
[
'pk'
],
),
);
);
return
new
Column
(
$tableColumn
[
'name'
],
\Doctrine\DBAL\Types\Type
::
getType
(
$type
),
$options
);
return
new
Column
(
$tableColumn
[
'name'
],
\Doctrine\DBAL\Types\Type
::
getType
(
$type
),
$options
);
...
...
lib/Doctrine/DBAL/Schema/Table.php
View file @
ea700de1
...
@@ -36,21 +36,6 @@ use Doctrine\DBAL\DBALException;
...
@@ -36,21 +36,6 @@ use Doctrine\DBAL\DBALException;
*/
*/
class
Table
extends
AbstractAsset
class
Table
extends
AbstractAsset
{
{
/**
* @var int
*/
const
ID_NONE
=
0
;
/**
* @var int
*/
const
ID_SEQUENCE
=
1
;
/**
* @var int
*/
const
ID_IDENTITY
=
2
;
/**
/**
* @var string
* @var string
*/
*/
...
@@ -81,11 +66,6 @@ class Table extends AbstractAsset
...
@@ -81,11 +66,6 @@ class Table extends AbstractAsset
*/
*/
protected
$_options
=
array
();
protected
$_options
=
array
();
/**
* @var bool
*/
protected
$_idGeneratorType
=
self
::
ID_NONE
;
/**
/**
* @var SchemaConfig
* @var SchemaConfig
*/
*/
...
@@ -100,7 +80,7 @@ class Table extends AbstractAsset
...
@@ -100,7 +80,7 @@ class Table extends AbstractAsset
* @param int $idGeneratorType
* @param int $idGeneratorType
* @param array $options
* @param array $options
*/
*/
public
function
__construct
(
$tableName
,
array
$columns
=
array
(),
array
$indexes
=
array
(),
array
$fkConstraints
=
array
(),
$idGeneratorType
=
self
::
ID_NONE
,
array
$options
=
array
())
public
function
__construct
(
$tableName
,
array
$columns
=
array
(),
array
$indexes
=
array
(),
array
$fkConstraints
=
array
(),
$idGeneratorType
=
0
,
array
$options
=
array
())
{
{
if
(
strlen
(
$tableName
)
==
0
)
{
if
(
strlen
(
$tableName
)
==
0
)
{
throw
DBALException
::
invalidTableName
(
$tableName
);
throw
DBALException
::
invalidTableName
(
$tableName
);
...
@@ -163,16 +143,6 @@ class Table extends AbstractAsset
...
@@ -163,16 +143,6 @@ class Table extends AbstractAsset
return
$primaryKey
;
return
$primaryKey
;
}
}
/**
* @param string $type
* @return Table
*/
public
function
setIdGeneratorType
(
$type
)
{
$this
->
_idGeneratorType
=
$type
;
return
$this
;
}
/**
/**
* @param array $columnNames
* @param array $columnNames
* @param string $indexName
* @param string $indexName
...
@@ -489,22 +459,6 @@ class Table extends AbstractAsset
...
@@ -489,22 +459,6 @@ class Table extends AbstractAsset
return
$this
->
_fkConstraints
[
$constraintName
];
return
$this
->
_fkConstraints
[
$constraintName
];
}
}
/**
* @return bool
*/
public
function
isIdGeneratorIdentity
()
{
return
(
$this
->
_idGeneratorType
==
self
::
ID_IDENTITY
);
}
/**
* @return array
*/
public
function
isIdGeneratorSequence
()
{
return
(
$this
->
_idGeneratorType
==
self
::
ID_SEQUENCE
);
}
/**
/**
* @return Column[]
* @return Column[]
*/
*/
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
View file @
ea700de1
...
@@ -359,6 +359,26 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
...
@@ -359,6 +359,26 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$views
=
$this
->
_sm
->
listViews
();
$views
=
$this
->
_sm
->
listViews
();
}
}
public
function
testAutoincrementDetection
()
{
if
(
!
$this
->
_sm
->
getDatabasePlatform
()
->
supportsIdentityColumns
())
{
$this
->
markTestSkipped
(
'This test is only supported on platforms that have autoincrement'
);
}
$table
=
new
\Doctrine\DBAL\Schema\Table
(
'test_autoincrement'
);
$table
->
setSchemaConfig
(
$this
->
_sm
->
createSchemaConfig
());
$table
->
addColumn
(
'id'
,
'integer'
,
array
(
'autoincrement'
=>
true
));
$table
->
setPrimaryKey
(
array
(
'id'
));
$this
->
_sm
->
createTable
(
$table
);
$inferredTable
=
$this
->
_sm
->
listTableDetails
(
'test_autoincrement'
);
$this
->
assertTrue
(
$inferredTable
->
hasColumn
(
'id'
));
$this
->
assertTrue
(
$inferredTable
->
getColumn
(
'id'
)
->
getAutoincrement
());
}
protected
function
createTestTable
(
$name
=
'test_table'
,
$data
=
array
())
protected
function
createTestTable
(
$name
=
'test_table'
,
$data
=
array
())
{
{
$options
=
array
();
$options
=
array
();
...
@@ -373,9 +393,8 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
...
@@ -373,9 +393,8 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
protected
function
getTestTable
(
$name
,
$options
=
array
())
protected
function
getTestTable
(
$name
,
$options
=
array
())
{
{
$table
=
new
\Doctrine\DBAL\Schema\Table
(
$name
,
array
(),
array
(),
array
(),
\Doctrine\DBAL\Schema\Table
::
ID_NONE
,
$options
);
$table
=
new
\Doctrine\DBAL\Schema\Table
(
$name
,
array
(),
array
(),
array
(),
false
,
$options
);
$table
->
setSchemaConfig
(
$this
->
_sm
->
createSchemaConfig
());
$table
->
setSchemaConfig
(
$this
->
_sm
->
createSchemaConfig
());
$table
->
setIdGeneratorType
(
\Doctrine\DBAL\Schema\Table
::
ID_IDENTITY
);
$table
->
addColumn
(
'id'
,
'integer'
,
array
(
'notnull'
=>
true
));
$table
->
addColumn
(
'id'
,
'integer'
,
array
(
'notnull'
=>
true
));
$table
->
setPrimaryKey
(
array
(
'id'
));
$table
->
setPrimaryKey
(
array
(
'id'
));
$table
->
addColumn
(
'test'
,
'string'
,
array
(
'length'
=>
255
));
$table
->
addColumn
(
'test'
,
'string'
,
array
(
'length'
=>
255
));
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
ea700de1
...
@@ -45,10 +45,9 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
...
@@ -45,10 +45,9 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
public
function
testGeneratesTableCreationSql
()
public
function
testGeneratesTableCreationSql
()
{
{
$table
=
new
\Doctrine\DBAL\Schema\Table
(
'test'
);
$table
=
new
\Doctrine\DBAL\Schema\Table
(
'test'
);
$table
->
addColumn
(
'id'
,
'integer'
,
array
(
'notnull'
=>
true
));
$table
->
addColumn
(
'id'
,
'integer'
,
array
(
'notnull'
=>
true
,
'autoincrement'
=>
true
));
$table
->
addColumn
(
'test'
,
'string'
,
array
(
'notnull'
=>
false
,
'length'
=>
255
));
$table
->
addColumn
(
'test'
,
'string'
,
array
(
'notnull'
=>
false
,
'length'
=>
255
));
$table
->
setPrimaryKey
(
array
(
'id'
));
$table
->
setPrimaryKey
(
array
(
'id'
));
$table
->
setIdGeneratorType
(
\Doctrine\DBAL\Schema\Table
::
ID_IDENTITY
);
$sql
=
$this
->
_platform
->
getCreateTableSQL
(
$table
);
$sql
=
$this
->
_platform
->
getCreateTableSQL
(
$table
);
$this
->
assertEquals
(
$this
->
getGenerateTableSql
(),
$sql
[
0
]);
$this
->
assertEquals
(
$this
->
getGenerateTableSql
(),
$sql
[
0
]);
...
...
tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php
View file @
ea700de1
...
@@ -44,6 +44,7 @@ class ColumnTest extends \PHPUnit_Framework_TestCase
...
@@ -44,6 +44,7 @@ class ColumnTest extends \PHPUnit_Framework_TestCase
'scale'
=>
2
,
'scale'
=>
2
,
'fixed'
=>
true
,
'fixed'
=>
true
,
'unsigned'
=>
true
,
'unsigned'
=>
true
,
'autoincrement'
=>
false
,
'columnDefinition'
=>
null
,
'columnDefinition'
=>
null
,
'foo'
=>
'bar'
,
'foo'
=>
'bar'
,
);
);
...
...
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
View file @
ea700de1
...
@@ -111,6 +111,17 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
...
@@ -111,6 +111,17 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
$expected
,
Comparator
::
compareSchemas
(
$schema1
,
$schema2
)
);
$this
->
assertEquals
(
$expected
,
Comparator
::
compareSchemas
(
$schema1
,
$schema2
)
);
}
}
public
function
testCompareOnlyAutoincrementChanged
()
{
$column1
=
new
Column
(
'foo'
,
Type
::
getType
(
'integer'
),
array
(
'autoincrement'
=>
true
));
$column2
=
new
Column
(
'foo'
,
Type
::
getType
(
'integer'
),
array
(
'autoincrement'
=>
false
));
$comparator
=
new
Comparator
();
$changedProperties
=
$comparator
->
diffColumn
(
$column1
,
$column2
);
$this
->
assertEquals
(
array
(
'autoincrement'
),
$changedProperties
);
}
public
function
testCompareMissingField
()
public
function
testCompareMissingField
()
{
{
$missingColumn
=
new
Column
(
'integerfield1'
,
Type
::
getType
(
'integer'
));
$missingColumn
=
new
Column
(
'integerfield1'
,
Type
::
getType
(
'integer'
));
...
@@ -575,10 +586,10 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
...
@@ -575,10 +586,10 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$this
->
markTestSkipped
(
'DBAL-2 was reopened, this test cannot work anymore.'
);
$this
->
markTestSkipped
(
'DBAL-2 was reopened, this test cannot work anymore.'
);
$tableA
=
new
Table
(
"foo"
);
$tableA
=
new
Table
(
"foo"
);
$tableA
->
addColumn
(
'id'
,
'integer'
,
array
(
'
platformOptions'
=>
array
(
'autoincrement'
=>
false
)
));
$tableA
->
addColumn
(
'id'
,
'integer'
,
array
(
'
autoincrement'
=>
false
));
$tableB
=
new
Table
(
"foo"
);
$tableB
=
new
Table
(
"foo"
);
$tableB
->
addColumn
(
'id'
,
'integer'
,
array
(
'
platformOptions'
=>
array
(
'autoincrement'
=>
true
)
));
$tableB
->
addColumn
(
'id'
,
'integer'
,
array
(
'
autoincrement'
=>
true
));
$c
=
new
Comparator
();
$c
=
new
Comparator
();
$tableDiff
=
$c
->
diffTable
(
$tableA
,
$tableB
);
$tableDiff
=
$c
->
diffTable
(
$tableA
,
$tableB
);
...
...
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
View file @
ea700de1
...
@@ -185,21 +185,6 @@ class TableTest extends \PHPUnit_Framework_TestCase
...
@@ -185,21 +185,6 @@ class TableTest extends \PHPUnit_Framework_TestCase
$table
=
new
Table
(
"foo"
,
$columns
,
$indexes
,
array
());
$table
=
new
Table
(
"foo"
,
$columns
,
$indexes
,
array
());
}
}
public
function
testIdGenerator
()
{
$tableA
=
new
Table
(
"foo"
,
array
(),
array
(),
array
(),
Table
::
ID_NONE
);
$this
->
assertFalse
(
$tableA
->
isIdGeneratorIdentity
());
$this
->
assertFalse
(
$tableA
->
isIdGeneratorSequence
());;
$tableB
=
new
Table
(
"foo"
,
array
(),
array
(),
array
(),
Table
::
ID_IDENTITY
);
$this
->
assertTrue
(
$tableB
->
isIdGeneratorIdentity
());
$this
->
assertFalse
(
$tableB
->
isIdGeneratorSequence
());;
$tableC
=
new
Table
(
"foo"
,
array
(),
array
(),
array
(),
Table
::
ID_SEQUENCE
);
$this
->
assertFalse
(
$tableC
->
isIdGeneratorIdentity
());
$this
->
assertTrue
(
$tableC
->
isIdGeneratorSequence
());;
}
public
function
testConstraints
()
public
function
testConstraints
()
{
{
$constraint
=
new
ForeignKeyConstraint
(
array
(),
"foo"
,
array
());
$constraint
=
new
ForeignKeyConstraint
(
array
(),
"foo"
,
array
());
...
@@ -213,7 +198,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
...
@@ -213,7 +198,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
public
function
testOptions
()
public
function
testOptions
()
{
{
$table
=
new
Table
(
"foo"
,
array
(),
array
(),
array
(),
Table
::
ID_NONE
,
array
(
"foo"
=>
"bar"
));
$table
=
new
Table
(
"foo"
,
array
(),
array
(),
array
(),
false
,
array
(
"foo"
=>
"bar"
));
$this
->
assertTrue
(
$table
->
hasOption
(
"foo"
));
$this
->
assertTrue
(
$table
->
hasOption
(
"foo"
));
$this
->
assertEquals
(
"bar"
,
$table
->
getOption
(
"foo"
));
$this
->
assertEquals
(
"bar"
,
$table
->
getOption
(
"foo"
));
...
@@ -281,17 +266,6 @@ class TableTest extends \PHPUnit_Framework_TestCase
...
@@ -281,17 +266,6 @@ class TableTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
"bar"
,
$table
->
getOption
(
"foo"
));
$this
->
assertEquals
(
"bar"
,
$table
->
getOption
(
"foo"
));
}
}
public
function
testIdGeneratorType
()
{
$table
=
new
Table
(
"foo"
);
$table
->
setIdGeneratorType
(
Table
::
ID_IDENTITY
);
$this
->
assertTrue
(
$table
->
isIdGeneratorIdentity
());
$table
->
setIdGeneratorType
(
Table
::
ID_SEQUENCE
);
$this
->
assertTrue
(
$table
->
isIdGeneratorSequence
());
}
public
function
testAddForeignKeyConstraint_UnknownLocalColumn_ThrowsException
()
public
function
testAddForeignKeyConstraint_UnknownLocalColumn_ThrowsException
()
{
{
$this
->
setExpectedException
(
"Doctrine\DBAL\Schema\SchemaException"
);
$this
->
setExpectedException
(
"Doctrine\DBAL\Schema\SchemaException"
);
...
...
tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php
View file @
ea700de1
...
@@ -66,7 +66,6 @@ class SchemaSqlCollectorTest extends \PHPUnit_Framework_TestCase
...
@@ -66,7 +66,6 @@ class SchemaSqlCollectorTest extends \PHPUnit_Framework_TestCase
$tableA
->
addColumn
(
"id"
,
'integer'
);
$tableA
->
addColumn
(
"id"
,
'integer'
);
$tableA
->
addColumn
(
"bar"
,
'string'
,
array
(
'length'
=>
255
));
$tableA
->
addColumn
(
"bar"
,
'string'
,
array
(
'length'
=>
255
));
$tableA
->
setPrimaryKey
(
array
(
"id"
));
$tableA
->
setPrimaryKey
(
array
(
"id"
));
$tableA
->
setIdGeneratorType
(
Table
::
ID_SEQUENCE
);
$schema
->
createSequence
(
"foo_seq"
);
$schema
->
createSequence
(
"foo_seq"
);
...
...
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