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
693953dd
Commit
693953dd
authored
May 14, 2011
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/2.0.x' into 2.0.x
parents
2241ba2a
6873b7e7
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
102 additions
and
15 deletions
+102
-15
build.xml
build.xml
+2
-0
Driver.php
lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php
+3
-0
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+30
-3
DB2Platform.php
lib/Doctrine/DBAL/Platforms/DB2Platform.php
+1
-1
MsSqlPlatform.php
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
+2
-2
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+1
-1
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+1
-1
Column.php
lib/Doctrine/DBAL/Schema/Column.php
+9
-1
Comparator.php
lib/Doctrine/DBAL/Schema/Comparator.php
+6
-3
SqliteSchemaManager.php
lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
+3
-1
Version.php
lib/Doctrine/DBAL/Version.php
+1
-1
doctrine-common
lib/vendor/doctrine-common
+1
-1
ComparatorTest.php
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
+42
-0
No files found.
build.xml
View file @
693953dd
...
...
@@ -89,6 +89,8 @@
<copy
todir=
"${build.dir}/doctrine-dbal/bin"
>
<fileset
refid=
"bin-scripts"
/>
</copy>
<delete
dir=
"${build.dir}/doctrine-dbal/Doctrine/Symfony/Component/Yaml/.git"
includeemptydirs=
"true"
/>
<delete
dir=
"${build.dir}/doctrine-dbal/Doctrine/Symfony/Component/Console/.git"
includeemptydirs=
"true"
/>
<exec
command=
"sed 's/${version}-DEV/${version}/' ${build.dir}/doctrine-dbal/Doctrine/DBAL/Version.php > ${build.dir}/doctrine-dbal/Doctrine/DBAL/Version2.php"
passthru=
"true"
/>
<exec
command=
"mv ${build.dir}/doctrine-dbal/Doctrine/DBAL/Version2.php ${build.dir}/doctrine-dbal/Doctrine/DBAL/Version.php"
passthru=
"true"
/>
</target>
...
...
lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php
View file @
693953dd
...
...
@@ -68,6 +68,9 @@ class Driver implements \Doctrine\DBAL\Driver
if
(
isset
(
$params
[
'unix_socket'
]))
{
$dsn
.=
'unix_socket='
.
$params
[
'unix_socket'
]
.
';'
;
}
if
(
isset
(
$params
[
'charset'
]))
{
$dsn
.=
'charset='
.
$params
[
'charset'
]
.
';'
;
}
return
$dsn
;
}
...
...
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
693953dd
...
...
@@ -1960,13 +1960,40 @@ abstract class AbstractPlatform
return
'H:i:s'
;
}
public
function
modifyLimitQuery
(
$query
,
$limit
,
$offset
=
null
)
/**
* Modify limit query
*
* @param string $query
* @param int $limit
* @param int $offset
* @return string
*/
final
public
function
modifyLimitQuery
(
$query
,
$limit
,
$offset
=
null
)
{
if
(
$limit
!==
null
)
{
$limit
=
(
int
)
$limit
;
}
if
(
$offset
!==
null
)
{
$offset
=
(
int
)
$offset
;
}
return
$this
->
doModifyLimitQuery
(
$query
,
$limit
,
$offset
);
}
/**
* @param string $query
* @param int $limit
* @param int $offset
* @return string
*/
protected
function
doModifyLimitQuery
(
$query
,
$limit
,
$offset
)
{
if
(
!
is_null
(
$limit
)
)
{
if
(
$limit
!==
null
)
{
$query
.=
' LIMIT '
.
$limit
;
}
if
(
!
is_null
(
$offset
)
)
{
if
(
$offset
!==
null
)
{
$query
.=
' OFFSET '
.
$offset
;
}
...
...
lib/Doctrine/DBAL/Platforms/DB2Platform.php
View file @
693953dd
...
...
@@ -453,7 +453,7 @@ class DB2Platform extends AbstractPlatform
return
"SESSION."
.
$tableName
;
}
p
ublic
function
m
odifyLimitQuery
(
$query
,
$limit
,
$offset
=
null
)
p
rotected
function
doM
odifyLimitQuery
(
$query
,
$limit
,
$offset
=
null
)
{
if
(
$limit
===
null
&&
$offset
===
null
)
{
return
$query
;
...
...
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
View file @
693953dd
...
...
@@ -583,14 +583,14 @@ class MsSqlPlatform extends AbstractPlatform
* @link http://lists.bestpractical.com/pipermail/rt-devel/2005-June/007339.html
* @return string
*/
p
ublic
function
m
odifyLimitQuery
(
$query
,
$limit
,
$offset
=
null
)
p
rotected
function
doM
odifyLimitQuery
(
$query
,
$limit
,
$offset
=
null
)
{
if
(
$limit
>
0
)
{
$count
=
intval
(
$limit
);
$offset
=
intval
(
$offset
);
if
(
$offset
<
0
)
{
throw
new
D
octrine_Connection_
Exception
(
"LIMIT argument offset=
$offset
is not valid"
);
throw
new
D
BAL
Exception
(
"LIMIT argument offset=
$offset
is not valid"
);
}
if
(
$offset
==
0
)
{
...
...
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
693953dd
...
...
@@ -370,7 +370,7 @@ class MySqlPlatform extends AbstractPlatform
$optionStrings
=
array
();
if
(
isset
(
$options
[
'comment'
]))
{
$optionStrings
[
'comment'
]
=
'COMMENT = '
.
$
this
->
quote
(
$options
[
'comment'
],
'text'
)
;
$optionStrings
[
'comment'
]
=
'COMMENT = '
.
$
options
[
'comment'
]
;
}
if
(
isset
(
$options
[
'charset'
]))
{
$optionStrings
[
'charset'
]
=
'DEFAULT CHARACTER SET '
.
$options
[
'charset'
];
...
...
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
693953dd
...
...
@@ -555,7 +555,7 @@ LEFT JOIN all_cons_columns r_cols
* @param integer $offset start reading from given offset
* @return string the modified query
*/
p
ublic
function
m
odifyLimitQuery
(
$query
,
$limit
,
$offset
=
null
)
p
rotected
function
doM
odifyLimitQuery
(
$query
,
$limit
,
$offset
=
null
)
{
$limit
=
(
int
)
$limit
;
$offset
=
(
int
)
$offset
;
...
...
lib/Doctrine/DBAL/Schema/Column.php
View file @
693953dd
...
...
@@ -154,6 +154,10 @@ class Column extends AbstractAsset
*/
public
function
setPrecision
(
$precision
)
{
if
(
!
is_numeric
(
$precision
))
{
$precision
=
10
;
// defaults to 10 when no valid precision is given.
}
$this
->
_precision
=
(
int
)
$precision
;
return
$this
;
}
...
...
@@ -164,7 +168,11 @@ class Column extends AbstractAsset
*/
public
function
setScale
(
$scale
)
{
$this
->
_scale
=
$scale
;
if
(
!
is_numeric
(
$scale
))
{
$scale
=
0
;
}
$this
->
_scale
=
(
int
)
$scale
;
return
$this
;
}
...
...
lib/Doctrine/DBAL/Schema/Comparator.php
View file @
693953dd
...
...
@@ -163,6 +163,7 @@ class Comparator
$changes
++
;
}
}
foreach
(
$table1Columns
as
$columnName
=>
$column
)
{
if
(
$table2
->
hasColumn
(
$columnName
)
)
{
$changedProperties
=
$this
->
diffColumn
(
$column
,
$table2
->
getColumn
(
$columnName
)
);
...
...
@@ -249,7 +250,7 @@ class Comparator
foreach
(
$tableDifferences
->
addedColumns
AS
$addedColumnName
=>
$addedColumn
)
{
foreach
(
$tableDifferences
->
removedColumns
AS
$removedColumnName
=>
$removedColumn
)
{
if
(
count
(
$this
->
diffColumn
(
$addedColumn
,
$removedColumn
))
==
0
)
{
$renameCandidates
[
$addedColumn
->
getName
()][]
=
array
(
$removedColumn
,
$addedColumn
);
$renameCandidates
[
$addedColumn
->
getName
()][]
=
array
(
$removedColumn
,
$addedColumn
,
$addedColumnName
);
}
}
}
...
...
@@ -257,8 +258,10 @@ class Comparator
foreach
(
$renameCandidates
AS
$candidate
=>
$candidateColumns
)
{
if
(
count
(
$candidateColumns
)
==
1
)
{
list
(
$removedColumn
,
$addedColumn
)
=
$candidateColumns
[
0
];
$removedColumnName
=
strtolower
(
$removedColumn
->
getName
());
$addedColumnName
=
strtolower
(
$addedColumn
->
getName
());
$tableDifferences
->
renamedColumns
[
$removedColumn
->
getName
()
]
=
$addedColumn
;
$tableDifferences
->
renamedColumns
[
$removedColumn
Name
]
=
$addedColumn
;
unset
(
$tableDifferences
->
addedColumns
[
$addedColumnName
]);
unset
(
$tableDifferences
->
removedColumns
[
$removedColumnName
]);
}
...
...
@@ -332,7 +335,7 @@ class Comparator
}
if
(
$column1
->
getType
()
instanceof
\Doctrine\DBAL\Types\DecimalType
)
{
if
(
$column1
->
getPrecision
()
!=
$column2
->
getPrecision
(
))
{
if
(
(
$column1
->
getPrecision
()
?:
10
)
!=
(
$column2
->
getPrecision
()
?:
10
))
{
$changedProperties
[]
=
'precision'
;
}
if
(
$column1
->
getScale
()
!=
$column2
->
getScale
())
{
...
...
lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php
View file @
693953dd
...
...
@@ -155,7 +155,9 @@ class SqliteSchemaManager extends AbstractSchemaManager
case
'real'
:
case
'decimal'
:
case
'numeric'
:
if
(
isset
(
$tableColumn
[
'length'
]))
{
list
(
$precision
,
$scale
)
=
array_map
(
'trim'
,
explode
(
', '
,
$tableColumn
[
'length'
]));
}
$length
=
null
;
break
;
}
...
...
lib/Doctrine/DBAL/Version.php
View file @
693953dd
...
...
@@ -36,7 +36,7 @@ class Version
/**
* Current Doctrine Version
*/
const
VERSION
=
'2.0.
2
-DEV'
;
const
VERSION
=
'2.0.
5
-DEV'
;
/**
* Compares a Doctrine version with the current one.
...
...
doctrine-common
@
a46c6180
Subproject commit
9d414673bb007e61977341d78745fc5aa316a92b
Subproject commit
a46c6180f96647fdd66e2c8f2771d61ecebe6a3f
tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php
View file @
693953dd
...
...
@@ -625,6 +625,48 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$this
->
assertArrayHasKey
(
'id'
,
$tableDiff
->
changedColumns
);
}
/**
* @group DBAL-105
*/
public
function
testDiff
()
{
$table
=
new
\Doctrine\DBAL\Schema\Table
(
'twitter_users'
);
$table
->
addColumn
(
'id'
,
'integer'
,
array
(
'autoincrement'
=>
true
));
$table
->
addColumn
(
'twitterId'
,
'integer'
,
array
(
'nullable'
=>
false
));
$table
->
addColumn
(
'displayName'
,
'string'
,
array
(
'nullable'
=>
false
));
$table
->
setPrimaryKey
(
array
(
'id'
));
$newtable
=
new
\Doctrine\DBAL\Schema\Table
(
'twitter_users'
);
$newtable
->
addColumn
(
'id'
,
'integer'
,
array
(
'autoincrement'
=>
true
));
$newtable
->
addColumn
(
'twitter_id'
,
'integer'
,
array
(
'nullable'
=>
false
));
$newtable
->
addColumn
(
'display_name'
,
'string'
,
array
(
'nullable'
=>
false
));
$newtable
->
addColumn
(
'logged_in_at'
,
'datetime'
,
array
(
'nullable'
=>
true
));
$newtable
->
setPrimaryKey
(
array
(
'id'
));
$c
=
new
Comparator
();
$tableDiff
=
$c
->
diffTable
(
$table
,
$newtable
);
$this
->
assertInstanceOf
(
'Doctrine\DBAL\Schema\TableDiff'
,
$tableDiff
);
$this
->
assertEquals
(
array
(
'twitterid'
,
'displayname'
),
array_keys
(
$tableDiff
->
renamedColumns
));
$this
->
assertEquals
(
array
(
'logged_in_at'
),
array_keys
(
$tableDiff
->
addedColumns
));
$this
->
assertEquals
(
0
,
count
(
$tableDiff
->
removedColumns
));
}
/**
* @group DBAL-106
*/
public
function
testDiffDecimalWithNullPrecision
()
{
$column
=
new
Column
(
'foo'
,
Type
::
getType
(
'decimal'
));
$column
->
setPrecision
(
null
);
$column2
=
new
Column
(
'foo'
,
Type
::
getType
(
'decimal'
));
$c
=
new
Comparator
();
$this
->
assertEquals
(
array
(),
$c
->
diffColumn
(
$column
,
$column2
));
}
/**
* @param SchemaDiff $diff
* @param int $newTableCount
...
...
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