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
390717ed
Commit
390717ed
authored
Jun 06, 2010
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge DBAL-5 into Master
parents
b5f90e09
626a334e
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
257 additions
and
281 deletions
+257
-281
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+53
-2
DB2Platform.php
lib/Doctrine/DBAL/Platforms/DB2Platform.php
+18
-2
MsSqlPlatform.php
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
+5
-2
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+29
-2
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+23
-2
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+41
-2
SqlitePlatform.php
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
+35
-2
DB2SchemaManager.php
lib/Doctrine/DBAL/Schema/DB2SchemaManager.php
+2
-16
MySqlSchemaManager.php
lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
+8
-87
OracleSchemaManager.php
lib/Doctrine/DBAL/Schema/OracleSchemaManager.php
+10
-21
PostgreSqlSchemaManager.php
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
+3
-57
SqliteSchemaManager.php
lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
+2
-84
MockPlatform.php
tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php
+2
-0
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+18
-0
DbalFunctionalTestCase.php
tests/Doctrine/Tests/DbalFunctionalTestCase.php
+6
-2
DatabasePlatformMock.php
tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php
+2
-0
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
390717ed
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
...
@@ -42,6 +40,7 @@ use Doctrine\DBAL\DBALException,
* @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org>
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @todo Remove any unnecessary methods.
*/
abstract
class
AbstractPlatform
...
...
@@ -76,11 +75,63 @@ abstract class AbstractPlatform
*/
const
TRIM_BOTH
=
3
;
/**
* @var array
*/
protected
$doctrineTypeMapping
=
null
;
/**
* Constructor.
*/
public
function
__construct
()
{}
/**
* Register a doctrine type to be used in conjunction with a column type of this platform.
*
* @param string $dbType
* @param string $doctrineType
*/
public
function
registerDoctrineTypeMapping
(
$dbType
,
$doctrineType
)
{
if
(
$this
->
doctrineTypeMapping
===
null
)
{
$this
->
initializeDoctrineTypeMappings
();
}
if
(
!
Types\Type
::
hasType
(
$doctrineType
))
{
throw
DBALException
::
typeNotFound
(
$doctrineType
);
}
$dbType
=
strtolower
(
$dbType
);
$this
->
doctrineTypeMapping
[
$dbType
]
=
$doctrineType
;
}
/**
* Get the Doctrine type that is mapped for the given database column type.
*
* @param string $dbType
* @return string
*/
public
function
getDoctrineTypeMapping
(
$dbType
)
{
if
(
$this
->
doctrineTypeMapping
===
null
)
{
$this
->
initializeDoctrineTypeMappings
();
}
$dbType
=
strtolower
(
$dbType
);
if
(
isset
(
$this
->
doctrineTypeMapping
[
$dbType
]))
{
return
$this
->
doctrineTypeMapping
[
$dbType
];
}
else
{
throw
new
\Doctrine\DBAL\DBALException
(
"Unknown database type "
.
$dbType
.
" requested, "
.
get_class
(
$this
)
.
" may not support it."
);
}
}
/**
* Lazy load Doctrine Type Mappings
*
* @return void
*/
abstract
protected
function
initializeDoctrineTypeMappings
();
/**
* Gets the character used for identifier quoting.
*
...
...
lib/Doctrine/DBAL/Platforms/DB2Platform.php
View file @
390717ed
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
...
@@ -27,6 +25,24 @@ use Doctrine\DBAL\Schema\TableDiff;
class
DB2Platform
extends
AbstractPlatform
{
public
function
initializeDoctrineTypeMappings
()
{
$this
->
doctrineTypeMapping
=
array
(
'smallint'
=>
'smallint'
,
'bigint'
=>
'bigint'
,
'integer'
=>
'integer'
,
'time'
=>
'time'
,
'date'
=>
'date'
,
'varchar'
=>
'string'
,
'character'
=>
'string'
,
'clob'
=>
'text'
,
'decimal'
=>
'decimal'
,
'double'
=>
'decimal'
,
'real'
=>
'decimal'
,
'timestamp'
=>
'datetime'
,
);
}
/**
* Gets the SQL snippet used to declare a VARCHAR column type.
*
...
...
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
View file @
390717ed
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
...
@@ -511,4 +509,9 @@ class MsSqlPlatform extends AbstractPlatform
return
$fromClause
;
}
}
protected
function
initializeDoctrineTypeMappings
()
{
}
}
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
390717ed
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
...
@@ -588,4 +586,33 @@ class MySqlPlatform extends AbstractPlatform
{
return
'LOCK IN SHARE MODE'
;
}
protected
function
initializeDoctrineTypeMappings
()
{
$this
->
doctrineTypeMapping
=
array
(
'tinyint'
=>
'boolean'
,
'smallint'
=>
'smallint'
,
'mediumint'
=>
'integer'
,
'int'
=>
'integer'
,
'integer'
=>
'integer'
,
'bigint'
=>
'bigint'
,
'tinytext'
=>
'text'
,
'mediumtext'
=>
'text'
,
'longtext'
=>
'text'
,
'text'
=>
'text'
,
'varchar'
=>
'string'
,
'string'
=>
'string'
,
'char'
=>
'string'
,
'date'
=>
'date'
,
'datetime'
=>
'datetime'
,
'timestamp'
=>
'datetime'
,
'time'
=>
'time'
,
'float'
=>
'decimal'
,
'double'
=>
'decimal'
,
'real'
=>
'decimal'
,
'decimal'
=>
'decimal'
,
'numeric'
=>
'decimal'
,
'year'
=>
'date'
,
);
}
}
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
390717ed
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
...
@@ -660,4 +658,27 @@ LEFT JOIN all_cons_columns r_cols
{
return
'SELECT 1 FROM DUAL'
;
}
protected
function
initializeDoctrineTypeMappings
()
{
$this
->
doctrineTypeMapping
=
array
(
'integer'
=>
'integer'
,
'number'
=>
'integer'
,
'pls_integer'
=>
'boolean'
,
'binary_integer'
=>
'boolean'
,
'varchar'
=>
'string'
,
'varchar2'
=>
'string'
,
'nvarchar2'
=>
'string'
,
'char'
=>
'string'
,
'nchar'
=>
'string'
,
'date'
=>
'datetime'
,
'timestamp'
=>
'datetime'
,
'float'
=>
'decimal'
,
'long'
=>
'string'
,
'clob'
=>
'text'
,
'nclob'
=>
'text'
,
'rowid'
=>
'string'
,
'urowid'
=>
'string'
);
}
}
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
390717ed
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
...
@@ -642,4 +640,45 @@ class PostgreSqlPlatform extends AbstractPlatform
{
return
'FOR SHARE'
;
}
protected
function
initializeDoctrineTypeMappings
()
{
$this
->
doctrineTypeMapping
=
array
(
'smallint'
=>
'smallint'
,
'int2'
=>
'smallint'
,
'serial'
=>
'integer'
,
'serial4'
=>
'integer'
,
'int'
=>
'integer'
,
'int4'
=>
'integer'
,
'integer'
=>
'integer'
,
'bigserial'
=>
'bigint'
,
'serial8'
=>
'bigint'
,
'bigint'
=>
'bigint'
,
'int8'
=>
'bigint'
,
'bool'
=>
'boolean'
,
'boolean'
=>
'boolean'
,
'text'
=>
'text'
,
'varchar'
=>
'string'
,
'interval'
=>
'string'
,
'_varchar'
=>
'string'
,
'char'
=>
'string'
,
'bpchar'
=>
'string'
,
'date'
=>
'date'
,
'datetime'
=>
'datetime'
,
'timestamp'
=>
'datetime'
,
'timestamptz'
=>
'datetime'
,
'time'
=>
'time'
,
'timetz'
=>
'time'
,
'float'
=>
'decimal'
,
'float4'
=>
'decimal'
,
'float8'
=>
'decimal'
,
'double'
=>
'decimal'
,
'double precision'
=>
'decimal'
,
'real'
=>
'decimal'
,
'decimal'
=>
'decimal'
,
'money'
=>
'decimal'
,
'numeric'
=>
'decimal'
,
'year'
=>
'date'
,
);
}
}
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
View file @
390717ed
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
...
@@ -433,4 +431,39 @@ class SqlitePlatform extends AbstractPlatform
{
return
''
;
}
protected
function
initializeDoctrineTypeMappings
()
{
$this
->
doctrineTypeMapping
=
array
(
'boolean'
=>
'boolean'
,
'tinyint'
=>
'boolean'
,
'smallint'
=>
'smallint'
,
'mediumint'
=>
'integer'
,
'int'
=>
'integer'
,
'integer'
=>
'integer'
,
'serial'
=>
'integer'
,
'bigint'
=>
'bigint'
,
'bigserial'
=>
'bigint'
,
'clob'
=>
'text'
,
'tinytext'
=>
'text'
,
'mediumtext'
=>
'text'
,
'longtext'
=>
'text'
,
'text'
=>
'text'
,
'varchar'
=>
'string'
,
'varchar2'
=>
'string'
,
'nvarchar'
=>
'string'
,
'image'
=>
'string'
,
'ntext'
=>
'string'
,
'char'
=>
'string'
,
'date'
=>
'date'
,
'datetime'
=>
'datetime'
,
'timestamp'
=>
'datetime'
,
'time'
=>
'time'
,
'float'
=>
'decimal'
,
'double'
=>
'decimal'
,
'real'
=>
'decimal'
,
'decimal'
=>
'decimal'
,
'numeric'
=>
'decimal'
,
);
}
}
lib/Doctrine/DBAL/Schema/DB2SchemaManager.php
View file @
390717ed
...
...
@@ -66,41 +66,27 @@ class DB2SchemaManager extends AbstractSchemaManager
$unsigned
=
false
;
$scale
=
false
;
$precision
=
false
;
$type
=
$this
->
_platform
->
getDoctrineTypeMapping
(
$tableColumn
[
'typename'
]);
switch
(
strtolower
(
$tableColumn
[
'typename'
]))
{
case
'smallint'
:
case
'bigint'
:
case
'integer'
:
case
'time'
:
case
'date'
:
$type
=
strtolower
(
$tableColumn
[
'typename'
]);
break
;
case
'varchar'
:
$type
=
'string'
;
$length
=
$tableColumn
[
'length'
];
$fixed
=
false
;
break
;
case
'character'
:
$type
=
'string'
;
$length
=
$tableColumn
[
'length'
];
$fixed
=
true
;
break
;
case
'clob'
:
$type
=
'text'
;
$length
=
$tableColumn
[
'length'
];
break
;
case
'decimal'
:
case
'double'
:
case
'real'
:
$type
=
'decimal'
;
$scale
=
$tableColumn
[
'scale'
];
$precision
=
$tableColumn
[
'length'
];
break
;
case
'timestamp'
:
$type
=
'datetime'
;
break
;
default
:
throw
new
\Doctrine\DBAL\DBALException
(
"Unknown Type: "
.
$tableColumn
[
'typename'
]);
}
$options
=
array
(
...
...
lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
View file @
390717ed
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
...
@@ -89,9 +87,6 @@ class MySqlSchemaManager extends AbstractSchemaManager
{
$dbType
=
strtolower
(
$tableColumn
[
'Type'
]);
$dbType
=
strtok
(
$dbType
,
'(), '
);
if
(
$dbType
==
'national'
)
{
$dbType
=
strtok
(
'(), '
);
}
if
(
isset
(
$tableColumn
[
'length'
]))
{
$length
=
$tableColumn
[
'length'
];
$decimal
=
''
;
...
...
@@ -109,70 +104,10 @@ class MySqlSchemaManager extends AbstractSchemaManager
$scale
=
null
;
$precision
=
null
;
// Map db type to Doctrine mapping type
$type
=
$this
->
_platform
->
getDoctrineTypeMapping
(
$dbType
);
switch
(
$dbType
)
{
case
'tinyint'
:
$type
=
'boolean'
;
$length
=
null
;
break
;
case
'smallint'
:
$type
=
'smallint'
;
$length
=
null
;
break
;
case
'mediumint'
:
$type
=
'integer'
;
$length
=
null
;
break
;
case
'int'
:
case
'integer'
:
$type
=
'integer'
;
$length
=
null
;
break
;
case
'bigint'
:
$type
=
'bigint'
;
$length
=
null
;
break
;
case
'tinytext'
:
case
'mediumtext'
:
case
'longtext'
:
case
'text'
:
$type
=
'text'
;
$fixed
=
false
;
break
;
case
'varchar'
:
$fixed
=
false
;
case
'string'
:
case
'char'
:
$type
=
'string'
;
if
(
$length
==
'1'
)
{
$type
=
'boolean'
;
if
(
preg_match
(
'/^(is|has)/'
,
$tableColumn
[
'name'
]))
{
$type
=
array_reverse
(
$type
);
}
}
else
if
(
strstr
(
$dbType
,
'text'
))
{
$type
=
'text'
;
if
(
$decimal
==
'binary'
)
{
$type
=
'blob'
;
}
}
if
(
$fixed
!==
false
)
{
$fixed
=
true
;
}
break
;
case
'set'
:
$fixed
=
false
;
$type
=
'text'
;
$type
=
'integer'
;
//FIXME:???
break
;
case
'date'
:
$type
=
'date'
;
break
;
case
'datetime'
:
case
'timestamp'
:
$type
=
'datetime'
;
break
;
case
'time'
:
$type
=
'time'
;
$fixed
=
true
;
break
;
case
'float'
:
case
'double'
:
...
...
@@ -184,36 +119,22 @@ class MySqlSchemaManager extends AbstractSchemaManager
$scale
=
$match
[
2
];
$length
=
null
;
}
$type
=
'decimal'
;
break
;
case
'tinyint'
:
case
'smallint'
:
case
'mediumint'
:
case
'int'
:
case
'integer'
:
case
'bigint'
:
case
'tinyblob'
:
case
'mediumblob'
:
case
'longblob'
:
case
'blob'
:
case
'binary'
:
case
'varbinary'
:
$type
=
'blob'
;
$length
=
null
;
break
;
case
'year'
:
$type
=
'integer'
;
$type
=
'date'
;
$length
=
null
;
break
;
case
'geometry'
:
case
'geometrycollection'
:
case
'point'
:
case
'multipoint'
:
case
'linestring'
:
case
'multilinestring'
:
case
'polygon'
:
case
'multipolygon'
:
$type
=
'blob'
;
$length
=
null
;
break
;
default
:
$type
=
'string'
;
$length
=
null
;
}
$length
=
((
int
)
$length
==
0
)
?
null
:
(
int
)
$length
;
...
...
lib/Doctrine/DBAL/Schema/OracleSchemaManager.php
View file @
390717ed
...
...
@@ -111,68 +111,57 @@ class OracleSchemaManager extends AbstractSchemaManager
$precision
=
null
;
$scale
=
null
;
$type
=
$this
->
_platform
->
getDoctrineTypeMapping
(
$dbType
);
switch
(
$dbType
)
{
case
'integer'
:
case
'number'
:
// @todo this sucks for the mapping stuff, is this deterministic maybe?
if
(
$tableColumn
[
'data_scale'
]
>
0
)
{
$type
=
'decimal'
;
$precision
=
$tableColumn
[
'data_precision'
];
$scale
=
$tableColumn
[
'data_scale'
];
}
else
{
$type
=
'integer'
;
if
(
$precision
==
0
&&
$scale
==
1
)
{
$type
=
'boolean'
;
}
else
{
$type
=
'decimal'
;
}
}
$length
=
null
;
break
;
case
'pls_integer'
:
case
'binary_integer'
:
$type
=
'boolean'
;
$length
=
null
;
break
;
case
'varchar'
:
case
'varchar2'
:
case
'nvarchar2'
:
$fixed
=
false
;
break
;
case
'char'
:
case
'nchar'
:
if
(
$length
==
'1'
&&
preg_match
(
'/^(is|has)/'
,
$tableColumn
[
'column_name'
]))
{
$type
=
'boolean'
;
}
else
{
$type
=
'string'
;
}
if
(
$fixed
!==
false
)
{
$fixed
=
true
;
}
$fixed
=
true
;
break
;
case
'date'
:
case
'timestamp'
:
$type
=
'datetime'
;
$length
=
null
;
break
;
case
'float'
:
$precision
=
$tableColumn
[
'data_precision'
];
$scale
=
$tableColumn
[
'data_scale'
];
$type
=
'decimal'
;
$length
=
null
;
break
;
case
'long'
:
$type
=
'string'
;
case
'clob'
:
case
'nclob'
:
$length
=
null
;
$type
=
'text'
;
break
;
case
'blob'
:
case
'raw'
:
case
'long raw'
:
case
'bfile'
:
$type
=
'blob'
;
$length
=
null
;
break
;
case
'rowid'
:
case
'urowid'
:
default
:
$type
=
'string'
;
$length
=
null
;
}
...
...
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
View file @
390717ed
...
...
@@ -199,11 +199,11 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$dbType
=
strtolower
(
$tableColumn
[
'type'
]);
$type
=
$this
->
_platform
->
getDoctrineTypeMapping
(
$dbType
);
$autoincrement
=
false
;
switch
(
$dbType
)
{
case
'smallint'
:
case
'int2'
:
$type
=
'smallint'
;
$length
=
null
;
break
;
case
'serial'
:
...
...
@@ -213,7 +213,6 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
case
'int'
:
case
'int4'
:
case
'integer'
:
$type
=
'integer'
;
$length
=
null
;
break
;
case
'bigserial'
:
...
...
@@ -222,52 +221,23 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
// break missing intentionally
case
'bigint'
:
case
'int8'
:
$type
=
'bigint'
;
$length
=
null
;
break
;
case
'bool'
:
case
'boolean'
:
$type
=
'boolean'
;
$length
=
null
;
break
;
case
'text'
:
$fixed
=
false
;
$type
=
'text'
;
break
;
case
'varchar'
:
case
'interval'
:
case
'_varchar'
:
$fixed
=
false
;
case
'tsvector'
:
case
'unknown'
:
break
;
case
'char'
:
case
'bpchar'
:
$type
=
'string'
;
if
(
$length
==
'1'
)
{
if
(
preg_match
(
'/^(is|has)/'
,
$tableColumn
[
'name'
]))
{
$type
=
'boolean'
;
}
}
elseif
(
strstr
(
$dbType
,
'text'
))
{
$type
=
'text'
;
}
if
(
$fixed
!==
false
)
{
$fixed
=
true
;
}
break
;
case
'date'
:
$type
=
'date'
;
$length
=
null
;
break
;
case
'datetime'
:
case
'timestamp'
:
case
'timetz'
:
case
'timestamptz'
:
$type
=
'datetime'
;
$length
=
null
;
break
;
case
'time'
:
$type
=
'time'
;
$length
=
null
;
$fixed
=
true
;
break
;
case
'float'
:
case
'float4'
:
...
...
@@ -283,34 +253,10 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
$scale
=
$match
[
2
];
$length
=
null
;
}
$type
=
'decimal'
;
break
;
case
'tinyblob'
:
case
'mediumblob'
:
case
'longblob'
:
case
'blob'
:
case
'bytea'
:
case
'geometry'
:
case
'geometrycollection'
:
case
'point'
:
case
'multipoint'
:
case
'linestring'
:
case
'multilinestring'
:
case
'polygon'
:
case
'multipolygon'
:
$type
=
'blob'
;
$length
=
null
;
break
;
case
'oid'
:
$type
=
'blob'
;
$length
=
null
;
break
;
case
'year'
:
$type
=
'date'
;
$length
=
null
;
break
;
default
:
$type
=
'string'
;
}
$options
=
array
(
...
...
lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
View file @
390717ed
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
...
@@ -131,11 +129,10 @@ class SqliteSchemaManager extends AbstractSchemaManager
}
$dbType
=
strtolower
(
$tableColumn
[
'type'
]);
$length
=
isset
(
$tableColumn
[
'length'
])
?
$tableColumn
[
'length'
]
:
null
;
$unsigned
=
(
boolean
)
isset
(
$tableColumn
[
'unsigned'
])
?
$tableColumn
[
'unsigned'
]
:
false
;
$fixed
=
false
;
$type
=
null
;
$type
=
$this
->
_platform
->
getDoctrineTypeMapping
(
$dbType
)
;
$default
=
$tableColumn
[
'dflt_value'
];
if
(
$default
==
'NULL'
)
{
$default
=
null
;
...
...
@@ -150,72 +147,8 @@ class SqliteSchemaManager extends AbstractSchemaManager
$scale
=
null
;
switch
(
$dbType
)
{
case
'boolean'
:
$type
=
'boolean'
;
break
;
case
'tinyint'
:
$type
=
'boolean'
;
$length
=
null
;
break
;
case
'smallint'
:
$type
=
'smallint'
;
$length
=
null
;
break
;
case
'mediumint'
:
case
'int'
:
case
'integer'
:
case
'serial'
:
$type
=
'integer'
;
$length
=
null
;
break
;
case
'bigint'
:
case
'bigserial'
:
$type
=
'bigint'
;
$length
=
null
;
break
;
case
'clob'
:
$fixed
=
false
;
$type
=
'text'
;
break
;
case
'tinytext'
:
case
'mediumtext'
:
case
'longtext'
:
case
'text'
:
$type
=
'text'
;
break
;
case
'varchar'
:
case
'varchar2'
:
case
'nvarchar'
:
case
'ntext'
:
case
'image'
:
case
'nchar'
:
$fixed
=
false
;
case
'char'
:
$type
=
'string'
;
if
(
$length
==
'1'
)
{
$type
=
'boolean'
;
if
(
preg_match
(
'/^(is|has)/'
,
$tableColumn
[
'name'
]))
{
$type
=
array_reverse
(
$type
);
}
}
elseif
(
strstr
(
$dbType
,
'text'
))
{
$type
=
'clob'
;
}
if
(
$fixed
!==
false
)
{
$fixed
=
true
;
}
break
;
case
'date'
:
$type
=
'date'
;
$length
=
null
;
break
;
case
'datetime'
:
case
'timestamp'
:
$type
=
'datetime'
;
$length
=
null
;
break
;
case
'time'
:
$type
=
'time'
;
$length
=
null
;
$fixed
=
true
;
break
;
case
'float'
:
case
'double'
:
...
...
@@ -223,23 +156,8 @@ class SqliteSchemaManager extends AbstractSchemaManager
case
'decimal'
:
case
'numeric'
:
list
(
$precision
,
$scale
)
=
array_map
(
'trim'
,
explode
(
', '
,
$tableColumn
[
'length'
]));
$type
=
'decimal'
;
$length
=
null
;
break
;
case
'tinyblob'
:
case
'mediumblob'
:
case
'longblob'
:
case
'blob'
:
$type
=
'blob'
;
$length
=
null
;
break
;
case
'year'
:
$type
=
'date'
;
$length
=
null
;
break
;
default
:
$type
=
'string'
;
$length
=
null
;
}
$options
=
array
(
...
...
tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php
View file @
390717ed
...
...
@@ -32,4 +32,6 @@ class MockPlatform extends \Doctrine\DBAL\Platforms\AbstractPlatform
{
return
'mock'
;
}
protected
function
initializeDoctrineTypeMappings
()
{
}
}
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
390717ed
...
...
@@ -16,6 +16,24 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this
->
_platform
=
$this
->
createPlatform
();
}
public
function
testGetUnknownDoctrineMappingType
()
{
$this
->
setExpectedException
(
'Doctrine\DBAL\DBALException'
);
$this
->
_platform
->
getDoctrineTypeMapping
(
'foobar'
);
}
public
function
testRegisterDoctrineMappingType
()
{
$this
->
_platform
->
registerDoctrineTypeMapping
(
'foo'
,
'integer'
);
$this
->
assertEquals
(
'integer'
,
$this
->
_platform
->
getDoctrineTypeMapping
(
'foo'
));
}
public
function
testRegisterUnknownDoctrineMappingType
()
{
$this
->
setExpectedException
(
'Doctrine\DBAL\DBALException'
);
$this
->
_platform
->
registerDoctrineTypeMapping
(
'foo'
,
'bar'
);
}
public
function
testCreateWithNoColumns
()
{
$table
=
new
\Doctrine\DBAL\Schema\Table
(
'test'
);
...
...
tests/Doctrine/Tests/DbalFunctionalTestCase.php
View file @
390717ed
...
...
@@ -4,7 +4,11 @@ namespace Doctrine\Tests;
class
DbalFunctionalTestCase
extends
DbalTestCase
{
/* Shared connection when a TestCase is run alone (outside of it's functional suite) */
/**
* Shared connection when a TestCase is run alone (outside of it's functional suite)
*
* @var Doctrine\DBAL\Connection
*/
private
static
$_sharedConn
;
/**
...
...
@@ -35,4 +39,4 @@ class DbalFunctionalTestCase extends DbalTestCase
$this
->
_conn
=
self
::
$_sharedConn
;
}
}
}
\ No newline at end of file
}
tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php
View file @
390717ed
...
...
@@ -82,4 +82,6 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform
{
return
'mock'
;
}
protected
function
initializeDoctrineTypeMappings
()
{
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment