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
168fc6b1
Commit
168fc6b1
authored
Feb 20, 2011
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'DBAL-42'
parents
c330d97c
18bed8f2
Changes
38
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
462 additions
and
97 deletions
+462
-97
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+116
-3
DB2Platform.php
lib/Doctrine/DBAL/Platforms/DB2Platform.php
+1
-1
MsSqlPlatform.php
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
+1
-1
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+23
-5
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+17
-5
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+19
-6
SqlitePlatform.php
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
+1
-1
AbstractSchemaManager.php
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
+28
-2
Column.php
lib/Doctrine/DBAL/Schema/Column.php
+17
-0
Comparator.php
lib/Doctrine/DBAL/Schema/Comparator.php
+5
-0
MySqlSchemaManager.php
lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
+4
-0
OracleSchemaManager.php
lib/Doctrine/DBAL/Schema/OracleSchemaManager.php
+4
-0
PostgreSqlSchemaManager.php
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
+12
-9
ConnectionTest.php
tests/Doctrine/Tests/DBAL/ConnectionTest.php
+3
-3
DriverManagerTest.php
tests/Doctrine/Tests/DBAL/DriverManagerTest.php
+2
-2
ConnectionTest.php
tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php
+1
-1
DataAccessTest.php
tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
+6
-6
PostgreSqlSchemaManagerTest.php
...ts/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php
+3
-3
SchemaManagerFunctionalTestCase.php
...BAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
+67
-19
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+39
-0
MsSqlPlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/MsSqlPlatformTest.php
+1
-0
MySqlPlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
+10
-0
OraclePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+18
-0
PostgreSqlPlatformTest.php
.../Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
+17
-0
ColumnTest.php
tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php
+17
-0
ComparatorTest.php
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
+4
-4
SchemaTest.php
tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php
+3
-3
TableTest.php
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
+6
-6
BooleanTest.php
tests/Doctrine/Tests/DBAL/Types/BooleanTest.php
+2
-2
DateTimeTest.php
tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php
+1
-1
DateTimeTzTest.php
tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php
+1
-1
DecimalTest.php
tests/Doctrine/Tests/DBAL/Types/DecimalTest.php
+1
-1
FloatTest.php
tests/Doctrine/Tests/DBAL/Types/FloatTest.php
+2
-2
IntegerTest.php
tests/Doctrine/Tests/DBAL/Types/IntegerTest.php
+2
-2
ObjectTest.php
tests/Doctrine/Tests/DBAL/Types/ObjectTest.php
+2
-2
SmallIntTest.php
tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php
+2
-2
StringTest.php
tests/Doctrine/Tests/DBAL/Types/StringTest.php
+2
-2
VarDateTimeTest.php
tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php
+2
-2
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
168fc6b1
...
@@ -25,7 +25,9 @@ use Doctrine\DBAL\DBALException,
...
@@ -25,7 +25,9 @@ use Doctrine\DBAL\DBALException,
Doctrine\DBAL\Schema\Table
,
Doctrine\DBAL\Schema\Table
,
Doctrine\DBAL\Schema\Index
,
Doctrine\DBAL\Schema\Index
,
Doctrine\DBAL\Schema\ForeignKeyConstraint
,
Doctrine\DBAL\Schema\ForeignKeyConstraint
,
Doctrine\DBAL\Schema\TableDiff
;
Doctrine\DBAL\Schema\TableDiff
,
Doctrine\DBAL\Schema\Column
,
Doctrine\DBAL\Types\Type
;
/**
/**
* Base class for all DatabasePlatforms. The DatabasePlatforms are the central
* Base class for all DatabasePlatforms. The DatabasePlatforms are the central
...
@@ -80,6 +82,14 @@ abstract class AbstractPlatform
...
@@ -80,6 +82,14 @@ abstract class AbstractPlatform
*/
*/
protected
$doctrineTypeMapping
=
null
;
protected
$doctrineTypeMapping
=
null
;
/**
* Contains a list of all columns that should generate parseable column comments for type-detection
* in reverse engineering scenarios.
*
* @var array
*/
protected
$doctrineTypeComments
=
null
;
/**
/**
* Constructor.
* Constructor.
*/
*/
...
@@ -209,6 +219,71 @@ abstract class AbstractPlatform
...
@@ -209,6 +219,71 @@ abstract class AbstractPlatform
return
isset
(
$this
->
doctrineTypeMapping
[
$dbType
]);
return
isset
(
$this
->
doctrineTypeMapping
[
$dbType
]);
}
}
/**
* Initialize the Doctrine Type comments instance variable for in_array() checks.
*
* @return void
*/
protected
function
initializeCommentedDoctrineTypes
()
{
$this
->
doctrineTypeComments
=
array
(
Type
::
TARRAY
,
Type
::
OBJECT
);
}
/**
* Is it necessary for the platform to add a parsable type comment to allow reverse engineering the given type?
*
* @param Type $doctrineType
* @return bool
*/
public
function
isCommentedDoctrineType
(
Type
$doctrineType
)
{
if
(
$this
->
doctrineTypeComments
===
null
)
{
$this
->
initializeCommentedDoctrineTypes
();
}
return
in_array
(
$doctrineType
->
getName
(),
$this
->
doctrineTypeComments
);
}
/**
* Mark this type as to be commented in ALTER TABLE and CREATE TABLE statements.
*
* @param Type $doctrineType
* @return void
*/
public
function
markDoctrineTypeCommented
(
Type
$doctrineType
)
{
if
(
$this
->
doctrineTypeComments
===
null
)
{
$this
->
initializeCommentedDoctrineTypes
();
}
$this
->
doctrineTypeComments
[]
=
$doctrineType
->
getName
();
}
/**
* Get the comment to append to a column comment that helps parsing this type in reverse engineering.
*
* @param Type $doctrineType
* @return string
*/
public
function
getDoctrineTypeComment
(
Type
$doctrineType
)
{
return
'(DC2Type:'
.
$doctrineType
->
getName
()
.
')'
;
}
/**
* Return the comment of a passed column modified by potential doctrine type comment hints.
*
* @param Column $column
* @return string
*/
protected
function
getColumnComment
(
Column
$column
)
{
$comment
=
$column
->
getComment
();
if
(
$this
->
isCommentedDoctrineType
(
$column
->
getType
()))
{
$comment
.=
$this
->
getDoctrineTypeComment
(
$column
->
getType
());
}
return
$comment
;
}
/**
/**
* Gets the character used for identifier quoting.
* Gets the character used for identifier quoting.
*
*
...
@@ -797,6 +872,7 @@ abstract class AbstractPlatform
...
@@ -797,6 +872,7 @@ abstract class AbstractPlatform
$columnData
[
'default'
]
=
$column
->
getDefault
();
$columnData
[
'default'
]
=
$column
->
getDefault
();
$columnData
[
'columnDefinition'
]
=
$column
->
getColumnDefinition
();
$columnData
[
'columnDefinition'
]
=
$column
->
getColumnDefinition
();
$columnData
[
'autoincrement'
]
=
$column
->
getAutoincrement
();
$columnData
[
'autoincrement'
]
=
$column
->
getAutoincrement
();
$columnData
[
'comment'
]
=
$this
->
getColumnComment
(
$column
);
if
(
in_array
(
$column
->
getName
(),
$options
[
'primary'
]))
{
if
(
in_array
(
$column
->
getName
(),
$options
[
'primary'
]))
{
$columnData
[
'primary'
]
=
true
;
$columnData
[
'primary'
]
=
true
;
...
@@ -812,7 +888,20 @@ abstract class AbstractPlatform
...
@@ -812,7 +888,20 @@ abstract class AbstractPlatform
}
}
}
}
return
$this
->
_getCreateTableSQL
(
$tableName
,
$columns
,
$options
);
$sql
=
$this
->
_getCreateTableSQL
(
$tableName
,
$columns
,
$options
);
if
(
$this
->
supportsCommentOnStatement
())
{
foreach
(
$table
->
getColumns
()
AS
$column
)
{
if
(
$column
->
getComment
())
{
$sql
[]
=
$this
->
getCommentOnColumnSQL
(
$tableName
,
$column
->
getName
(),
$this
->
getColumnComment
(
$column
));
}
}
}
return
$sql
;
}
public
function
getCommentOnColumnSQL
(
$tableName
,
$columnName
,
$comment
)
{
return
"COMMENT ON COLUMN "
.
$tableName
.
"."
.
$columnName
.
" IS '"
.
$comment
.
"'"
;
}
}
/**
/**
...
@@ -1142,6 +1231,10 @@ abstract class AbstractPlatform
...
@@ -1142,6 +1231,10 @@ abstract class AbstractPlatform
$columnDef
=
$typeDecl
.
$charset
.
$default
.
$notnull
.
$unique
.
$check
.
$collation
;
$columnDef
=
$typeDecl
.
$charset
.
$default
.
$notnull
.
$unique
.
$check
.
$collation
;
}
}
if
(
$this
->
supportsInlineColumnComments
()
&&
isset
(
$field
[
'comment'
])
&&
$field
[
'comment'
])
{
$columnDef
.=
" COMMENT '"
.
$field
[
'comment'
]
.
"'"
;
}
return
$name
.
' '
.
$columnDef
;
return
$name
.
' '
.
$columnDef
;
}
}
...
@@ -1616,7 +1709,7 @@ abstract class AbstractPlatform
...
@@ -1616,7 +1709,7 @@ abstract class AbstractPlatform
throw
DBALException
::
notSupported
(
__METHOD__
);
throw
DBALException
::
notSupported
(
__METHOD__
);
}
}
public
function
getListTableColumnsSQL
(
$table
)
public
function
getListTableColumnsSQL
(
$table
,
$database
=
null
)
{
{
throw
DBALException
::
notSupported
(
__METHOD__
);
throw
DBALException
::
notSupported
(
__METHOD__
);
}
}
...
@@ -1880,6 +1973,26 @@ abstract class AbstractPlatform
...
@@ -1880,6 +1973,26 @@ abstract class AbstractPlatform
return
true
;
return
true
;
}
}
/**
* Does this plaform support to add inline column comments as postfix.
*
* @return bool
*/
public
function
supportsInlineColumnComments
()
{
return
false
;
}
/**
* Does this platform support the propriortary synatx "COMMENT ON asset"
*
* @return bool
*/
public
function
supportsCommentOnStatement
()
{
return
false
;
}
public
function
getIdentityColumnNullInsertSQL
()
public
function
getIdentityColumnNullInsertSQL
()
{
{
return
""
;
return
""
;
...
...
lib/Doctrine/DBAL/Platforms/DB2Platform.php
View file @
168fc6b1
...
@@ -208,7 +208,7 @@ class DB2Platform extends AbstractPlatform
...
@@ -208,7 +208,7 @@ class DB2Platform extends AbstractPlatform
* @param string $table
* @param string $table
* @return string
* @return string
*/
*/
public
function
getListTableColumnsSQL
(
$table
)
public
function
getListTableColumnsSQL
(
$table
,
$database
=
null
)
{
{
return
"SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno,
return
"SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno,
c.typename, c.default, c.nulls, c.length, c.scale,
c.typename, c.default, c.nulls, c.length, c.scale,
...
...
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
View file @
168fc6b1
...
@@ -311,7 +311,7 @@ class MsSqlPlatform extends AbstractPlatform
...
@@ -311,7 +311,7 @@ class MsSqlPlatform extends AbstractPlatform
/**
/**
* @override
* @override
*/
*/
public
function
getListTableColumnsSQL
(
$table
)
public
function
getListTableColumnsSQL
(
$table
,
$database
=
null
)
{
{
return
'exec sp_columns @table_name = '
.
$table
;
return
'exec sp_columns @table_name = '
.
$table
;
}
}
...
...
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
168fc6b1
...
@@ -259,6 +259,11 @@ class MySqlPlatform extends AbstractPlatform
...
@@ -259,6 +259,11 @@ class MySqlPlatform extends AbstractPlatform
return
true
;
return
true
;
}
}
public
function
supportsInlineColumnComments
()
{
return
true
;
}
public
function
getShowDatabasesSQL
()
public
function
getShowDatabasesSQL
()
{
{
return
'SHOW DATABASES'
;
return
'SHOW DATABASES'
;
...
@@ -269,9 +274,16 @@ class MySqlPlatform extends AbstractPlatform
...
@@ -269,9 +274,16 @@ class MySqlPlatform extends AbstractPlatform
return
"SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'"
;
return
"SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'"
;
}
}
public
function
getListTableColumnsSQL
(
$table
)
public
function
getListTableColumnsSQL
(
$table
,
$database
=
null
)
{
{
return
'DESCRIBE '
.
$table
;
if
(
$database
)
{
return
"SELECT COLUMN_NAME AS Field, COLUMN_TYPE AS Type, IS_NULLABLE AS `Null`, "
.
"COLUMN_KEY AS `Key`, COLUMN_DEFAULT AS `Default`, EXTRA AS Extra, COLUMN_COMMENT AS Comment, "
.
"CHARACTER_SET_NAME AS CharacterSet, COLLATION_NAME AS CollactionName "
.
"FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = '"
.
$database
.
"' AND TABLE_NAME = '"
.
$table
.
"'"
;
}
else
{
return
'DESCRIBE '
.
$table
;
}
}
}
/**
/**
...
@@ -410,7 +422,9 @@ class MySqlPlatform extends AbstractPlatform
...
@@ -410,7 +422,9 @@ class MySqlPlatform extends AbstractPlatform
}
}
foreach
(
$diff
->
addedColumns
AS
$fieldName
=>
$column
)
{
foreach
(
$diff
->
addedColumns
AS
$fieldName
=>
$column
)
{
$queryParts
[]
=
'ADD '
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$column
->
toArray
());
$columnArray
=
$column
->
toArray
();
$columnArray
[
'comment'
]
=
$this
->
getColumnComment
(
$column
);
$queryParts
[]
=
'ADD '
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$columnArray
);
}
}
foreach
(
$diff
->
removedColumns
AS
$column
)
{
foreach
(
$diff
->
removedColumns
AS
$column
)
{
...
@@ -420,13 +434,17 @@ class MySqlPlatform extends AbstractPlatform
...
@@ -420,13 +434,17 @@ class MySqlPlatform extends AbstractPlatform
foreach
(
$diff
->
changedColumns
AS
$columnDiff
)
{
foreach
(
$diff
->
changedColumns
AS
$columnDiff
)
{
/* @var $columnDiff Doctrine\DBAL\Schema\ColumnDiff */
/* @var $columnDiff Doctrine\DBAL\Schema\ColumnDiff */
$column
=
$columnDiff
->
column
;
$column
=
$columnDiff
->
column
;
$columnArray
=
$column
->
toArray
();
$columnArray
[
'comment'
]
=
$this
->
getColumnComment
(
$column
);
$queryParts
[]
=
'CHANGE '
.
(
$columnDiff
->
oldColumnName
)
.
' '
$queryParts
[]
=
'CHANGE '
.
(
$columnDiff
->
oldColumnName
)
.
' '
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$column
->
toArray
()
);
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$column
Array
);
}
}
foreach
(
$diff
->
renamedColumns
AS
$oldColumnName
=>
$column
)
{
foreach
(
$diff
->
renamedColumns
AS
$oldColumnName
=>
$column
)
{
$columnArray
=
$column
->
toArray
();
$columnArray
[
'comment'
]
=
$this
->
getColumnComment
(
$column
);
$queryParts
[]
=
'CHANGE '
.
$oldColumnName
.
' '
$queryParts
[]
=
'CHANGE '
.
$oldColumnName
.
' '
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$column
->
toArray
()
);
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$column
Array
);
}
}
$sql
=
array
();
$sql
=
array
();
...
...
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
168fc6b1
...
@@ -441,10 +441,12 @@ LEFT JOIN all_cons_columns r_cols
...
@@ -441,10 +441,12 @@ LEFT JOIN all_cons_columns r_cols
return
'SELECT * FROM user_constraints WHERE table_name = \''
.
$table
.
'\''
;
return
'SELECT * FROM user_constraints WHERE table_name = \''
.
$table
.
'\''
;
}
}
public
function
getListTableColumnsSQL
(
$table
)
public
function
getListTableColumnsSQL
(
$table
,
$database
=
null
)
{
{
$table
=
strtoupper
(
$table
);
$table
=
strtoupper
(
$table
);
return
"SELECT * FROM all_tab_columns WHERE table_name = '"
.
$table
.
"' ORDER BY column_name"
;
return
"SELECT c.*, d.comments FROM all_tab_columns c "
.
"INNER JOIN all_col_comments d ON d.OWNER = c.OWNER AND d.TABLE_NAME = c.TABLE_NAME AND d.COLUMN_NAME = c.COLUMN_NAME "
.
"WHERE c.table_name = '"
.
$table
.
"' ORDER BY c.column_name"
;
}
}
/**
/**
...
@@ -499,10 +501,14 @@ LEFT JOIN all_cons_columns r_cols
...
@@ -499,10 +501,14 @@ LEFT JOIN all_cons_columns r_cols
public
function
getAlterTableSQL
(
TableDiff
$diff
)
public
function
getAlterTableSQL
(
TableDiff
$diff
)
{
{
$sql
=
array
();
$sql
=
array
();
$commentsSQL
=
array
();
$fields
=
array
();
$fields
=
array
();
foreach
(
$diff
->
addedColumns
AS
$column
)
{
foreach
(
$diff
->
addedColumns
AS
$column
)
{
$fields
[]
=
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$column
->
toArray
());
$fields
[]
=
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$column
->
toArray
());
if
(
$comment
=
$this
->
getColumnComment
(
$column
))
{
$commentsSQL
[]
=
$this
->
getCommentOnColumnSQL
(
$diff
->
name
,
$column
->
getName
(),
$comment
);
}
}
}
if
(
count
(
$fields
))
{
if
(
count
(
$fields
))
{
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' ADD ('
.
implode
(
', '
,
$fields
)
.
')'
;
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' ADD ('
.
implode
(
', '
,
$fields
)
.
')'
;
...
@@ -512,6 +518,9 @@ LEFT JOIN all_cons_columns r_cols
...
@@ -512,6 +518,9 @@ LEFT JOIN all_cons_columns r_cols
foreach
(
$diff
->
changedColumns
AS
$columnDiff
)
{
foreach
(
$diff
->
changedColumns
AS
$columnDiff
)
{
$column
=
$columnDiff
->
column
;
$column
=
$columnDiff
->
column
;
$fields
[]
=
$column
->
getQuotedName
(
$this
)
.
' '
.
$this
->
getColumnDeclarationSQL
(
''
,
$column
->
toArray
());
$fields
[]
=
$column
->
getQuotedName
(
$this
)
.
' '
.
$this
->
getColumnDeclarationSQL
(
''
,
$column
->
toArray
());
if
(
$columnDiff
->
hasChanged
(
'comment'
)
&&
$comment
=
$this
->
getColumnComment
(
$column
))
{
$commentsSQL
[]
=
$this
->
getCommentOnColumnSQL
(
$diff
->
name
,
$column
->
getName
(),
$comment
);
}
}
}
if
(
count
(
$fields
))
{
if
(
count
(
$fields
))
{
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' MODIFY ('
.
implode
(
', '
,
$fields
)
.
')'
;
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' MODIFY ('
.
implode
(
', '
,
$fields
)
.
')'
;
...
@@ -533,9 +542,7 @@ LEFT JOIN all_cons_columns r_cols
...
@@ -533,9 +542,7 @@ LEFT JOIN all_cons_columns r_cols
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' RENAME TO '
.
$diff
->
newName
;
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' RENAME TO '
.
$diff
->
newName
;
}
}
$sql
=
array_merge
(
$sql
,
$this
->
_getAlterTableIndexForeignKeySQL
(
$diff
));
return
array_merge
(
$sql
,
$this
->
_getAlterTableIndexForeignKeySQL
(
$diff
),
$commentsSQL
);
return
$sql
;
}
}
/**
/**
...
@@ -548,6 +555,11 @@ LEFT JOIN all_cons_columns r_cols
...
@@ -548,6 +555,11 @@ LEFT JOIN all_cons_columns r_cols
return
true
;
return
true
;
}
}
public
function
supportsCommentOnStatement
()
{
return
true
;
}
/**
/**
* Get the platform name for this instance
* Get the platform name for this instance
*
*
...
...
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
168fc6b1
...
@@ -135,6 +135,11 @@ class PostgreSqlPlatform extends AbstractPlatform
...
@@ -135,6 +135,11 @@ class PostgreSqlPlatform extends AbstractPlatform
{
{
return
true
;
return
true
;
}
}
public
function
supportsCommentOnStatement
()
{
return
true
;
}
/**
/**
* Whether the platform prefers sequences for ID generation.
* Whether the platform prefers sequences for ID generation.
...
@@ -241,7 +246,7 @@ class PostgreSqlPlatform extends AbstractPlatform
...
@@ -241,7 +246,7 @@ class PostgreSqlPlatform extends AbstractPlatform
return
$whereClause
;
return
$whereClause
;
}
}
public
function
getListTableColumnsSQL
(
$table
)
public
function
getListTableColumnsSQL
(
$table
,
$database
=
null
)
{
{
return
"SELECT
return
"SELECT
a.attnum,
a.attnum,
...
@@ -262,8 +267,11 @@ class PostgreSqlPlatform extends AbstractPlatform
...
@@ -262,8 +267,11 @@ class PostgreSqlPlatform extends AbstractPlatform
FROM pg_attrdef
FROM pg_attrdef
WHERE c.oid = pg_attrdef.adrelid
WHERE c.oid = pg_attrdef.adrelid
AND pg_attrdef.adnum=a.attnum
AND pg_attrdef.adnum=a.attnum
) AS default
) AS default,
FROM pg_attribute a, pg_class c, pg_type t, pg_namespace n
(SELECT pg_description.description
FROM pg_description WHERE pg_description.objoid = c.oid AND a.attnum = pg_description.objsubid
) AS comment
FROM pg_attribute a, pg_class c, pg_type t, pg_namespace n
WHERE "
.
$this
->
getTableWhereClause
(
$table
,
'c'
,
'n'
)
.
"
WHERE "
.
$this
->
getTableWhereClause
(
$table
,
'c'
,
'n'
)
.
"
AND a.attnum > 0
AND a.attnum > 0
AND a.attrelid = c.oid
AND a.attrelid = c.oid
...
@@ -340,10 +348,14 @@ class PostgreSqlPlatform extends AbstractPlatform
...
@@ -340,10 +348,14 @@ class PostgreSqlPlatform extends AbstractPlatform
public
function
getAlterTableSQL
(
TableDiff
$diff
)
public
function
getAlterTableSQL
(
TableDiff
$diff
)
{
{
$sql
=
array
();
$sql
=
array
();
$commentsSQL
=
array
();
foreach
(
$diff
->
addedColumns
as
$column
)
{
foreach
(
$diff
->
addedColumns
as
$column
)
{
$query
=
'ADD '
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$column
->
toArray
());
$query
=
'ADD '
.
$this
->
getColumnDeclarationSQL
(
$column
->
getQuotedName
(
$this
),
$column
->
toArray
());
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' '
.
$query
;
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' '
.
$query
;
if
(
$comment
=
$this
->
getColumnComment
(
$column
))
{
$commentsSQL
[]
=
$this
->
getCommentOnColumnSQL
(
$diff
->
name
,
$column
->
getName
(),
$comment
);
}
}
}
foreach
(
$diff
->
removedColumns
as
$column
)
{
foreach
(
$diff
->
removedColumns
as
$column
)
{
...
@@ -385,6 +397,9 @@ class PostgreSqlPlatform extends AbstractPlatform
...
@@ -385,6 +397,9 @@ class PostgreSqlPlatform extends AbstractPlatform
$sql
[]
=
"ALTER TABLE "
.
$diff
->
name
.
" "
.
$query
;
$sql
[]
=
"ALTER TABLE "
.
$diff
->
name
.
" "
.
$query
;
}
}
}
}
if
(
$columnDiff
->
hasChanged
(
'comment'
)
&&
$comment
=
$this
->
getColumnComment
(
$column
))
{
$commentsSQL
[]
=
$this
->
getCommentOnColumnSQL
(
$diff
->
name
,
$column
->
getName
(),
$comment
);
}
}
}
foreach
(
$diff
->
renamedColumns
as
$oldColumnName
=>
$column
)
{
foreach
(
$diff
->
renamedColumns
as
$oldColumnName
=>
$column
)
{
...
@@ -395,9 +410,7 @@ class PostgreSqlPlatform extends AbstractPlatform
...
@@ -395,9 +410,7 @@ class PostgreSqlPlatform extends AbstractPlatform
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' RENAME TO '
.
$diff
->
newName
;
$sql
[]
=
'ALTER TABLE '
.
$diff
->
name
.
' RENAME TO '
.
$diff
->
newName
;
}
}
$sql
=
array_merge
(
$sql
,
$this
->
_getAlterTableIndexForeignKeySQL
(
$diff
));
return
array_merge
(
$sql
,
$this
->
_getAlterTableIndexForeignKeySQL
(
$diff
),
$commentsSQL
);
return
$sql
;
}
}
/**
/**
...
...
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
View file @
168fc6b1
...
@@ -326,7 +326,7 @@ class SqlitePlatform extends AbstractPlatform
...
@@ -326,7 +326,7 @@ class SqlitePlatform extends AbstractPlatform
return
"SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name = '
$table
' AND sql NOT NULL ORDER BY name"
;
return
"SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name = '
$table
' AND sql NOT NULL ORDER BY name"
;
}
}
public
function
getListTableColumnsSQL
(
$table
)
public
function
getListTableColumnsSQL
(
$table
,
$database
=
null
)
{
{
return
"PRAGMA table_info(
$table
)"
;
return
"PRAGMA table_info(
$table
)"
;
}
}
...
...
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
View file @
168fc6b1
...
@@ -141,11 +141,16 @@ abstract class AbstractSchemaManager
...
@@ -141,11 +141,16 @@ abstract class AbstractSchemaManager
* in the platformDetails array.
* in the platformDetails array.
*
*
* @param string $table The name of the table.
* @param string $table The name of the table.
* @param string $database
* @return Column[]
* @return Column[]
*/
*/
public
function
listTableColumns
(
$table
)
public
function
listTableColumns
(
$table
,
$database
=
null
)
{
{
$sql
=
$this
->
_platform
->
getListTableColumnsSQL
(
$table
);
if
(
!
$database
)
{
$database
=
$this
->
_conn
->
getDatabase
();
}
$sql
=
$this
->
_platform
->
getListTableColumnsSQL
(
$table
,
$database
);
$tableColumns
=
$this
->
_conn
->
fetchAll
(
$sql
);
$tableColumns
=
$this
->
_conn
->
fetchAll
(
$sql
);
...
@@ -774,4 +779,25 @@ abstract class AbstractSchemaManager
...
@@ -774,4 +779,25 @@ abstract class AbstractSchemaManager
return
$schemaConfig
;
return
$schemaConfig
;
}
}
/**
* Given a table comment this method tries to extract a typehint for Doctrine Type, or returns
* the type given as default.
*
* @param string $comment
* @param string $currentType
* @return string
*/
public
function
extractDoctrineTypeFromComment
(
$comment
,
$currentType
)
{
if
(
preg_match
(
"(\(DC2Type:([a-zA-Z0-9]+)\))"
,
$comment
,
$match
))
{
$currentType
=
$match
[
1
];
}
return
$currentType
;
}
public
function
removeDoctrineTypeFromComment
(
$comment
,
$type
)
{
return
str_replace
(
'(DC2Type:'
.
$type
.
')'
,
''
,
$comment
);
}
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Schema/Column.php
View file @
168fc6b1
...
@@ -88,6 +88,11 @@ class Column extends AbstractAsset
...
@@ -88,6 +88,11 @@ class Column extends AbstractAsset
*/
*/
protected
$_columnDefinition
=
null
;
protected
$_columnDefinition
=
null
;
/**
* @var string
*/
protected
$_comment
=
null
;
/**
/**
* Create a new Column
* Create a new Column
*
*
...
@@ -316,6 +321,17 @@ class Column extends AbstractAsset
...
@@ -316,6 +321,17 @@ class Column extends AbstractAsset
return
$this
;
return
$this
;
}
}
public
function
setComment
(
$comment
)
{
$this
->
_comment
=
$comment
;
return
$this
;
}
public
function
getComment
()
{
return
$this
->
_comment
;
}
/**
/**
* @param Visitor $visitor
* @param Visitor $visitor
*/
*/
...
@@ -341,6 +357,7 @@ class Column extends AbstractAsset
...
@@ -341,6 +357,7 @@ class Column extends AbstractAsset
'unsigned'
=>
$this
->
_unsigned
,
'unsigned'
=>
$this
->
_unsigned
,
'autoincrement'
=>
$this
->
_autoincrement
,
'autoincrement'
=>
$this
->
_autoincrement
,
'columnDefinition'
=>
$this
->
_columnDefinition
,
'columnDefinition'
=>
$this
->
_columnDefinition
,
'comment'
=>
$this
->
_comment
,
),
$this
->
_platformOptions
);
),
$this
->
_platformOptions
);
}
}
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Schema/Comparator.php
View file @
168fc6b1
...
@@ -344,6 +344,11 @@ class Comparator
...
@@ -344,6 +344,11 @@ class Comparator
$changedProperties
[]
=
'autoincrement'
;
$changedProperties
[]
=
'autoincrement'
;
}
}
// only allow to delete comment if its set to '' not to null.
if
(
$column1
->
getComment
()
!==
null
&&
$column1
->
getComment
()
!=
$column2
->
getComment
())
{
$changedProperties
[]
=
'comment'
;
}
return
$changedProperties
;
return
$changedProperties
;
}
}
...
...
lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
View file @
168fc6b1
...
@@ -107,6 +107,9 @@ class MySqlSchemaManager extends AbstractSchemaManager
...
@@ -107,6 +107,9 @@ class MySqlSchemaManager extends AbstractSchemaManager
$precision
=
null
;
$precision
=
null
;
$type
=
$this
->
_platform
->
getDoctrineTypeMapping
(
$dbType
);
$type
=
$this
->
_platform
->
getDoctrineTypeMapping
(
$dbType
);
$type
=
$this
->
extractDoctrineTypeFromComment
(
$tableColumn
[
'comment'
],
$type
);
$tableColumn
[
'comment'
]
=
$this
->
removeDoctrineTypeFromComment
(
$tableColumn
[
'comment'
],
$type
);
switch
(
$dbType
)
{
switch
(
$dbType
)
{
case
'char'
:
case
'char'
:
$fixed
=
true
;
$fixed
=
true
;
...
@@ -156,6 +159,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
...
@@ -156,6 +159,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
'scale'
=>
null
,
'scale'
=>
null
,
'precision'
=>
null
,
'precision'
=>
null
,
'autoincrement'
=>
(
bool
)
(
strpos
(
$tableColumn
[
'extra'
],
'auto_increment'
)
!==
false
),
'autoincrement'
=>
(
bool
)
(
strpos
(
$tableColumn
[
'extra'
],
'auto_increment'
)
!==
false
),
'comment'
=>
(
isset
(
$tableColumn
[
'comment'
]))
?
$tableColumn
[
'comment'
]
:
null
);
);
if
(
$scale
!==
null
&&
$precision
!==
null
)
{
if
(
$scale
!==
null
&&
$precision
!==
null
)
{
...
...
lib/Doctrine/DBAL/Schema/OracleSchemaManager.php
View file @
168fc6b1
...
@@ -117,6 +117,9 @@ class OracleSchemaManager extends AbstractSchemaManager
...
@@ -117,6 +117,9 @@ class OracleSchemaManager extends AbstractSchemaManager
$scale
=
null
;
$scale
=
null
;
$type
=
$this
->
_platform
->
getDoctrineTypeMapping
(
$dbType
);
$type
=
$this
->
_platform
->
getDoctrineTypeMapping
(
$dbType
);
$type
=
$this
->
extractDoctrineTypeFromComment
(
$tableColumn
[
'comments'
],
$type
);
$tableColumn
[
'comments'
]
=
$this
->
removeDoctrineTypeFromComment
(
$tableColumn
[
'comments'
],
$type
);
switch
(
$dbType
)
{
switch
(
$dbType
)
{
case
'number'
:
case
'number'
:
if
(
$tableColumn
[
'data_precision'
]
==
20
&&
$tableColumn
[
'data_scale'
]
==
0
)
{
if
(
$tableColumn
[
'data_precision'
]
==
20
&&
$tableColumn
[
'data_scale'
]
==
0
)
{
...
@@ -186,6 +189,7 @@ class OracleSchemaManager extends AbstractSchemaManager
...
@@ -186,6 +189,7 @@ class OracleSchemaManager extends AbstractSchemaManager
'length'
=>
$length
,
'length'
=>
$length
,
'precision'
=>
$precision
,
'precision'
=>
$precision
,
'scale'
=>
$scale
,
'scale'
=>
$scale
,
'comment'
=>
(
isset
(
$tableColumn
[
'comments'
]))
?
$tableColumn
[
'comments'
]
:
null
,
'platformDetails'
=>
array
(),
'platformDetails'
=>
array
(),
);
);
...
...
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
View file @
168fc6b1
...
@@ -201,7 +201,6 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
...
@@ -201,7 +201,6 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
if
((
int
)
$length
<=
0
)
{
if
((
int
)
$length
<=
0
)
{
$length
=
null
;
$length
=
null
;
}
}
$type
=
array
();
$fixed
=
null
;
$fixed
=
null
;
if
(
!
isset
(
$tableColumn
[
'name'
]))
{
if
(
!
isset
(
$tableColumn
[
'name'
]))
{
...
@@ -219,6 +218,9 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
...
@@ -219,6 +218,9 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
}
}
$type
=
$this
->
_platform
->
getDoctrineTypeMapping
(
$dbType
);
$type
=
$this
->
_platform
->
getDoctrineTypeMapping
(
$dbType
);
$type
=
$this
->
extractDoctrineTypeFromComment
(
$tableColumn
[
'comment'
],
$type
);
$tableColumn
[
'comment'
]
=
$this
->
removeDoctrineTypeFromComment
(
$tableColumn
[
'comment'
],
$type
);
switch
(
$dbType
)
{
switch
(
$dbType
)
{
case
'smallint'
:
case
'smallint'
:
case
'int2'
:
case
'int2'
:
...
@@ -270,15 +272,16 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
...
@@ -270,15 +272,16 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
}
}
$options
=
array
(
$options
=
array
(
'length'
=>
$length
,
'length'
=>
$length
,
'notnull'
=>
(
bool
)
$tableColumn
[
'isnotnull'
],
'notnull'
=>
(
bool
)
$tableColumn
[
'isnotnull'
],
'default'
=>
$tableColumn
[
'default'
],
'default'
=>
$tableColumn
[
'default'
],
'primary'
=>
(
bool
)
(
$tableColumn
[
'pri'
]
==
't'
),
'primary'
=>
(
bool
)
(
$tableColumn
[
'pri'
]
==
't'
),
'precision'
=>
$precision
,
'precision'
=>
$precision
,
'scale'
=>
$scale
,
'scale'
=>
$scale
,
'fixed'
=>
$fixed
,
'fixed'
=>
$fixed
,
'unsigned'
=>
false
,
'unsigned'
=>
false
,
'autoincrement'
=>
$autoincrement
,
'autoincrement'
=>
$autoincrement
,
'comment'
=>
$tableColumn
[
'comment'
],
);
);
return
new
Column
(
$tableColumn
[
'field'
],
\Doctrine\DBAL\Types\Type
::
getType
(
$type
),
$options
);
return
new
Column
(
$tableColumn
[
'field'
],
\Doctrine\DBAL\Types\Type
::
getType
(
$type
),
$options
);
...
...
tests/Doctrine/Tests/DBAL/ConnectionTest.php
View file @
168fc6b1
...
@@ -66,7 +66,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
...
@@ -66,7 +66,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
{
{
$config
=
$this
->
_conn
->
getConfiguration
();
$config
=
$this
->
_conn
->
getConfiguration
();
$this
->
assert
Type
(
'Doctrine\DBAL\Configuration'
,
$config
);
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Configuration'
,
$config
);
}
}
public
function
testGetHost
()
public
function
testGetHost
()
...
@@ -91,12 +91,12 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
...
@@ -91,12 +91,12 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
public
function
testGetDriver
()
public
function
testGetDriver
()
{
{
$this
->
assert
Type
(
'Doctrine\DBAL\Driver\PDOMySql\Driver'
,
$this
->
_conn
->
getDriver
());
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Driver\PDOMySql\Driver'
,
$this
->
_conn
->
getDriver
());
}
}
public
function
testGetEventManager
()
public
function
testGetEventManager
()
{
{
$this
->
assert
Type
(
'Doctrine\Common\EventManager'
,
$this
->
_conn
->
getEventManager
());
$this
->
assert
InstanceOf
(
'Doctrine\Common\EventManager'
,
$this
->
_conn
->
getEventManager
());
}
}
public
function
testConnectDispatchEvent
()
public
function
testConnectDispatchEvent
()
...
...
tests/Doctrine/Tests/DBAL/DriverManagerTest.php
View file @
168fc6b1
...
@@ -79,7 +79,7 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
...
@@ -79,7 +79,7 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
);
);
$conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
$options
);
$conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
$options
);
$this
->
assert
Type
(
$wrapperClass
,
$conn
);
$this
->
assert
InstanceOf
(
$wrapperClass
,
$conn
);
}
}
public
function
testInvalidWrapperClass
()
public
function
testInvalidWrapperClass
()
...
@@ -112,6 +112,6 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
...
@@ -112,6 +112,6 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
);
);
$conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
$options
);
$conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
$options
);
$this
->
assert
Type
(
'Doctrine\DBAL\Driver\PDOMySql\Driver'
,
$conn
->
getDriver
());
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Driver\PDOMySql\Driver'
,
$conn
->
getDriver
());
}
}
}
}
\ No newline at end of file
tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php
View file @
168fc6b1
...
@@ -22,7 +22,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
...
@@ -22,7 +22,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
public
function
testGetWrappedConnection
()
public
function
testGetWrappedConnection
()
{
{
$this
->
assert
Type
(
'Doctrine\DBAL\Driver\Connection'
,
$this
->
_conn
->
getWrappedConnection
());
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Driver\Connection'
,
$this
->
_conn
->
getWrappedConnection
());
}
}
public
function
testCommitWithRollbackOnlyThrowsException
()
public
function
testCommitWithRollbackOnlyThrowsException
()
...
...
tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
View file @
168fc6b1
...
@@ -33,7 +33,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
...
@@ -33,7 +33,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
{
{
$sql
=
"SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"
;
$sql
=
"SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"
;
$stmt
=
$this
->
_conn
->
prepare
(
$sql
);
$stmt
=
$this
->
_conn
->
prepare
(
$sql
);
$this
->
assert
Type
(
'Doctrine\DBAL\Statement'
,
$stmt
);
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Statement'
,
$stmt
);
$stmt
->
bindValue
(
1
,
1
);
$stmt
->
bindValue
(
1
,
1
);
$stmt
->
bindValue
(
2
,
'foo'
);
$stmt
->
bindValue
(
2
,
'foo'
);
...
@@ -51,7 +51,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
...
@@ -51,7 +51,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$sql
=
"SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"
;
$sql
=
"SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"
;
$stmt
=
$this
->
_conn
->
prepare
(
$sql
);
$stmt
=
$this
->
_conn
->
prepare
(
$sql
);
$this
->
assert
Type
(
'Doctrine\DBAL\Statement'
,
$stmt
);
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Statement'
,
$stmt
);
$stmt
->
bindParam
(
1
,
$paramInt
);
$stmt
->
bindParam
(
1
,
$paramInt
);
$stmt
->
bindParam
(
2
,
$paramStr
);
$stmt
->
bindParam
(
2
,
$paramStr
);
...
@@ -69,7 +69,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
...
@@ -69,7 +69,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$sql
=
"SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"
;
$sql
=
"SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"
;
$stmt
=
$this
->
_conn
->
prepare
(
$sql
);
$stmt
=
$this
->
_conn
->
prepare
(
$sql
);
$this
->
assert
Type
(
'Doctrine\DBAL\Statement'
,
$stmt
);
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Statement'
,
$stmt
);
$stmt
->
bindParam
(
1
,
$paramInt
);
$stmt
->
bindParam
(
1
,
$paramInt
);
$stmt
->
bindParam
(
2
,
$paramStr
);
$stmt
->
bindParam
(
2
,
$paramStr
);
...
@@ -87,7 +87,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
...
@@ -87,7 +87,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$sql
=
"SELECT test_int FROM fetch_table WHERE test_int = ? AND test_string = ?"
;
$sql
=
"SELECT test_int FROM fetch_table WHERE test_int = ? AND test_string = ?"
;
$stmt
=
$this
->
_conn
->
prepare
(
$sql
);
$stmt
=
$this
->
_conn
->
prepare
(
$sql
);
$this
->
assert
Type
(
'Doctrine\DBAL\Statement'
,
$stmt
);
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Statement'
,
$stmt
);
$stmt
->
bindParam
(
1
,
$paramInt
);
$stmt
->
bindParam
(
1
,
$paramInt
);
$stmt
->
bindParam
(
2
,
$paramStr
);
$stmt
->
bindParam
(
2
,
$paramStr
);
...
@@ -106,7 +106,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
...
@@ -106,7 +106,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$sql
=
"SELECT test_int, test_string FROM "
.
$this
->
_conn
->
quoteIdentifier
(
$table
)
.
" "
.
$sql
=
"SELECT test_int, test_string FROM "
.
$this
->
_conn
->
quoteIdentifier
(
$table
)
.
" "
.
"WHERE test_int = "
.
$this
->
_conn
->
quote
(
$paramInt
)
.
" AND test_string = "
.
$this
->
_conn
->
quote
(
$paramStr
);
"WHERE test_int = "
.
$this
->
_conn
->
quote
(
$paramInt
)
.
" AND test_string = "
.
$this
->
_conn
->
quote
(
$paramStr
);
$stmt
=
$this
->
_conn
->
prepare
(
$sql
);
$stmt
=
$this
->
_conn
->
prepare
(
$sql
);
$this
->
assert
Type
(
'Doctrine\DBAL\Statement'
,
$stmt
);
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Statement'
,
$stmt
);
}
}
public
function
testPrepareWithExecuteParams
()
public
function
testPrepareWithExecuteParams
()
...
@@ -116,7 +116,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
...
@@ -116,7 +116,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$sql
=
"SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"
;
$sql
=
"SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"
;
$stmt
=
$this
->
_conn
->
prepare
(
$sql
);
$stmt
=
$this
->
_conn
->
prepare
(
$sql
);
$this
->
assert
Type
(
'Doctrine\DBAL\Statement'
,
$stmt
);
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Statement'
,
$stmt
);
$stmt
->
execute
(
array
(
$paramInt
,
$paramStr
));
$stmt
->
execute
(
array
(
$paramInt
,
$paramStr
));
$row
=
$stmt
->
fetch
(
\PDO
::
FETCH_ASSOC
);
$row
=
$stmt
->
fetch
(
\PDO
::
FETCH_ASSOC
);
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php
View file @
168fc6b1
...
@@ -22,13 +22,13 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
...
@@ -22,13 +22,13 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this
->
_conn
->
exec
(
$createTableSQL
);
$this
->
_conn
->
exec
(
$createTableSQL
);
$table
=
$this
->
_conn
->
getSchemaManager
()
->
listTableDetails
(
'domain_type_test'
);
$table
=
$this
->
_conn
->
getSchemaManager
()
->
listTableDetails
(
'domain_type_test'
);
$this
->
assert
Type
(
'Doctrine\DBAL\Types\DecimalType'
,
$table
->
getColumn
(
'value'
)
->
getType
());
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Types\DecimalType'
,
$table
->
getColumn
(
'value'
)
->
getType
());
Type
::
addType
(
'MyMoney'
,
'Doctrine\Tests\DBAL\Functional\Schema\MoneyType'
);
Type
::
addType
(
'MyMoney'
,
'Doctrine\Tests\DBAL\Functional\Schema\MoneyType'
);
$this
->
_conn
->
getDatabasePlatform
()
->
registerDoctrineTypeMapping
(
'MyMoney'
,
'MyMoney'
);
$this
->
_conn
->
getDatabasePlatform
()
->
registerDoctrineTypeMapping
(
'MyMoney'
,
'MyMoney'
);
$table
=
$this
->
_conn
->
getSchemaManager
()
->
listTableDetails
(
'domain_type_test'
);
$table
=
$this
->
_conn
->
getSchemaManager
()
->
listTableDetails
(
'domain_type_test'
);
$this
->
assert
Type
(
'Doctrine\Tests\DBAL\Functional\Schema\MoneyType'
,
$table
->
getColumn
(
'value'
)
->
getType
());
$this
->
assert
InstanceOf
(
'Doctrine\Tests\DBAL\Functional\Schema\MoneyType'
,
$table
->
getColumn
(
'value'
)
->
getType
());
}
}
/**
/**
...
@@ -91,7 +91,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
...
@@ -91,7 +91,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$c
=
new
\Doctrine\DBAL\Schema\Comparator
();
$c
=
new
\Doctrine\DBAL\Schema\Comparator
();
$diff
=
$c
->
diffTable
(
$tableFrom
,
$tableTo
);
$diff
=
$c
->
diffTable
(
$tableFrom
,
$tableTo
);
$this
->
assert
Type
(
'Doctrine\DBAL\Schema\TableDiff'
,
$diff
,
"There should be a difference and not false being returned from the table comparison"
);
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Schema\TableDiff'
,
$diff
,
"There should be a difference and not false being returned from the table comparison"
);
$this
->
assertEquals
(
array
(
"ALTER TABLE autoinc_table_drop ALTER id DROP DEFAULT"
),
$this
->
_conn
->
getDatabasePlatform
()
->
getAlterTableSQL
(
$diff
));
$this
->
assertEquals
(
array
(
"ALTER TABLE autoinc_table_drop ALTER id DROP DEFAULT"
),
$this
->
_conn
->
getDatabasePlatform
()
->
getAlterTableSQL
(
$diff
));
$this
->
_sm
->
alterTable
(
$diff
);
$this
->
_sm
->
alterTable
(
$diff
);
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
View file @
168fc6b1
This diff is collapsed.
Click to expand it.
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
168fc6b1
...
@@ -165,4 +165,43 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
...
@@ -165,4 +165,43 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$field
=
array
(
'columnDefinition'
=>
'MEDIUMINT(6) UNSIGNED'
);
$field
=
array
(
'columnDefinition'
=>
'MEDIUMINT(6) UNSIGNED'
);
$this
->
assertEquals
(
'foo MEDIUMINT(6) UNSIGNED'
,
$this
->
_platform
->
getColumnDeclarationSQL
(
'foo'
,
$field
));
$this
->
assertEquals
(
'foo MEDIUMINT(6) UNSIGNED'
,
$this
->
_platform
->
getColumnDeclarationSQL
(
'foo'
,
$field
));
}
}
/**
* @group DBAL-42
*/
public
function
testCreateTableColumnComments
()
{
$table
=
new
\Doctrine\DBAL\Schema\Table
(
'test'
);
$table
->
addColumn
(
'id'
,
'integer'
,
array
(
'comment'
=>
'This is a comment'
));
$table
->
setPrimaryKey
(
array
(
'id'
));
$this
->
assertEquals
(
$this
->
getCreateTableColumnCommentsSQL
(),
$this
->
_platform
->
getCreateTableSQL
(
$table
));
}
/**
* @group DBAL-42
*/
public
function
testAlterTableColumnComments
()
{
$tableDiff
=
new
\Doctrine\DBAL\Schema\TableDiff
(
'mytable'
);
$tableDiff
->
addedColumns
[
'quota'
]
=
new
\Doctrine\DBAL\Schema\Column
(
'quota'
,
\Doctrine\DBAL\Types\Type
::
getType
(
'integer'
),
array
(
'comment'
=>
'A comment'
));
$tableDiff
->
changedColumns
[
'bar'
]
=
new
\Doctrine\DBAL\Schema\ColumnDiff
(
'bar'
,
new
\Doctrine\DBAL\Schema\Column
(
'baz'
,
\Doctrine\DBAL\Types\Type
::
getType
(
'string'
),
array
(
'comment'
=>
'B comment'
)
),
array
(
'comment'
)
);
$this
->
assertEquals
(
$this
->
getAlterTableColumnCommentsSQL
(),
$this
->
_platform
->
getAlterTableSQL
(
$tableDiff
));
}
public
function
getCreateTableColumnCommentsSQL
()
{
$this
->
markTestSkipped
(
'Platform does not support Column comments.'
);
}
public
function
getAlterTableColumnCommentsSQL
()
{
$this
->
markTestSkipped
(
'Platform does not support Column comments.'
);
}
}
}
tests/Doctrine/Tests/DBAL/Platforms/MsSqlPlatformTest.php
View file @
168fc6b1
...
@@ -171,4 +171,5 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase
...
@@ -171,4 +171,5 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase
$this
->
assertEquals
(
'SELECT TOP 10 * FROM user ORDER BY username DESC'
,
$sql
);
$this
->
assertEquals
(
'SELECT TOP 10 * FROM user ORDER BY username DESC'
,
$sql
);
}
}
}
}
\ No newline at end of file
tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
View file @
168fc6b1
...
@@ -166,4 +166,14 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
...
@@ -166,4 +166,14 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
$this
->
assertEquals
(
"TIMESTAMP"
,
$this
->
_platform
->
getDateTimeTypeDeclarationSQL
(
array
(
'version'
=>
true
)));
$this
->
assertEquals
(
"TIMESTAMP"
,
$this
->
_platform
->
getDateTimeTypeDeclarationSQL
(
array
(
'version'
=>
true
)));
$this
->
assertEquals
(
"DATETIME"
,
$this
->
_platform
->
getDateTimeTypeDeclarationSQL
(
array
()));
$this
->
assertEquals
(
"DATETIME"
,
$this
->
_platform
->
getDateTimeTypeDeclarationSQL
(
array
()));
}
}
public
function
getCreateTableColumnCommentsSQL
()
{
return
array
(
"CREATE TABLE test (id INT NOT NULL COMMENT 'This is a comment', PRIMARY KEY(id)) ENGINE = InnoDB"
);
}
public
function
getAlterTableColumnCommentsSQL
()
{
return
array
(
"ALTER TABLE mytable ADD quota INT NOT NULL COMMENT 'A comment', CHANGE bar baz VARCHAR(255) NOT NULL COMMENT 'B comment'"
);
}
}
}
\ No newline at end of file
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
View file @
168fc6b1
...
@@ -186,4 +186,22 @@ class OraclePlatformTest extends AbstractPlatformTestCase
...
@@ -186,4 +186,22 @@ class OraclePlatformTest extends AbstractPlatformTestCase
$sql
=
$this
->
_platform
->
modifyLimitQuery
(
'SELECT * FROM user ORDER BY username DESC'
,
10
);
$sql
=
$this
->
_platform
->
modifyLimitQuery
(
'SELECT * FROM user ORDER BY username DESC'
,
10
);
$this
->
assertEquals
(
'SELECT a.* FROM (SELECT * FROM user ORDER BY username DESC) a WHERE ROWNUM <= 10'
,
$sql
);
$this
->
assertEquals
(
'SELECT a.* FROM (SELECT * FROM user ORDER BY username DESC) a WHERE ROWNUM <= 10'
,
$sql
);
}
}
public
function
getCreateTableColumnCommentsSQL
()
{
return
array
(
"CREATE TABLE test (id NUMBER(10) NOT NULL, PRIMARY KEY(id))"
,
"COMMENT ON COLUMN test.id IS 'This is a comment'"
,
);
}
public
function
getAlterTableColumnCommentsSQL
()
{
return
array
(
"ALTER TABLE mytable ADD (quota NUMBER(10) NOT NULL)"
,
"ALTER TABLE mytable MODIFY (baz VARCHAR2(255) NOT NULL)"
,
"COMMENT ON COLUMN mytable.quota IS 'A comment'"
,
"COMMENT ON COLUMN mytable.baz IS 'B comment'"
,
);
}
}
}
\ No newline at end of file
tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
View file @
168fc6b1
...
@@ -199,4 +199,21 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
...
@@ -199,4 +199,21 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
$sql
=
$this
->
_platform
->
modifyLimitQuery
(
'SELECT * FROM user'
,
10
);
$sql
=
$this
->
_platform
->
modifyLimitQuery
(
'SELECT * FROM user'
,
10
);
$this
->
assertEquals
(
'SELECT * FROM user LIMIT 10'
,
$sql
);
$this
->
assertEquals
(
'SELECT * FROM user LIMIT 10'
,
$sql
);
}
}
public
function
getCreateTableColumnCommentsSQL
()
{
return
array
(
"CREATE TABLE test (id INT NOT NULL, PRIMARY KEY(id))"
,
"COMMENT ON COLUMN test.id IS 'This is a comment'"
,
);
}
public
function
getAlterTableColumnCommentsSQL
()
{
return
array
(
"ALTER TABLE mytable ADD quota INT NOT NULL"
,
"COMMENT ON COLUMN mytable.quota IS 'A comment'"
,
"COMMENT ON COLUMN mytable.baz IS 'B comment'"
,
);
}
}
}
\ No newline at end of file
tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php
View file @
168fc6b1
...
@@ -46,6 +46,7 @@ class ColumnTest extends \PHPUnit_Framework_TestCase
...
@@ -46,6 +46,7 @@ class ColumnTest extends \PHPUnit_Framework_TestCase
'unsigned'
=>
true
,
'unsigned'
=>
true
,
'autoincrement'
=>
false
,
'autoincrement'
=>
false
,
'columnDefinition'
=>
null
,
'columnDefinition'
=>
null
,
'comment'
=>
null
,
'foo'
=>
'bar'
,
'foo'
=>
'bar'
,
);
);
...
@@ -87,4 +88,20 @@ class ColumnTest extends \PHPUnit_Framework_TestCase
...
@@ -87,4 +88,20 @@ class ColumnTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
'`bar`'
,
$column
->
getQuotedName
(
$mysqlPlatform
));
$this
->
assertEquals
(
'`bar`'
,
$column
->
getQuotedName
(
$mysqlPlatform
));
$this
->
assertEquals
(
'"bar"'
,
$column
->
getQuotedName
(
$sqlitePlatform
));
$this
->
assertEquals
(
'"bar"'
,
$column
->
getQuotedName
(
$sqlitePlatform
));
}
}
/**
* @group DBAL-42
*/
public
function
testColumnComment
()
{
$column
=
new
Column
(
"bar"
,
Type
::
getType
(
'string'
));
$this
->
assertNull
(
$column
->
getComment
());
$column
->
setComment
(
"foo"
);
$this
->
assertEquals
(
"foo"
,
$column
->
getComment
());
$columnArray
=
$column
->
toArray
();
$this
->
assertArrayHasKey
(
'comment'
,
$columnArray
);
$this
->
assertEquals
(
'foo'
,
$columnArray
[
'comment'
]);
}
}
}
\ No newline at end of file
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
View file @
168fc6b1
...
@@ -426,7 +426,7 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
...
@@ -426,7 +426,7 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$c
=
new
Comparator
();
$c
=
new
Comparator
();
$tableDiff
=
$c
->
diffTable
(
$table1
,
$table2
);
$tableDiff
=
$c
->
diffTable
(
$table1
,
$table2
);
$this
->
assert
Type
(
'Doctrine\DBAL\Schema\TableDiff'
,
$tableDiff
);
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Schema\TableDiff'
,
$tableDiff
);
$this
->
assertEquals
(
1
,
count
(
$tableDiff
->
addedForeignKeys
));
$this
->
assertEquals
(
1
,
count
(
$tableDiff
->
addedForeignKeys
));
}
}
...
@@ -445,7 +445,7 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
...
@@ -445,7 +445,7 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$c
=
new
Comparator
();
$c
=
new
Comparator
();
$tableDiff
=
$c
->
diffTable
(
$table2
,
$table1
);
$tableDiff
=
$c
->
diffTable
(
$table2
,
$table1
);
$this
->
assert
Type
(
'Doctrine\DBAL\Schema\TableDiff'
,
$tableDiff
);
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Schema\TableDiff'
,
$tableDiff
);
$this
->
assertEquals
(
1
,
count
(
$tableDiff
->
removedForeignKeys
));
$this
->
assertEquals
(
1
,
count
(
$tableDiff
->
removedForeignKeys
));
}
}
...
@@ -465,7 +465,7 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
...
@@ -465,7 +465,7 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$c
=
new
Comparator
();
$c
=
new
Comparator
();
$tableDiff
=
$c
->
diffTable
(
$table1
,
$table2
);
$tableDiff
=
$c
->
diffTable
(
$table1
,
$table2
);
$this
->
assert
Type
(
'Doctrine\DBAL\Schema\TableDiff'
,
$tableDiff
);
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Schema\TableDiff'
,
$tableDiff
);
$this
->
assertEquals
(
1
,
count
(
$tableDiff
->
changedForeignKeys
));
$this
->
assertEquals
(
1
,
count
(
$tableDiff
->
changedForeignKeys
));
}
}
...
@@ -621,7 +621,7 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
...
@@ -621,7 +621,7 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$c
=
new
Comparator
();
$c
=
new
Comparator
();
$tableDiff
=
$c
->
diffTable
(
$tableA
,
$tableB
);
$tableDiff
=
$c
->
diffTable
(
$tableA
,
$tableB
);
$this
->
assert
Type
(
'Doctrine\DBAL\Schema\TableDiff'
,
$tableDiff
);
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Schema\TableDiff'
,
$tableDiff
);
$this
->
assertArrayHasKey
(
'id'
,
$tableDiff
->
changedColumns
);
$this
->
assertArrayHasKey
(
'id'
,
$tableDiff
->
changedColumns
);
}
}
...
...
tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php
View file @
168fc6b1
...
@@ -92,7 +92,7 @@ class SchemaTest extends \PHPUnit_Framework_TestCase
...
@@ -92,7 +92,7 @@ class SchemaTest extends \PHPUnit_Framework_TestCase
$table
=
$schema
->
createTable
(
"foo"
);
$table
=
$schema
->
createTable
(
"foo"
);
$this
->
assert
Type
(
'Doctrine\DBAL\Schema\Table'
,
$table
);
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Schema\Table'
,
$table
);
$this
->
assertEquals
(
"foo"
,
$table
->
getName
());
$this
->
assertEquals
(
"foo"
,
$table
->
getName
());
$this
->
assertTrue
(
$schema
->
hasTable
(
"foo"
));
$this
->
assertTrue
(
$schema
->
hasTable
(
"foo"
));
}
}
...
@@ -104,7 +104,7 @@ class SchemaTest extends \PHPUnit_Framework_TestCase
...
@@ -104,7 +104,7 @@ class SchemaTest extends \PHPUnit_Framework_TestCase
$schema
=
new
Schema
(
array
(),
array
(
$sequence
));
$schema
=
new
Schema
(
array
(),
array
(
$sequence
));
$this
->
assertTrue
(
$schema
->
hasSequence
(
"a_seq"
));
$this
->
assertTrue
(
$schema
->
hasSequence
(
"a_seq"
));
$this
->
assert
Type
(
'Doctrine\DBAL\Schema\Sequence'
,
$schema
->
getSequence
(
"a_seq"
));
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Schema\Sequence'
,
$schema
->
getSequence
(
"a_seq"
));
$sequences
=
$schema
->
getSequences
();
$sequences
=
$schema
->
getSequences
();
$this
->
assertArrayHasKey
(
'a_seq'
,
$sequences
);
$this
->
assertArrayHasKey
(
'a_seq'
,
$sequences
);
...
@@ -142,7 +142,7 @@ class SchemaTest extends \PHPUnit_Framework_TestCase
...
@@ -142,7 +142,7 @@ class SchemaTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
20
,
$sequence
->
getInitialValue
());
$this
->
assertEquals
(
20
,
$sequence
->
getInitialValue
());
$this
->
assertTrue
(
$schema
->
hasSequence
(
"a_seq"
));
$this
->
assertTrue
(
$schema
->
hasSequence
(
"a_seq"
));
$this
->
assert
Type
(
'Doctrine\DBAL\Schema\Sequence'
,
$schema
->
getSequence
(
"a_seq"
));
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Schema\Sequence'
,
$schema
->
getSequence
(
"a_seq"
));
$sequences
=
$schema
->
getSequences
();
$sequences
=
$schema
->
getSequences
();
$this
->
assertArrayHasKey
(
'a_seq'
,
$sequences
);
$this
->
assertArrayHasKey
(
'a_seq'
,
$sequences
);
...
...
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
View file @
168fc6b1
...
@@ -38,8 +38,8 @@ class TableTest extends \PHPUnit_Framework_TestCase
...
@@ -38,8 +38,8 @@ class TableTest extends \PHPUnit_Framework_TestCase
$this
->
assertTrue
(
$table
->
hasColumn
(
"bar"
));
$this
->
assertTrue
(
$table
->
hasColumn
(
"bar"
));
$this
->
assertFalse
(
$table
->
hasColumn
(
"baz"
));
$this
->
assertFalse
(
$table
->
hasColumn
(
"baz"
));
$this
->
assert
Type
(
'Doctrine\DBAL\Schema\Column'
,
$table
->
getColumn
(
"foo"
));
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Schema\Column'
,
$table
->
getColumn
(
"foo"
));
$this
->
assert
Type
(
'Doctrine\DBAL\Schema\Column'
,
$table
->
getColumn
(
"bar"
));
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Schema\Column'
,
$table
->
getColumn
(
"bar"
));
$this
->
assertEquals
(
2
,
count
(
$table
->
getColumns
()));
$this
->
assertEquals
(
2
,
count
(
$table
->
getColumns
()));
}
}
...
@@ -153,9 +153,9 @@ class TableTest extends \PHPUnit_Framework_TestCase
...
@@ -153,9 +153,9 @@ class TableTest extends \PHPUnit_Framework_TestCase
$this
->
assertTrue
(
$table
->
hasIndex
(
"bar_idx"
));
$this
->
assertTrue
(
$table
->
hasIndex
(
"bar_idx"
));
$this
->
assertFalse
(
$table
->
hasIndex
(
"some_idx"
));
$this
->
assertFalse
(
$table
->
hasIndex
(
"some_idx"
));
$this
->
assert
Type
(
'Doctrine\DBAL\Schema\Index'
,
$table
->
getPrimaryKey
());
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Schema\Index'
,
$table
->
getPrimaryKey
());
$this
->
assert
Type
(
'Doctrine\DBAL\Schema\Index'
,
$table
->
getIndex
(
'the_primary'
));
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Schema\Index'
,
$table
->
getIndex
(
'the_primary'
));
$this
->
assert
Type
(
'Doctrine\DBAL\Schema\Index'
,
$table
->
getIndex
(
'bar_idx'
));
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Schema\Index'
,
$table
->
getIndex
(
'bar_idx'
));
}
}
public
function
testGetUnknownIndexThrowsException
()
public
function
testGetUnknownIndexThrowsException
()
...
@@ -219,7 +219,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
...
@@ -219,7 +219,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
$table
->
setPrimaryKey
(
array
(
"bar"
));
$table
->
setPrimaryKey
(
array
(
"bar"
));
$this
->
assertTrue
(
$table
->
hasIndex
(
"primary"
));
$this
->
assertTrue
(
$table
->
hasIndex
(
"primary"
));
$this
->
assert
Type
(
'Doctrine\DBAL\Schema\Index'
,
$table
->
getPrimaryKey
());
$this
->
assert
InstanceOf
(
'Doctrine\DBAL\Schema\Index'
,
$table
->
getPrimaryKey
());
$this
->
assertTrue
(
$table
->
getIndex
(
"primary"
)
->
isUnique
());
$this
->
assertTrue
(
$table
->
getIndex
(
"primary"
)
->
isUnique
());
$this
->
assertTrue
(
$table
->
getIndex
(
"primary"
)
->
isPrimary
());
$this
->
assertTrue
(
$table
->
getIndex
(
"primary"
)
->
isPrimary
());
}
}
...
...
tests/Doctrine/Tests/DBAL/Types/BooleanTest.php
View file @
168fc6b1
...
@@ -21,12 +21,12 @@ class BooleanTest extends \Doctrine\Tests\DbalTestCase
...
@@ -21,12 +21,12 @@ class BooleanTest extends \Doctrine\Tests\DbalTestCase
public
function
testBooleanConvertsToDatabaseValue
()
public
function
testBooleanConvertsToDatabaseValue
()
{
{
$this
->
assertType
(
'integer'
,
$this
->
_type
->
convertToDatabaseValue
(
1
,
$this
->
_platform
));
$this
->
assert
Internal
Type
(
'integer'
,
$this
->
_type
->
convertToDatabaseValue
(
1
,
$this
->
_platform
));
}
}
public
function
testBooleanConvertsToPHPValue
()
public
function
testBooleanConvertsToPHPValue
()
{
{
$this
->
assertType
(
'bool'
,
$this
->
_type
->
convertToPHPValue
(
0
,
$this
->
_platform
));
$this
->
assert
Internal
Type
(
'bool'
,
$this
->
_type
->
convertToPHPValue
(
0
,
$this
->
_platform
));
}
}
public
function
testBooleanNullConvertsToPHPValue
()
public
function
testBooleanNullConvertsToPHPValue
()
...
...
tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php
View file @
168fc6b1
...
@@ -33,7 +33,7 @@ class DateTimeTest extends \Doctrine\Tests\DbalTestCase
...
@@ -33,7 +33,7 @@ class DateTimeTest extends \Doctrine\Tests\DbalTestCase
{
{
// Birthday of jwage and also birthday of Doctrine. Send him a present ;)
// Birthday of jwage and also birthday of Doctrine. Send him a present ;)
$date
=
$this
->
_type
->
convertToPHPValue
(
'1985-09-01 00:00:00'
,
$this
->
_platform
);
$date
=
$this
->
_type
->
convertToPHPValue
(
'1985-09-01 00:00:00'
,
$this
->
_platform
);
$this
->
assert
Type
(
'DateTime'
,
$date
);
$this
->
assert
InstanceOf
(
'DateTime'
,
$date
);
$this
->
assertEquals
(
'1985-09-01 00:00:00'
,
$date
->
format
(
'Y-m-d H:i:s'
));
$this
->
assertEquals
(
'1985-09-01 00:00:00'
,
$date
->
format
(
'Y-m-d H:i:s'
));
}
}
...
...
tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php
View file @
168fc6b1
...
@@ -33,7 +33,7 @@ class DateTimeTzTest extends \Doctrine\Tests\DbalTestCase
...
@@ -33,7 +33,7 @@ class DateTimeTzTest extends \Doctrine\Tests\DbalTestCase
{
{
// Birthday of jwage and also birthday of Doctrine. Send him a present ;)
// Birthday of jwage and also birthday of Doctrine. Send him a present ;)
$date
=
$this
->
_type
->
convertToPHPValue
(
'1985-09-01 00:00:00'
,
$this
->
_platform
);
$date
=
$this
->
_type
->
convertToPHPValue
(
'1985-09-01 00:00:00'
,
$this
->
_platform
);
$this
->
assert
Type
(
'DateTime'
,
$date
);
$this
->
assert
InstanceOf
(
'DateTime'
,
$date
);
$this
->
assertEquals
(
'1985-09-01 00:00:00'
,
$date
->
format
(
'Y-m-d H:i:s'
));
$this
->
assertEquals
(
'1985-09-01 00:00:00'
,
$date
->
format
(
'Y-m-d H:i:s'
));
}
}
...
...
tests/Doctrine/Tests/DBAL/Types/DecimalTest.php
View file @
168fc6b1
...
@@ -21,7 +21,7 @@ class DecimalTest extends \Doctrine\Tests\DbalTestCase
...
@@ -21,7 +21,7 @@ class DecimalTest extends \Doctrine\Tests\DbalTestCase
public
function
testDecimalConvertsToPHPValue
()
public
function
testDecimalConvertsToPHPValue
()
{
{
$this
->
assertType
(
'float'
,
$this
->
_type
->
convertToPHPValue
(
'5.5'
,
$this
->
_platform
));
$this
->
assert
Internal
Type
(
'float'
,
$this
->
_type
->
convertToPHPValue
(
'5.5'
,
$this
->
_platform
));
}
}
public
function
testDecimalNullConvertsToPHPValue
()
public
function
testDecimalNullConvertsToPHPValue
()
...
...
tests/Doctrine/Tests/DBAL/Types/FloatTest.php
View file @
168fc6b1
...
@@ -19,7 +19,7 @@ class FloatTest extends \Doctrine\Tests\DbalTestCase
...
@@ -19,7 +19,7 @@ class FloatTest extends \Doctrine\Tests\DbalTestCase
public
function
testFloatConvertsToPHPValue
()
public
function
testFloatConvertsToPHPValue
()
{
{
$this
->
assertType
(
'float'
,
$this
->
_type
->
convertToPHPValue
(
'5.5'
,
$this
->
_platform
));
$this
->
assert
Internal
Type
(
'float'
,
$this
->
_type
->
convertToPHPValue
(
'5.5'
,
$this
->
_platform
));
}
}
public
function
testFloatNullConvertsToPHPValue
()
public
function
testFloatNullConvertsToPHPValue
()
...
@@ -29,7 +29,7 @@ class FloatTest extends \Doctrine\Tests\DbalTestCase
...
@@ -29,7 +29,7 @@ class FloatTest extends \Doctrine\Tests\DbalTestCase
public
function
testFloatConvertToDatabaseValue
()
public
function
testFloatConvertToDatabaseValue
()
{
{
$this
->
assertType
(
'float'
,
$this
->
_type
->
convertToDatabaseValue
(
5.5
,
$this
->
_platform
));
$this
->
assert
Internal
Type
(
'float'
,
$this
->
_type
->
convertToDatabaseValue
(
5.5
,
$this
->
_platform
));
}
}
public
function
testFloatNullConvertToDatabaseValue
()
public
function
testFloatNullConvertToDatabaseValue
()
...
...
tests/Doctrine/Tests/DBAL/Types/IntegerTest.php
View file @
168fc6b1
...
@@ -21,8 +21,8 @@ class IntegerTest extends \Doctrine\Tests\DbalTestCase
...
@@ -21,8 +21,8 @@ class IntegerTest extends \Doctrine\Tests\DbalTestCase
public
function
testIntegerConvertsToPHPValue
()
public
function
testIntegerConvertsToPHPValue
()
{
{
$this
->
assertType
(
'integer'
,
$this
->
_type
->
convertToPHPValue
(
'1'
,
$this
->
_platform
));
$this
->
assert
Internal
Type
(
'integer'
,
$this
->
_type
->
convertToPHPValue
(
'1'
,
$this
->
_platform
));
$this
->
assertType
(
'integer'
,
$this
->
_type
->
convertToPHPValue
(
'0'
,
$this
->
_platform
));
$this
->
assert
Internal
Type
(
'integer'
,
$this
->
_type
->
convertToPHPValue
(
'0'
,
$this
->
_platform
));
}
}
public
function
testIntegerNullConvertsToPHPValue
()
public
function
testIntegerNullConvertsToPHPValue
()
...
...
tests/Doctrine/Tests/DBAL/Types/ObjectTest.php
View file @
168fc6b1
...
@@ -26,12 +26,12 @@ class ObjectTest extends \Doctrine\Tests\DbalTestCase
...
@@ -26,12 +26,12 @@ class ObjectTest extends \Doctrine\Tests\DbalTestCase
public
function
testObjectConvertsToDatabaseValue
()
public
function
testObjectConvertsToDatabaseValue
()
{
{
$this
->
assertType
(
'string'
,
$this
->
_type
->
convertToDatabaseValue
(
new
\stdClass
(),
$this
->
_platform
));
$this
->
assert
Internal
Type
(
'string'
,
$this
->
_type
->
convertToDatabaseValue
(
new
\stdClass
(),
$this
->
_platform
));
}
}
public
function
testObjectConvertsToPHPValue
()
public
function
testObjectConvertsToPHPValue
()
{
{
$this
->
assertType
(
'object'
,
$this
->
_type
->
convertToPHPValue
(
serialize
(
new
\stdClass
),
$this
->
_platform
));
$this
->
assert
Internal
Type
(
'object'
,
$this
->
_type
->
convertToPHPValue
(
serialize
(
new
\stdClass
),
$this
->
_platform
));
}
}
public
function
testConversionFailure
()
public
function
testConversionFailure
()
...
...
tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php
View file @
168fc6b1
...
@@ -21,8 +21,8 @@ class SmallIntTest extends \Doctrine\Tests\DbalTestCase
...
@@ -21,8 +21,8 @@ class SmallIntTest extends \Doctrine\Tests\DbalTestCase
public
function
testSmallIntConvertsToPHPValue
()
public
function
testSmallIntConvertsToPHPValue
()
{
{
$this
->
assertType
(
'integer'
,
$this
->
_type
->
convertToPHPValue
(
'1'
,
$this
->
_platform
));
$this
->
assert
Internal
Type
(
'integer'
,
$this
->
_type
->
convertToPHPValue
(
'1'
,
$this
->
_platform
));
$this
->
assertType
(
'integer'
,
$this
->
_type
->
convertToPHPValue
(
'0'
,
$this
->
_platform
));
$this
->
assert
Internal
Type
(
'integer'
,
$this
->
_type
->
convertToPHPValue
(
'0'
,
$this
->
_platform
));
}
}
public
function
testSmallIntNullConvertsToPHPValue
()
public
function
testSmallIntNullConvertsToPHPValue
()
...
...
tests/Doctrine/Tests/DBAL/Types/StringTest.php
View file @
168fc6b1
...
@@ -31,8 +31,8 @@ class StringTest extends \Doctrine\Tests\DbalTestCase
...
@@ -31,8 +31,8 @@ class StringTest extends \Doctrine\Tests\DbalTestCase
public
function
testConvertToPHPValue
()
public
function
testConvertToPHPValue
()
{
{
$this
->
assertType
(
"string"
,
$this
->
_type
->
convertToPHPValue
(
"foo"
,
$this
->
_platform
));
$this
->
assert
Internal
Type
(
"string"
,
$this
->
_type
->
convertToPHPValue
(
"foo"
,
$this
->
_platform
));
$this
->
assertType
(
"string"
,
$this
->
_type
->
convertToPHPValue
(
""
,
$this
->
_platform
));
$this
->
assert
Internal
Type
(
"string"
,
$this
->
_type
->
convertToPHPValue
(
""
,
$this
->
_platform
));
}
}
public
function
testNullConversion
()
public
function
testNullConversion
()
...
...
tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php
View file @
168fc6b1
...
@@ -36,7 +36,7 @@ class VarDateTimeTest extends \Doctrine\Tests\DbalTestCase
...
@@ -36,7 +36,7 @@ class VarDateTimeTest extends \Doctrine\Tests\DbalTestCase
{
{
// Birthday of jwage and also birthday of Doctrine. Send him a present ;)
// Birthday of jwage and also birthday of Doctrine. Send him a present ;)
$date
=
$this
->
_type
->
convertToPHPValue
(
'1985-09-01 00:00:00'
,
$this
->
_platform
);
$date
=
$this
->
_type
->
convertToPHPValue
(
'1985-09-01 00:00:00'
,
$this
->
_platform
);
$this
->
assert
Type
(
'DateTime'
,
$date
);
$this
->
assert
InstanceOf
(
'DateTime'
,
$date
);
$this
->
assertEquals
(
'1985-09-01 00:00:00'
,
$date
->
format
(
'Y-m-d H:i:s'
));
$this
->
assertEquals
(
'1985-09-01 00:00:00'
,
$date
->
format
(
'Y-m-d H:i:s'
));
$this
->
assertEquals
(
'000000'
,
$date
->
format
(
'u'
));
$this
->
assertEquals
(
'000000'
,
$date
->
format
(
'u'
));
}
}
...
@@ -50,7 +50,7 @@ class VarDateTimeTest extends \Doctrine\Tests\DbalTestCase
...
@@ -50,7 +50,7 @@ class VarDateTimeTest extends \Doctrine\Tests\DbalTestCase
public
function
testConversionWithMicroseconds
()
public
function
testConversionWithMicroseconds
()
{
{
$date
=
$this
->
_type
->
convertToPHPValue
(
'1985-09-01 00:00:00.123456'
,
$this
->
_platform
);
$date
=
$this
->
_type
->
convertToPHPValue
(
'1985-09-01 00:00:00.123456'
,
$this
->
_platform
);
$this
->
assert
Type
(
'DateTime'
,
$date
);
$this
->
assert
InstanceOf
(
'DateTime'
,
$date
);
$this
->
assertEquals
(
'1985-09-01 00:00:00'
,
$date
->
format
(
'Y-m-d H:i:s'
));
$this
->
assertEquals
(
'1985-09-01 00:00:00'
,
$date
->
format
(
'Y-m-d H:i:s'
));
$this
->
assertEquals
(
'123456'
,
$date
->
format
(
'u'
));
$this
->
assertEquals
(
'123456'
,
$date
->
format
(
'u'
));
}
}
...
...
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