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
dae94de9
Commit
dae94de9
authored
Sep 25, 2011
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'DDC-1337' into 2.1.x
parents
aafe60e6
38d10b9e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
129 additions
and
25 deletions
+129
-25
Connection.php
lib/Doctrine/DBAL/Connection.php
+5
-5
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+15
-1
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+21
-17
TemporaryTableTest.php
tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php
+86
-0
DbalFunctionalTestCase.php
tests/Doctrine/Tests/DbalFunctionalTestCase.php
+2
-2
No files found.
lib/Doctrine/DBAL/Connection.php
View file @
dae94de9
...
...
@@ -276,7 +276,7 @@ class Connection implements DriverConnection
/**
* Gets the DBAL driver instance.
*
* @return Doctrine\DBAL\Driver
* @return
\
Doctrine\DBAL\Driver
*/
public
function
getDriver
()
{
...
...
@@ -286,7 +286,7 @@ class Connection implements DriverConnection
/**
* Gets the Configuration used by the Connection.
*
* @return Doctrine\DBAL\Configuration
* @return
\
Doctrine\DBAL\Configuration
*/
public
function
getConfiguration
()
{
...
...
@@ -296,7 +296,7 @@ class Connection implements DriverConnection
/**
* Gets the EventManager used by the Connection.
*
* @return Doctrine\Common\EventManager
* @return
\
Doctrine\Common\EventManager
*/
public
function
getEventManager
()
{
...
...
@@ -306,7 +306,7 @@ class Connection implements DriverConnection
/**
* Gets the DatabasePlatform for the connection.
*
* @return Doctrine\DBAL\Platforms\AbstractPlatform
* @return
\
Doctrine\DBAL\Platforms\AbstractPlatform
*/
public
function
getDatabasePlatform
()
{
...
...
@@ -316,7 +316,7 @@ class Connection implements DriverConnection
/**
* Gets the ExpressionBuilder for the connection.
*
* @return Doctrine\DBAL\Query\ExpressionBuilder
* @return
\
Doctrine\DBAL\Query\ExpressionBuilder
*/
public
function
getExpressionBuilder
()
{
...
...
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
dae94de9
...
...
@@ -830,7 +830,8 @@ abstract class AbstractPlatform
/**
* Drop a Table
*
*
* @throws \InvalidArgumentException
* @param Table|string $table
* @return string
*/
...
...
@@ -838,11 +839,24 @@ abstract class AbstractPlatform
{
if
(
$table
instanceof
\Doctrine\DBAL\Schema\Table
)
{
$table
=
$table
->
getQuotedName
(
$this
);
}
else
if
(
!
is_string
(
$table
))
{
throw
new
\InvalidArgumentException
(
'getDropTableSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.'
);
}
return
'DROP TABLE '
.
$table
;
}
/**
* Get SQL to safely drop a temporary table WITHOUT implicitly committing an open transaction.
*
* @param Table|string $table
* @return string
*/
public
function
getDropTemporaryTableSQL
(
$table
)
{
return
$this
->
getDropTableSQL
(
$table
);
}
/**
* Drop index from a table
*
...
...
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
dae94de9
...
...
@@ -610,23 +610,6 @@ class MySqlPlatform extends AbstractPlatform
{
return
'ALTER TABLE '
.
$table
.
' DROP PRIMARY KEY'
;
}
/**
* Gets the SQL to drop a table.
*
* @param string $table The name of table to drop.
* @override
*/
public
function
getDropTableSQL
(
$table
)
{
if
(
$table
instanceof
\Doctrine\DBAL\Schema\Table
)
{
$table
=
$table
->
getQuotedName
(
$this
);
}
else
if
(
!
is_string
(
$table
))
{
throw
new
\InvalidArgumentException
(
'MysqlPlatform::getDropTableSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.'
);
}
return
'DROP TABLE '
.
$table
;
}
public
function
getSetTransactionIsolationSQL
(
$level
)
{
...
...
@@ -686,4 +669,25 @@ class MySqlPlatform extends AbstractPlatform
{
return
'Doctrine\DBAL\Platforms\Keywords\MySQLKeywords'
;
}
/**
* Get SQL to safely drop a temporary table WITHOUT implicitly committing an open transaction.
*
* MySQL commits a transaction implicitly when DROP TABLE is executed, however not
* if DROP TEMPORARY TABLE is executed.
*
* @throws \InvalidArgumentException
* @param $table
* @return string
*/
public
function
getDropTemporaryTableSQL
(
$table
)
{
if
(
$table
instanceof
\Doctrine\DBAL\Schema\Table
)
{
$table
=
$table
->
getQuotedName
(
$this
);
}
else
if
(
!
is_string
(
$table
))
{
throw
new
\InvalidArgumentException
(
'getDropTableSQL() expects $table parameter to be string or \Doctrine\DBAL\Schema\Table.'
);
}
return
'DROP TEMPORARY TABLE '
.
$table
;
}
}
tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php
0 → 100644
View file @
dae94de9
<?php
namespace
Doctrine\Tests\DBAL\Functional
;
use
\Doctrine\DBAL\Schema\Table
;
use
\Doctrine\DBAL\Schema\Column
;
use
\Doctrine\DBAL\Types\Type
;
class
TemporaryTableTest
extends
\Doctrine\Tests\DbalFunctionalTestCase
{
public
function
setUp
()
{
parent
::
setUp
();
try
{
$this
->
_conn
->
exec
(
$this
->
_conn
->
getDatabasePlatform
()
->
getDropTableSQL
(
"non_temporary"
));
}
catch
(
\Exception
$e
)
{
}
}
/**
* @group DDC-1337
* @return void
*/
public
function
testDropTemporaryTableNotAbortsTransaction
()
{
$platform
=
$this
->
_conn
->
getDatabasePlatform
();
$columnDefinitions
=
array
(
"id"
=>
array
(
"type"
=>
Type
::
getType
(
"integer"
),
"notnull"
=>
true
));
$tempTable
=
$platform
->
getTemporaryTableName
(
"temporary"
);
$tempTableSQL
=
$platform
->
getCreateTemporaryTableSnippetSQL
()
.
' '
.
$tempTable
.
' ('
.
$platform
->
getColumnDeclarationListSQL
(
$columnDefinitions
)
.
')'
;
$table
=
new
Table
(
"non_temporary"
);
$table
->
addColumn
(
"id"
,
"integer"
);
$this
->
_conn
->
getSchemaManager
()
->
createTable
(
$table
);
$this
->
_conn
->
beginTransaction
();
$this
->
_conn
->
insert
(
"non_temporary"
,
array
(
"id"
=>
1
));
$this
->
_conn
->
exec
(
$tempTableSQL
);
$this
->
_conn
->
exec
(
$platform
->
getDropTemporaryTableSQL
(
$tempTable
));
$this
->
_conn
->
insert
(
"non_temporary"
,
array
(
"id"
=>
2
));
$this
->
_conn
->
rollback
();
$rows
=
$this
->
_conn
->
fetchAll
(
'SELECT * FROM non_temporary'
);
$this
->
assertEquals
(
array
(),
$rows
);
}
/**
* @group DDC-1337
* @return void
*/
public
function
testCreateTemporaryTableNotAbortsTransaction
()
{
$platform
=
$this
->
_conn
->
getDatabasePlatform
();
$columnDefinitions
=
array
(
"id"
=>
array
(
"type"
=>
Type
::
getType
(
"integer"
),
"notnull"
=>
true
));
$tempTable
=
$platform
->
getTemporaryTableName
(
"temporary"
);
$tempTableSQL
=
$platform
->
getCreateTemporaryTableSnippetSQL
()
.
' '
.
$tempTable
.
' ('
.
$platform
->
getColumnDeclarationListSQL
(
$columnDefinitions
)
.
')'
;
$table
=
new
Table
(
"non_temporary"
);
$table
->
addColumn
(
"id"
,
"integer"
);
$this
->
_conn
->
getSchemaManager
()
->
createTable
(
$table
);
$this
->
_conn
->
beginTransaction
();
$this
->
_conn
->
insert
(
"non_temporary"
,
array
(
"id"
=>
1
));
$this
->
_conn
->
exec
(
$tempTableSQL
);
$this
->
_conn
->
insert
(
"non_temporary"
,
array
(
"id"
=>
2
));
$this
->
_conn
->
rollback
();
try
{
$this
->
_conn
->
exec
(
$platform
->
getDropTemporaryTableSQL
(
$tempTable
));
}
catch
(
\Exception
$e
)
{
}
$rows
=
$this
->
_conn
->
fetchAll
(
'SELECT * FROM non_temporary'
);
$this
->
assertEquals
(
array
(),
$rows
);
}
}
\ No newline at end of file
tests/Doctrine/Tests/DbalFunctionalTestCase.php
View file @
dae94de9
...
...
@@ -7,12 +7,12 @@ class DbalFunctionalTestCase extends DbalTestCase
/**
* Shared connection when a TestCase is run alone (outside of it's functional suite)
*
* @var Doctrine\DBAL\Connection
* @var
\
Doctrine\DBAL\Connection
*/
private
static
$_sharedConn
;
/**
* @var Doctrine\DBAL\Connection
* @var
\
Doctrine\DBAL\Connection
*/
protected
$_conn
;
...
...
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