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
e659afa1
Commit
e659afa1
authored
Jan 10, 2014
by
Steve Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix integer type declaration SQL on SQLite
parent
2790ee79
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
152 additions
and
15 deletions
+152
-15
SqlitePlatform.php
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
+6
-6
DBAL752Test.php
tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php
+26
-9
SqlitePlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
+120
-0
No files found.
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
View file @
e659afa1
...
@@ -225,7 +225,7 @@ class SqlitePlatform extends AbstractPlatform
...
@@ -225,7 +225,7 @@ class SqlitePlatform extends AbstractPlatform
*/
*/
public
function
getIntegerTypeDeclarationSQL
(
array
$field
)
public
function
getIntegerTypeDeclarationSQL
(
array
$field
)
{
{
return
$this
->
_getCommonIntegerTypeDeclarationSQL
(
$field
);
return
'INTEGER'
.
$this
->
_getCommonIntegerTypeDeclarationSQL
(
$field
);
}
}
/**
/**
...
@@ -233,7 +233,7 @@ class SqlitePlatform extends AbstractPlatform
...
@@ -233,7 +233,7 @@ class SqlitePlatform extends AbstractPlatform
*/
*/
public
function
getBigIntTypeDeclarationSQL
(
array
$field
)
public
function
getBigIntTypeDeclarationSQL
(
array
$field
)
{
{
return
$this
->
_getCommonIntegerTypeDeclarationSQL
(
$field
);
return
'BIGINT'
.
$this
->
_getCommonIntegerTypeDeclarationSQL
(
$field
);
}
}
/**
/**
...
@@ -241,7 +241,7 @@ class SqlitePlatform extends AbstractPlatform
...
@@ -241,7 +241,7 @@ class SqlitePlatform extends AbstractPlatform
*/
*/
public
function
getTinyIntTypeDeclarationSql
(
array
$field
)
public
function
getTinyIntTypeDeclarationSql
(
array
$field
)
{
{
return
$this
->
_getCommonIntegerTypeDeclarationSQL
(
$field
);
return
'TINYINT'
.
$this
->
_getCommonIntegerTypeDeclarationSQL
(
$field
);
}
}
/**
/**
...
@@ -249,7 +249,7 @@ class SqlitePlatform extends AbstractPlatform
...
@@ -249,7 +249,7 @@ class SqlitePlatform extends AbstractPlatform
*/
*/
public
function
getSmallIntTypeDeclarationSQL
(
array
$field
)
public
function
getSmallIntTypeDeclarationSQL
(
array
$field
)
{
{
return
$this
->
_getCommonIntegerTypeDeclarationSQL
(
$field
);
return
'SMALLINT'
.
$this
->
_getCommonIntegerTypeDeclarationSQL
(
$field
);
}
}
/**
/**
...
@@ -257,7 +257,7 @@ class SqlitePlatform extends AbstractPlatform
...
@@ -257,7 +257,7 @@ class SqlitePlatform extends AbstractPlatform
*/
*/
public
function
getMediumIntTypeDeclarationSql
(
array
$field
)
public
function
getMediumIntTypeDeclarationSql
(
array
$field
)
{
{
return
$this
->
_getCommonIntegerTypeDeclarationSQL
(
$field
);
return
'MEDIUMINT'
.
$this
->
_getCommonIntegerTypeDeclarationSQL
(
$field
);
}
}
/**
/**
...
@@ -289,7 +289,7 @@ class SqlitePlatform extends AbstractPlatform
...
@@ -289,7 +289,7 @@ class SqlitePlatform extends AbstractPlatform
*/
*/
protected
function
_getCommonIntegerTypeDeclarationSQL
(
array
$columnDef
)
protected
function
_getCommonIntegerTypeDeclarationSQL
(
array
$columnDef
)
{
{
return
'INTEGER
'
;
return
!
empty
(
$columnDef
[
'unsigned'
])
?
' UNSIGNED'
:
'
'
;
}
}
/**
/**
...
...
tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php
View file @
e659afa1
...
@@ -24,9 +24,14 @@ class DBAL752Test extends \Doctrine\Tests\DbalFunctionalTestCase
...
@@ -24,9 +24,14 @@ class DBAL752Test extends \Doctrine\Tests\DbalFunctionalTestCase
{
{
$this
->
_conn
->
exec
(
<<<SQL
$this
->
_conn
->
exec
(
<<<SQL
CREATE TABLE dbal752_unsigneds (
CREATE TABLE dbal752_unsigneds (
id BIGINT UNSIGNED,
small SMALLINT,
flag SMALLINT UNSIGNED,
small_unsigned SMALLINT UNSIGNED,
masks INTEGER UNSIGNED
medium MEDIUMINT,
medium_unsigned MEDIUMINT UNSIGNED,
"integer" INTEGER,
integer_unsigned INTEGER UNSIGNED,
big BIGINT,
big_unsigned BIGINT UNSIGNED
);
);
SQL
SQL
);
);
...
@@ -35,11 +40,23 @@ SQL
...
@@ -35,11 +40,23 @@ SQL
$fetchedTable
=
$schemaManager
->
listTableDetails
(
'dbal752_unsigneds'
);
$fetchedTable
=
$schemaManager
->
listTableDetails
(
'dbal752_unsigneds'
);
$this
->
assertEquals
(
'bigint'
,
$fetchedTable
->
getColumn
(
'id'
)
->
getType
()
->
getName
());
$this
->
assertEquals
(
'smallint'
,
$fetchedTable
->
getColumn
(
'small'
)
->
getType
()
->
getName
());
$this
->
assertEquals
(
'smallint'
,
$fetchedTable
->
getColumn
(
'flag'
)
->
getType
()
->
getName
());
$this
->
assertEquals
(
'smallint'
,
$fetchedTable
->
getColumn
(
'small_unsigned'
)
->
getType
()
->
getName
());
$this
->
assertEquals
(
'integer'
,
$fetchedTable
->
getColumn
(
'masks'
)
->
getType
()
->
getName
());
$this
->
assertEquals
(
'integer'
,
$fetchedTable
->
getColumn
(
'medium'
)
->
getType
()
->
getName
());
$this
->
assertTrue
(
$fetchedTable
->
getColumn
(
'id'
)
->
getUnsigned
());
$this
->
assertEquals
(
'integer'
,
$fetchedTable
->
getColumn
(
'medium_unsigned'
)
->
getType
()
->
getName
());
$this
->
assertTrue
(
$fetchedTable
->
getColumn
(
'flag'
)
->
getUnsigned
());
$this
->
assertEquals
(
'integer'
,
$fetchedTable
->
getColumn
(
'integer'
)
->
getType
()
->
getName
());
$this
->
assertTrue
(
$fetchedTable
->
getColumn
(
'masks'
)
->
getUnsigned
());
$this
->
assertEquals
(
'integer'
,
$fetchedTable
->
getColumn
(
'integer_unsigned'
)
->
getType
()
->
getName
());
$this
->
assertEquals
(
'bigint'
,
$fetchedTable
->
getColumn
(
'big'
)
->
getType
()
->
getName
());
$this
->
assertEquals
(
'bigint'
,
$fetchedTable
->
getColumn
(
'big_unsigned'
)
->
getType
()
->
getName
());
$this
->
assertTrue
(
$fetchedTable
->
getColumn
(
'small_unsigned'
)
->
getUnsigned
());
$this
->
assertTrue
(
$fetchedTable
->
getColumn
(
'medium_unsigned'
)
->
getUnsigned
());
$this
->
assertTrue
(
$fetchedTable
->
getColumn
(
'integer_unsigned'
)
->
getUnsigned
());
$this
->
assertTrue
(
$fetchedTable
->
getColumn
(
'big_unsigned'
)
->
getUnsigned
());
$this
->
assertFalse
(
$fetchedTable
->
getColumn
(
'small'
)
->
getUnsigned
());
$this
->
assertFalse
(
$fetchedTable
->
getColumn
(
'medium'
)
->
getUnsigned
());
$this
->
assertFalse
(
$fetchedTable
->
getColumn
(
'integer'
)
->
getUnsigned
());
$this
->
assertFalse
(
$fetchedTable
->
getColumn
(
'big'
)
->
getUnsigned
());
}
}
}
}
tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php
View file @
e659afa1
...
@@ -63,6 +63,90 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
...
@@ -63,6 +63,90 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
$this
->
assertTrue
(
$this
->
_platform
->
prefersIdentityColumns
());
$this
->
assertTrue
(
$this
->
_platform
->
prefersIdentityColumns
());
}
}
/**
* @group DBAL-752
*/
public
function
testGeneratesTypeDeclarationForTinyIntegers
()
{
$this
->
assertEquals
(
'TINYINT'
,
$this
->
_platform
->
getTinyIntTypeDeclarationSQL
(
array
())
);
$this
->
assertEquals
(
'TINYINT'
,
$this
->
_platform
->
getTinyIntTypeDeclarationSQL
(
array
(
'autoincrement'
=>
true
))
);
$this
->
assertEquals
(
'TINYINT'
,
$this
->
_platform
->
getTinyIntTypeDeclarationSQL
(
array
(
'autoincrement'
=>
true
,
'primary'
=>
true
))
);
$this
->
assertEquals
(
'TINYINT'
,
$this
->
_platform
->
getTinyIntTypeDeclarationSQL
(
array
(
'unsigned'
=>
false
))
);
$this
->
assertEquals
(
'TINYINT UNSIGNED'
,
$this
->
_platform
->
getTinyIntTypeDeclarationSQL
(
array
(
'unsigned'
=>
true
))
);
}
/**
* @group DBAL-752
*/
public
function
testGeneratesTypeDeclarationForSmallIntegers
()
{
$this
->
assertEquals
(
'SMALLINT'
,
$this
->
_platform
->
getSmallIntTypeDeclarationSQL
(
array
())
);
$this
->
assertEquals
(
'SMALLINT'
,
$this
->
_platform
->
getSmallIntTypeDeclarationSQL
(
array
(
'autoincrement'
=>
true
))
);
$this
->
assertEquals
(
'SMALLINT'
,
$this
->
_platform
->
getSmallIntTypeDeclarationSQL
(
array
(
'autoincrement'
=>
true
,
'primary'
=>
true
))
);
$this
->
assertEquals
(
'SMALLINT'
,
$this
->
_platform
->
getSmallIntTypeDeclarationSQL
(
array
(
'unsigned'
=>
false
))
);
$this
->
assertEquals
(
'SMALLINT UNSIGNED'
,
$this
->
_platform
->
getSmallIntTypeDeclarationSQL
(
array
(
'unsigned'
=>
true
))
);
}
/**
* @group DBAL-752
*/
public
function
testGeneratesTypeDeclarationForMediumIntegers
()
{
$this
->
assertEquals
(
'MEDIUMINT'
,
$this
->
_platform
->
getMediumIntTypeDeclarationSQL
(
array
())
);
$this
->
assertEquals
(
'MEDIUMINT'
,
$this
->
_platform
->
getMediumIntTypeDeclarationSQL
(
array
(
'autoincrement'
=>
true
))
);
$this
->
assertEquals
(
'MEDIUMINT'
,
$this
->
_platform
->
getMediumIntTypeDeclarationSQL
(
array
(
'autoincrement'
=>
true
,
'primary'
=>
true
))
);
$this
->
assertEquals
(
'MEDIUMINT'
,
$this
->
_platform
->
getMediumIntTypeDeclarationSQL
(
array
(
'unsigned'
=>
false
))
);
$this
->
assertEquals
(
'MEDIUMINT UNSIGNED'
,
$this
->
_platform
->
getMediumIntTypeDeclarationSQL
(
array
(
'unsigned'
=>
true
))
);
}
public
function
testGeneratesTypeDeclarationForIntegers
()
public
function
testGeneratesTypeDeclarationForIntegers
()
{
{
$this
->
assertEquals
(
$this
->
assertEquals
(
...
@@ -78,6 +162,42 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
...
@@ -78,6 +162,42 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
$this
->
_platform
->
getIntegerTypeDeclarationSQL
(
$this
->
_platform
->
getIntegerTypeDeclarationSQL
(
array
(
'autoincrement'
=>
true
,
'primary'
=>
true
))
array
(
'autoincrement'
=>
true
,
'primary'
=>
true
))
);
);
$this
->
assertEquals
(
'INTEGER'
,
$this
->
_platform
->
getIntegerTypeDeclarationSQL
(
array
(
'unsigned'
=>
false
))
);
$this
->
assertEquals
(
'INTEGER UNSIGNED'
,
$this
->
_platform
->
getIntegerTypeDeclarationSQL
(
array
(
'unsigned'
=>
true
))
);
}
/**
* @group DBAL-752
*/
public
function
testGeneratesTypeDeclarationForBigIntegers
()
{
$this
->
assertEquals
(
'BIGINT'
,
$this
->
_platform
->
getBigIntTypeDeclarationSQL
(
array
())
);
$this
->
assertEquals
(
'BIGINT'
,
$this
->
_platform
->
getBigIntTypeDeclarationSQL
(
array
(
'autoincrement'
=>
true
))
);
$this
->
assertEquals
(
'BIGINT'
,
$this
->
_platform
->
getBigIntTypeDeclarationSQL
(
array
(
'autoincrement'
=>
true
,
'primary'
=>
true
))
);
$this
->
assertEquals
(
'BIGINT'
,
$this
->
_platform
->
getBigIntTypeDeclarationSQL
(
array
(
'unsigned'
=>
false
))
);
$this
->
assertEquals
(
'BIGINT UNSIGNED'
,
$this
->
_platform
->
getBigIntTypeDeclarationSQL
(
array
(
'unsigned'
=>
true
))
);
}
}
public
function
testGeneratesTypeDeclarationForStrings
()
public
function
testGeneratesTypeDeclarationForStrings
()
...
...
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