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
2775ab9c
Commit
2775ab9c
authored
Feb 20, 2011
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'DBAL-88' into 2.0.x
parents
8e5a76eb
f1c282e7
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
49 additions
and
78 deletions
+49
-78
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+19
-1
DB2Platform.php
lib/Doctrine/DBAL/Platforms/DB2Platform.php
+1
-12
MsSqlPlatform.php
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
+2
-13
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+6
-12
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+1
-12
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+7
-13
SqlitePlatform.php
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
+1
-11
MockPlatform.php
tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php
+4
-0
MsSqlPlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/MsSqlPlatformTest.php
+1
-1
OraclePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
+1
-1
PostgreSqlPlatformTest.php
.../Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
+1
-1
SqlitePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
+1
-1
DatabasePlatformMock.php
tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php
+4
-0
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
2775ab9c
...
...
@@ -137,7 +137,25 @@ abstract class AbstractPlatform
*
* @param array $field
*/
abstract
public
function
getVarcharTypeDeclarationSQL
(
array
$field
);
public
function
getVarcharTypeDeclarationSQL
(
array
$field
)
{
if
(
!
isset
(
$field
[
'length'
]))
{
$field
[
'length'
]
=
$this
->
getVarcharDefaultLength
();
}
$fixed
=
(
isset
(
$field
[
'fixed'
]))
?
$field
[
'fixed'
]
:
false
;
if
(
$field
[
'length'
]
>
$this
->
getVarcharMaxLength
())
{
return
$this
->
getClobTypeDeclarationSQL
(
$field
);
}
else
{
return
$this
->
getVarcharTypeDeclarationSQLSnippet
(
$field
[
'length'
],
$fixed
);
}
}
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
{
throw
DBALException
::
notSupported
(
'VARCHARs not supported by Platform.'
);
}
/**
* Gets the SQL snippet used to declare a CLOB column type.
...
...
lib/Doctrine/DBAL/Platforms/DB2Platform.php
View file @
2775ab9c
...
...
@@ -48,19 +48,8 @@ class DB2Platform extends AbstractPlatform
*
* @param array $field
*/
p
ublic
function
getVarcharTypeDeclarationSQL
(
array
$fiel
d
)
p
rotected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixe
d
)
{
if
(
!
isset
(
$field
[
'length'
]))
{
if
(
array_key_exists
(
'default'
,
$field
))
{
$field
[
'length'
]
=
$this
->
getVarcharDefaultLength
();
}
else
{
$field
[
'length'
]
=
false
;
}
}
$length
=
(
$field
[
'length'
]
<=
$this
->
getVarcharMaxLength
())
?
$field
[
'length'
]
:
false
;
$fixed
=
(
isset
(
$field
[
'fixed'
]))
?
$field
[
'fixed'
]
:
false
;
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR(255)'
)
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'VARCHAR(255)'
);
}
...
...
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
View file @
2775ab9c
...
...
@@ -516,20 +516,9 @@ class MsSqlPlatform extends AbstractPlatform
}
/** @override */
p
ublic
function
getVarcharTypeDeclarationSQL
(
array
$fiel
d
)
p
rotected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixe
d
)
{
if
(
!
isset
(
$field
[
'length'
]))
{
if
(
array_key_exists
(
'default'
,
$field
))
{
$field
[
'length'
]
=
$this
->
getVarcharDefaultLength
();
}
else
{
$field
[
'length'
]
=
false
;
}
}
$length
=
(
$field
[
'length'
]
<=
$this
->
getVarcharMaxLength
())
?
$field
[
'length'
]
:
false
;
$fixed
=
(
isset
(
$field
[
'fixed'
]))
?
$field
[
'fixed'
]
:
false
;
return
$fixed
?
(
$length
?
'NCHAR('
.
$length
.
')'
:
'CHAR(255)'
)
:
(
$length
?
'NVARCHAR('
.
$length
.
')'
:
'NTEXT'
);
return
$fixed
?
(
$length
?
'NCHAR('
.
$length
.
')'
:
'CHAR(255)'
)
:
(
$length
?
'NVARCHAR('
.
$length
.
')'
:
'NVARCHAR(255)'
);
}
/** @override */
...
...
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
2775ab9c
...
...
@@ -152,19 +152,8 @@ class MySqlPlatform extends AbstractPlatform
*
* @params array $field
*/
p
ublic
function
getVarcharTypeDeclarationSQL
(
array
$fiel
d
)
p
rotected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixe
d
)
{
if
(
!
isset
(
$field
[
'length'
]))
{
if
(
array_key_exists
(
'default'
,
$field
))
{
$field
[
'length'
]
=
$this
->
getVarcharDefaultLength
();
}
else
{
$field
[
'length'
]
=
false
;
}
}
$length
=
(
$field
[
'length'
]
<=
$this
->
getVarcharMaxLength
())
?
$field
[
'length'
]
:
false
;
$fixed
=
(
isset
(
$field
[
'fixed'
]))
?
$field
[
'fixed'
]
:
false
;
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR(255)'
)
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'VARCHAR(255)'
);
}
...
...
@@ -599,4 +588,9 @@ class MySqlPlatform extends AbstractPlatform
'year'
=>
'date'
,
);
}
public
function
getVarcharMaxLength
()
{
return
65535
;
}
}
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
2775ab9c
...
...
@@ -234,19 +234,8 @@ class OraclePlatform extends AbstractPlatform
* @params array $field
* @override
*/
p
ublic
function
getVarcharTypeDeclarationSQL
(
array
$fiel
d
)
p
rotected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixe
d
)
{
if
(
!
isset
(
$field
[
'length'
]))
{
if
(
array_key_exists
(
'default'
,
$field
))
{
$field
[
'length'
]
=
$this
->
getVarcharDefaultLength
();
}
else
{
$field
[
'length'
]
=
false
;
}
}
$length
=
(
$field
[
'length'
]
<=
$this
->
getVarcharMaxLength
())
?
$field
[
'length'
]
:
false
;
$fixed
=
(
isset
(
$field
[
'fixed'
]))
?
$field
[
'fixed'
]
:
false
;
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR(2000)'
)
:
(
$length
?
'VARCHAR2('
.
$length
.
')'
:
'VARCHAR2(4000)'
);
}
...
...
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
2775ab9c
...
...
@@ -591,21 +591,10 @@ class PostgreSqlPlatform extends AbstractPlatform
* @params array $field
* @override
*/
p
ublic
function
getVarcharTypeDeclarationSQL
(
array
$fiel
d
)
p
rotected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixe
d
)
{
if
(
!
isset
(
$field
[
'length'
]))
{
if
(
array_key_exists
(
'default'
,
$field
))
{
$field
[
'length'
]
=
$this
->
getVarcharDefaultLength
();
}
else
{
$field
[
'length'
]
=
false
;
}
}
$length
=
(
$field
[
'length'
]
<=
$this
->
getVarcharMaxLength
())
?
$field
[
'length'
]
:
false
;
$fixed
=
(
isset
(
$field
[
'fixed'
]))
?
$field
[
'fixed'
]
:
false
;
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR(255)'
)
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'
TEXT
'
);
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'
VARCHAR(255)
'
);
}
/** @override */
...
...
@@ -707,4 +696,9 @@ class PostgreSqlPlatform extends AbstractPlatform
'year'
=>
'date'
,
);
}
public
function
getVarcharMaxLength
()
{
return
65535
;
}
}
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
View file @
2775ab9c
...
...
@@ -300,18 +300,8 @@ class SqlitePlatform extends AbstractPlatform
/**
* {@inheritdoc}
*/
p
ublic
function
getVarcharTypeDeclarationSQL
(
array
$fiel
d
)
p
rotected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixe
d
)
{
if
(
!
isset
(
$field
[
'length'
]))
{
if
(
array_key_exists
(
'default'
,
$field
))
{
$field
[
'length'
]
=
$this
->
getVarcharDefaultLength
();
}
else
{
$field
[
'length'
]
=
false
;
}
}
$length
=
(
$field
[
'length'
]
<=
$this
->
getVarcharMaxLength
())
?
$field
[
'length'
]
:
false
;
$fixed
=
(
isset
(
$field
[
'fixed'
]))
?
$field
[
'fixed'
]
:
false
;
return
$fixed
?
(
$length
?
'CHAR('
.
$length
.
')'
:
'CHAR(255)'
)
:
(
$length
?
'VARCHAR('
.
$length
.
')'
:
'TEXT'
);
}
...
...
tests/Doctrine/Tests/DBAL/Mocks/MockPlatform.php
View file @
2775ab9c
...
...
@@ -34,4 +34,8 @@ class MockPlatform extends \Doctrine\DBAL\Platforms\AbstractPlatform
}
protected
function
initializeDoctrineTypeMappings
()
{
}
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
{
}
}
tests/Doctrine/Tests/DBAL/Platforms/MsSqlPlatformTest.php
View file @
2775ab9c
...
...
@@ -105,7 +105,7 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase
'Variable string declaration is not correct'
);
$this
->
assertEquals
(
'N
TEXT
'
,
'N
VARCHAR(255)
'
,
$this
->
_platform
->
getVarcharTypeDeclarationSQL
(
array
()),
'Long string declaration is not correct'
);
...
...
tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php
View file @
2775ab9c
...
...
@@ -127,7 +127,7 @@ class OraclePlatformTest extends AbstractPlatformTestCase
'Variable string declaration is not correct'
);
$this
->
assertEquals
(
'VARCHAR2(
4000
)'
,
'VARCHAR2(
255
)'
,
$this
->
_platform
->
getVarcharTypeDeclarationSQL
(
array
()),
'Long string declaration is not correct'
);
...
...
tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php
View file @
2775ab9c
...
...
@@ -135,7 +135,7 @@ class PostgreSqlPlatformTest extends AbstractPlatformTestCase
'Variable string declaration is not correct'
);
$this
->
assertEquals
(
'
TEXT
'
,
'
VARCHAR(255)
'
,
$this
->
_platform
->
getVarcharTypeDeclarationSQL
(
array
()),
'Long string declaration is not correct'
);
...
...
tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
View file @
2775ab9c
...
...
@@ -89,7 +89,7 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
'Variable string declaration is not correct'
);
$this
->
assertEquals
(
'
TEXT
'
,
'
VARCHAR(255)
'
,
$this
->
_platform
->
getVarcharTypeDeclarationSQL
(
array
()),
'Long string declaration is not correct'
);
...
...
tests/Doctrine/Tests/Mocks/DatabasePlatformMock.php
View file @
2775ab9c
...
...
@@ -84,4 +84,8 @@ class DatabasePlatformMock extends \Doctrine\DBAL\Platforms\AbstractPlatform
}
protected
function
initializeDoctrineTypeMappings
()
{
}
protected
function
getVarcharTypeDeclarationSQLSnippet
(
$length
,
$fixed
)
{
}
}
\ 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