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
07e73880
Commit
07e73880
authored
Feb 19, 2010
by
beberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] DDC-92 - Completly removed DoctrineException in DBAL package
parent
639718e9
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
56 additions
and
63 deletions
+56
-63
DBALException.php
lib/Doctrine/DBAL/DBALException.php
+24
-1
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+6
-2
MsSqlPlatform.php
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
+3
-4
MySqlPlatform.php
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
+1
-45
OraclePlatform.php
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
+1
-1
PostgreSqlPlatform.php
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
+1
-1
SqlitePlatform.php
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
+1
-8
AbstractSchemaManager.php
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
+0
-1
Table.php
lib/Doctrine/DBAL/Schema/Table.php
+5
-0
AbstractPlatformTestCase.php
...octrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
+8
-0
TableTest.php
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
+6
-0
No files found.
lib/Doctrine/DBAL/DBALException.php
View file @
07e73880
...
...
@@ -6,7 +6,7 @@ class DBALException extends \Exception
{
public
static
function
notSupported
(
$method
)
{
return
new
self
(
"Operation '
$method
' is not supported."
);
return
new
self
(
"Operation '
$method
' is not supported
by platform
."
);
}
public
static
function
invalidPlatformSpecified
()
...
...
@@ -47,4 +47,27 @@ class DBALException extends \Exception
return
new
self
(
"The given 'driverClass' "
.
$driverClass
.
" has to implement the "
.
"\Doctrine\DBAL\Driver interface."
);
}
/**
* @param string $tableName
* @return DBALException
*/
public
static
function
invalidTableName
(
$tableName
)
{
return
new
self
(
"Invalid table name specified: "
.
$tableName
);
}
/**
* @param string $tableName
* @return DBALException
*/
public
static
function
noColumnsSpecifiedForTable
(
$tableName
)
{
return
new
self
(
"No columns specified for table "
.
$tableName
);
}
public
static
function
limitOffsetInvalid
()
{
return
new
self
(
"Invalid Offset in Limit Query, it has to be larger or equal to 0."
);
}
}
\ No newline at end of file
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
07e73880
...
...
@@ -582,6 +582,10 @@ abstract class AbstractPlatform
throw
new
\InvalidArgumentException
(
"Second argument of AbstractPlatform::getCreateTableSql() has to be integer."
);
}
if
(
count
(
$table
->
getColumns
())
==
0
)
{
throw
DBALException
::
noColumnsSpecifiedForTable
(
$table
->
getName
());
}
$tableName
=
$table
->
getName
();
$options
=
$table
->
getOptions
();
$options
[
'uniqueConstraints'
]
=
array
();
...
...
@@ -692,7 +696,7 @@ abstract class AbstractPlatform
* Gets the SQL to create a sequence on this platform.
*
* @param \Doctrine\DBAL\Schema\Sequence $sequence
* @throws D
octrine
Exception
* @throws D
BAL
Exception
*/
public
function
getCreateSequenceSql
(
\Doctrine\DBAL\Schema\Sequence
$sequence
)
{
...
...
@@ -1573,7 +1577,7 @@ abstract class AbstractPlatform
*/
public
function
getTimeTypeDeclarationSql
(
array
$fieldDeclaration
)
{
throw
D
octrineException
::
getTimeTypeDeclarationNotSupported
(
$this
);
throw
D
BALException
::
notSupported
(
__METHOD__
);
}
/**
...
...
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
View file @
07e73880
...
...
@@ -21,9 +21,8 @@
namespace
Doctrine\DBAL\Platforms
;
use
\Doctrine\DBAL\Schema\TableDiff
;
use
Doctrine\Common\DoctrineException
;
use
Doctrine\DBAL\Schema\TableDiff
;
use
Doctrine\DBAL\DBALException
;
/**
* The MsSqlPlatform provides the behavior, features and SQL dialect of the
...
...
@@ -54,7 +53,7 @@ class MsSqlPlatform extends AbstractPlatform
$offset
=
intval
(
$offset
);
if
(
$offset
<
0
)
{
throw
\Doctrine\Common\Doctrine
Exception
::
limitOffsetInvalid
(
$offset
);
throw
DBAL
Exception
::
limitOffsetInvalid
(
$offset
);
}
$orderby
=
stristr
(
$query
,
'ORDER BY'
);
...
...
lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
View file @
07e73880
...
...
@@ -21,7 +21,7 @@
namespace
Doctrine\DBAL\Platforms
;
use
Doctrine\
Common\Doctrine
Exception
,
use
Doctrine\
DBAL\DBAL
Exception
,
Doctrine\DBAL\Schema\TableDiff
;
/**
...
...
@@ -347,12 +347,6 @@ class MySqlPlatform extends AbstractPlatform
*/
protected
function
_getCreateTableSql
(
$tableName
,
array
$columns
,
array
$options
=
array
())
{
if
(
!
$tableName
)
{
throw
DoctrineException
::
missingTableName
();
}
if
(
empty
(
$columns
))
{
throw
DoctrineException
::
missingFieldsArrayForTable
(
$tableName
);
}
$queryFields
=
$this
->
getColumnDeclarationListSql
(
$columns
);
if
(
isset
(
$options
[
'uniqueConstraints'
])
&&
!
empty
(
$options
[
'uniqueConstraints'
]))
{
...
...
@@ -593,44 +587,6 @@ class MySqlPlatform extends AbstractPlatform
return
$unsigned
.
$autoinc
;
}
/**
* Obtain DBMS specific SQL code portion needed to set an index
* declaration to be used in statements like CREATE TABLE.
*
* @return string
* @override
*/
public
function
getIndexFieldDeclarationListSql
(
array
$fields
)
{
$declFields
=
array
();
foreach
(
$fields
as
$fieldName
=>
$field
)
{
$fieldString
=
$fieldName
;
if
(
is_array
(
$field
))
{
if
(
isset
(
$field
[
'length'
]))
{
$fieldString
.=
'('
.
$field
[
'length'
]
.
')'
;
}
if
(
isset
(
$field
[
'sorting'
]))
{
$sort
=
strtoupper
(
$field
[
'sorting'
]);
switch
(
$sort
)
{
case
'ASC'
:
case
'DESC'
:
$fieldString
.=
' '
.
$sort
;
break
;
default
:
throw
DoctrineException
::
unknownIndexSortingOption
(
$sort
);
}
}
}
else
{
$fieldString
=
$field
;
}
$declFields
[]
=
$fieldString
;
}
return
implode
(
', '
,
$declFields
);
}
/**
* Return the FOREIGN KEY query section dealing with non-standard options
* as MATCH, INITIALLY DEFERRED, ON UPDATE, ...
...
...
lib/Doctrine/DBAL/Platforms/OraclePlatform.php
View file @
07e73880
...
...
@@ -111,7 +111,7 @@ class OraclePlatform extends AbstractPlatform
* in {@see listSequences()}
*
* @param \Doctrine\DBAL\Schema\Sequence $sequence
* @
throws DoctrineException
* @
return string
*/
public
function
getCreateSequenceSql
(
\Doctrine\DBAL\Schema\Sequence
$sequence
)
{
...
...
lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
View file @
07e73880
...
...
@@ -387,7 +387,7 @@ class PostgreSqlPlatform extends AbstractPlatform
* Gets the SQL to create a sequence on this platform.
*
* @param \Doctrine\DBAL\Schema\Sequence $sequence
* @
throws DoctrineException
* @
return string
*/
public
function
getCreateSequenceSql
(
\Doctrine\DBAL\Schema\Sequence
$sequence
)
{
...
...
lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
View file @
07e73880
...
...
@@ -21,7 +21,7 @@
namespace
Doctrine\DBAL\Platforms
;
use
Doctrine\
Common\Doctrine
Exception
;
use
Doctrine\
DBAL\DBAL
Exception
;
/**
* The SqlitePlatform class describes the specifics and dialects of the SQLite
...
...
@@ -267,13 +267,6 @@ class SqlitePlatform extends AbstractPlatform
*/
protected
function
_getCreateTableSql
(
$name
,
array
$columns
,
array
$options
=
array
())
{
if
(
!
$name
)
{
throw
DoctrineException
::
invalidTableName
(
$name
);
}
if
(
empty
(
$columns
))
{
throw
DoctrineException
::
noFieldsSpecifiedForTable
(
$name
);
}
$queryFields
=
$this
->
getColumnDeclarationListSql
(
$columns
);
$autoinc
=
false
;
...
...
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
View file @
07e73880
...
...
@@ -22,7 +22,6 @@
namespace
Doctrine\DBAL\Schema
;
use
\Doctrine\DBAL\Types
;
use
\Doctrine\Common\DoctrineException
;
use
\Doctrine\DBAL\DBALException
;
use
\Doctrine\DBAL\Platforms\AbstractPlatform
;
...
...
lib/Doctrine/DBAL/Schema/Table.php
View file @
07e73880
...
...
@@ -23,6 +23,7 @@ namespace Doctrine\DBAL\Schema;
use
Doctrine\DBAL\Types\Type
;
use
Doctrine\DBAL\Schema\Visitor\Visitor
;
use
Doctrine\DBAL\DBALException
;
/**
* Object Representation of a table
...
...
@@ -101,6 +102,10 @@ class Table extends AbstractAsset
*/
public
function
__construct
(
$tableName
,
array
$columns
=
array
(),
array
$indexes
=
array
(),
array
$fkConstraints
=
array
(),
$idGeneratorType
=
self
::
ID_NONE
,
array
$options
=
array
())
{
if
(
strlen
(
$tableName
)
==
0
)
{
throw
DBALException
::
invalidTableName
(
$tableName
);
}
$this
->
_setName
(
$tableName
);
$this
->
_idGeneratorType
=
$idGeneratorType
;
...
...
tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
View file @
07e73880
...
...
@@ -16,6 +16,14 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this
->
_platform
=
$this
->
createPlatform
();
}
public
function
testCreateWithNoColumns
()
{
$table
=
new
\Doctrine\DBAL\Schema\Table
(
'test'
);
$this
->
setExpectedException
(
'Doctrine\DBAL\DBALException'
);
$sql
=
$this
->
_platform
->
getCreateTableSql
(
$table
);
}
public
function
testGeneratesTableCreationSql
()
{
$table
=
new
\Doctrine\DBAL\Schema\Table
(
'test'
);
...
...
tests/Doctrine/Tests/DBAL/Schema/TableTest.php
View file @
07e73880
...
...
@@ -14,6 +14,12 @@ use Doctrine\DBAL\Types\Type;
class
TableTest
extends
\PHPUnit_Framework_TestCase
{
public
function
testCreateWithInvalidTableName
()
{
$this
->
setExpectedException
(
'Doctrine\DBAL\DBALException'
);
$table
=
new
\Doctrine\DBAL\Schema\Table
(
''
);
}
public
function
testGetName
()
{
$table
=
new
Table
(
"foo"
,
array
(),
array
(),
array
());
...
...
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