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
4dd96a7d
Commit
4dd96a7d
authored
Jan 16, 2012
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix SQL Platform/Schema Manager problems.
parent
624ca843
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
69 additions
and
41 deletions
+69
-41
UPGRADE
UPGRADE
+1
-1
Driver.php
lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php
+1
-1
SQLServer2005Platform.php
lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php
+6
-25
SQLServer2008Platform.php
lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php
+27
-3
SQLServerPlatform.php
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
+17
-3
SQLServerSchemaManager.php
lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php
+1
-1
SQLServerSchemaManagerTest.php
...sts/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php
+4
-1
SchemaManagerFunctionalTestCase.php
...BAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
+12
-6
No files found.
UPGRADE
View file @
4dd96a7d
...
@@ -22,7 +22,7 @@ to SQLServerSchemaManager.
...
@@ -22,7 +22,7 @@ to SQLServerSchemaManager.
## Cleanup SQLServer Platform version mess
## Cleanup SQLServer Platform version mess
DBAL 2.1 and before were actually only compatible to SQL Server 2008, not earlier versions.
DBAL 2.1 and before were actually only compatible to SQL Server 2008, not earlier versions.
Still other parts of the platform did use old features instead of newly introced datatypes
Still other parts of the platform did use old features instead of newly intro
du
ced datatypes
in SQL Server 2005. Starting with DBAL 2.2 you can pick the Doctrine abstraction exactly
in SQL Server 2005. Starting with DBAL 2.2 you can pick the Doctrine abstraction exactly
matching your SQL Server version.
matching your SQL Server version.
...
...
lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php
View file @
4dd96a7d
...
@@ -63,7 +63,7 @@ class Driver implements \Doctrine\DBAL\Driver
...
@@ -63,7 +63,7 @@ class Driver implements \Doctrine\DBAL\Driver
public
function
getDatabasePlatform
()
public
function
getDatabasePlatform
()
{
{
return
new
\Doctrine\DBAL\Platforms\SQLServer200
5
Platform
();
return
new
\Doctrine\DBAL\Platforms\SQLServer200
8
Platform
();
}
}
public
function
getSchemaManager
(
\Doctrine\DBAL\Connection
$conn
)
public
function
getSchemaManager
(
\Doctrine\DBAL\Connection
$conn
)
...
...
lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php
View file @
4dd96a7d
...
@@ -35,37 +35,18 @@ namespace Doctrine\DBAL\Platforms;
...
@@ -35,37 +35,18 @@ namespace Doctrine\DBAL\Platforms;
*/
*/
class
SQLServer2005Platform
extends
SQLServerPlatform
class
SQLServer2005Platform
extends
SQLServerPlatform
{
{
public
function
getDateTimeTypeDeclarationSQL
(
array
$fieldDeclaration
)
{
// 3 - microseconds precision length
// http://msdn.microsoft.com/en-us/library/ms187819.aspx
return
'DATETIME'
;
}
/**
/**
* @override
* @override
*/
*/
public
function
getDateTimeFormatString
()
public
function
supportsLimitOffset
()
{
return
'Y-m-d H:i:s.000'
;
}
/**
*/
protected
function
initializeDoctrineTypeMappings
()
{
{
parent
::
initializeDoctrineTypeMappings
();
return
true
;
$this
->
doctrineTypeMapping
=
array
(
);
}
}
/**
/** @override */
* @override
public
function
getClobTypeDeclarationSQL
(
array
$field
)
*/
public
function
supportsLimitOffset
()
{
{
return
true
;
return
'VARCHAR(MAX)'
;
}
}
}
}
lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php
View file @
4dd96a7d
...
@@ -53,14 +53,38 @@ class SQLServer2008Platform extends SQLServer2005Platform
...
@@ -53,14 +53,38 @@ class SQLServer2008Platform extends SQLServer2005Platform
return
'TIME(0)'
;
return
'TIME(0)'
;
}
}
/**
* @override
*/
public
function
getDateTimeFormatString
()
{
return
'Y-m-d H:i:s.u'
;
}
/**
* @override
*/
public
function
getDateFormatString
()
{
return
'Y-m-d'
;
}
/**
* @override
*/
public
function
getTimeFormatString
()
{
return
'H:i:s'
;
}
/**
/**
* Adding Datetime2 Type
* Adding Datetime2 Type
*/
*/
protected
function
initializeDoctrineTypeMappings
()
protected
function
initializeDoctrineTypeMappings
()
{
{
parent
::
initializeDoctrineTypeMappings
();
parent
::
initializeDoctrineTypeMappings
();
$this
->
doctrineTypeMapping
=
array
(
$this
->
doctrineTypeMapping
[
'datetime2'
]
=
'datetime'
;
'datetime2'
=>
'datetime'
,
$this
->
doctrineTypeMapping
[
'date'
]
=
'date'
;
)
;
$this
->
doctrineTypeMapping
[
'time'
]
=
'time'
;
}
}
}
}
lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
View file @
4dd96a7d
...
@@ -710,7 +710,23 @@ class SQLServerPlatform extends AbstractPlatform
...
@@ -710,7 +710,23 @@ class SQLServerPlatform extends AbstractPlatform
*/
*/
public
function
getDateTimeFormatString
()
public
function
getDateTimeFormatString
()
{
{
return
'Y-m-d H:i:s.u'
;
return
'Y-m-d H:i:s.000'
;
}
/**
* @override
*/
public
function
getDateFormatString
()
{
return
'Y-m-d H:i:s.000'
;
}
/**
* @override
*/
public
function
getTimeFormatString
()
{
return
'Y-m-d H:i:s.000'
;
}
}
/**
/**
...
@@ -750,11 +766,9 @@ class SQLServerPlatform extends AbstractPlatform
...
@@ -750,11 +766,9 @@ class SQLServerPlatform extends AbstractPlatform
'real'
=>
'float'
,
'real'
=>
'float'
,
'double'
=>
'float'
,
'double'
=>
'float'
,
'double precision'
=>
'float'
,
'double precision'
=>
'float'
,
'date'
=>
'date'
,
'datetimeoffset'
=>
'datetimetz'
,
'datetimeoffset'
=>
'datetimetz'
,
'smalldatetime'
=>
'datetime'
,
'smalldatetime'
=>
'datetime'
,
'datetime'
=>
'datetime'
,
'datetime'
=>
'datetime'
,
'time'
=>
'time'
,
'char'
=>
'string'
,
'char'
=>
'string'
,
'varchar'
=>
'string'
,
'varchar'
=>
'string'
,
'text'
=>
'text'
,
'text'
=>
'text'
,
...
...
lib/Doctrine/DBAL/SQLServerSchemaManager.php
→
lib/Doctrine/DBAL/S
chema/S
QLServerSchemaManager.php
View file @
4dd96a7d
...
@@ -55,7 +55,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
...
@@ -55,7 +55,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
$default
=
$tableColumn
[
'COLUMN_DEF'
];
$default
=
$tableColumn
[
'COLUMN_DEF'
];
while
(
$default
!=
(
$default2
=
preg_replace
(
"/^\((.*)\)$/"
,
'$1'
,
$default
)))
{
while
(
$default
!=
(
$default2
=
preg_replace
(
"/^\((.*)\)$/"
,
'$1'
,
$default
)))
{
$default
=
$default2
;
$default
=
trim
(
$default2
,
"'"
)
;
}
}
$length
=
(
int
)
$tableColumn
[
'LENGTH'
];
$length
=
(
int
)
$tableColumn
[
'LENGTH'
];
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php
View file @
4dd96a7d
...
@@ -6,5 +6,8 @@ use Doctrine\DBAL\Schema;
...
@@ -6,5 +6,8 @@ use Doctrine\DBAL\Schema;
class
SQLServerSchemaManagerTest
extends
SchemaManagerFunctionalTestCase
class
SQLServerSchemaManagerTest
extends
SchemaManagerFunctionalTestCase
{
{
protected
function
getPlatformName
()
{
return
"mssql"
;
}
}
}
tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
View file @
4dd96a7d
...
@@ -17,17 +17,23 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
...
@@ -17,17 +17,23 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
*/
*/
protected
$_sm
;
protected
$_sm
;
protected
function
setUp
()
protected
function
getPlatformName
()
{
{
parent
::
setUp
();
$class
=
get_class
(
$this
);
$class
=
get_class
(
$this
);
$e
=
explode
(
'\\'
,
$class
);
$e
=
explode
(
'\\'
,
$class
);
$testClass
=
end
(
$e
);
$testClass
=
end
(
$e
);
$dbms
=
strtolower
(
str_replace
(
'SchemaManagerTest'
,
null
,
$testClass
));
$dbms
=
strtolower
(
str_replace
(
'SchemaManagerTest'
,
null
,
$testClass
));
return
$dbms
;
}
protected
function
setUp
()
{
parent
::
setUp
();
$dbms
=
$this
->
getPlatformName
();
if
(
$this
->
_conn
->
getDatabasePlatform
()
->
getName
()
!==
$dbms
)
{
if
(
$this
->
_conn
->
getDatabasePlatform
()
->
getName
()
!==
$dbms
)
{
$this
->
markTestSkipped
(
'The '
.
$testClass
.
' requires the use of '
.
$dbms
);
$this
->
markTestSkipped
(
get_class
(
$this
)
.
' requires the use of '
.
$dbms
);
}
}
$this
->
_sm
=
$this
->
_conn
->
getSchemaManager
();
$this
->
_sm
=
$this
->
_conn
->
getSchemaManager
();
...
...
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