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
b9510560
Commit
b9510560
authored
May 26, 2009
by
jwage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Adding initial MsSql platform and tests
parent
d2405ded
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
463 additions
and
35 deletions
+463
-35
AbstractPlatform.php
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
+15
-6
MsSqlPlatform.php
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
+280
-24
AllTests.php
tests/Doctrine/Tests/DBAL/AllTests.php
+2
-1
MssqlPlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/MssqlPlatformTest.php
+166
-0
MySqlPlatformTest.php
tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
+0
-4
No files found.
lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
View file @
b9510560
...
@@ -1092,11 +1092,7 @@ abstract class AbstractPlatform
...
@@ -1092,11 +1092,7 @@ abstract class AbstractPlatform
$query
=
'CREATE '
.
$type
.
'INDEX '
.
$name
.
' ON '
.
$table
;
$query
=
'CREATE '
.
$type
.
'INDEX '
.
$name
.
' ON '
.
$table
;
$fields
=
array
();
$query
.=
' ('
.
$this
->
getIndexFieldDeclarationListSql
(
$definition
[
'fields'
])
.
')'
;
foreach
(
$definition
[
'fields'
]
as
$field
)
{
$fields
[]
=
$field
;
}
$query
.=
' ('
.
implode
(
', '
,
$fields
)
.
')'
;
return
$query
;
return
$query
;
}
}
...
@@ -1716,6 +1712,19 @@ abstract class AbstractPlatform
...
@@ -1716,6 +1712,19 @@ abstract class AbstractPlatform
throw
DoctrineException
::
updateMe
(
'Set transaction isolation not supported by this platform.'
);
throw
DoctrineException
::
updateMe
(
'Set transaction isolation not supported by this platform.'
);
}
}
/**
* Obtain DBMS specific SQL code portion needed to set the CHARACTER SET
* of a field declaration to be used in statements like CREATE TABLE.
*
* @param string $charset name of the charset
* @return string DBMS specific SQL code portion needed to set the CHARACTER SET
* of a field declaration.
*/
public
function
getCharsetFieldDeclaration
(
$charset
)
{
throw
DoctrineException
::
updateMe
(
'Get charset field declaration not supported by this platform.'
);
}
/**
/**
* Gets the default transaction isolation level of the platform.
* Gets the default transaction isolation level of the platform.
*
*
...
...
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
View file @
b9510560
This diff is collapsed.
Click to expand it.
tests/Doctrine/Tests/DBAL/AllTests.php
View file @
b9510560
...
@@ -25,6 +25,7 @@ class AllTests
...
@@ -25,6 +25,7 @@ class AllTests
$suite
->
addTestSuite
(
'Doctrine\Tests\DBAL\Platforms\SqlitePlatformTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\DBAL\Platforms\SqlitePlatformTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\DBAL\Platforms\MySqlPlatformTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\DBAL\Platforms\MySqlPlatformTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\DBAL\Platforms\PostgreSqlPlatformTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\DBAL\Platforms\PostgreSqlPlatformTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\DBAL\Platforms\MsSqlPlatformTest'
);
return
$suite
;
return
$suite
;
}
}
...
...
tests/Doctrine/Tests/DBAL/Platforms/MssqlPlatformTest.php
0 → 100644
View file @
b9510560
<?php
namespace
Doctrine\Tests\DBAL\Platforms
;
use
Doctrine\DBAL\Platforms\MsSqlPlatform
;
use
Doctrine\DBAL\Types\Type
;
require_once
__DIR__
.
'/../../TestInit.php'
;
class
MsSqlPlatformTest
extends
\Doctrine\Tests\DbalTestCase
{
private
$_platform
;
public
function
setUp
()
{
$this
->
_platform
=
new
MssqlPlatform
;
}
public
function
testCreateTableSql
()
{
$columns
=
array
(
'id'
=>
array
(
'type'
=>
Type
::
getType
(
'integer'
),
'autoincrement'
=>
true
,
'primary'
=>
true
,
'notnull'
=>
true
),
'test'
=>
array
(
'type'
=>
Type
::
getType
(
'string'
),
'length'
=>
255
,
'notnull'
=>
true
)
);
$options
=
array
(
'primary'
=>
array
(
'id'
)
);
$sql
=
$this
->
_platform
->
getCreateTableSql
(
'test'
,
$columns
,
$options
);
$this
->
assertEquals
(
'CREATE TABLE test (id INT AUTO_INCREMENT NOT NULL, test VARCHAR(255) NOT NULL, PRIMARY KEY(id))'
,
$sql
[
0
]);
}
public
function
testAlterTableSql
()
{
$changes
=
array
(
'name'
=>
'userlist'
,
'add'
=>
array
(
'quota'
=>
array
(
'type'
=>
Type
::
getType
(
'integer'
),
'unsigned'
=>
1
)
));
$this
->
assertEquals
(
'ALTER TABLE mytable RENAME TO userlist, ADD quota INT UNSIGNED DEFAULT NULL'
,
$this
->
_platform
->
getAlterTableSql
(
'mytable'
,
$changes
)
);
}
public
function
testCreateIndexSql
()
{
$indexDef
=
array
(
'fields'
=>
array
(
'user_name'
=>
array
(
'sorting'
=>
'ASC'
,
'length'
=>
10
),
'last_login'
=>
array
()
)
);
$this
->
assertEquals
(
'CREATE INDEX my_idx ON mytable (user_name, last_login)'
,
$this
->
_platform
->
getCreateIndexSql
(
'mytable'
,
'my_idx'
,
$indexDef
)
);
}
public
function
testSqlSnippets
()
{
$this
->
assertEquals
(
'RLIKE'
,
$this
->
_platform
->
getRegexpExpression
());
$this
->
assertEquals
(
'`'
,
$this
->
_platform
->
getIdentifierQuoteCharacter
());
$this
->
assertEquals
(
'RAND()'
,
$this
->
_platform
->
getRandomExpression
());
$this
->
assertEquals
(
'(column1 + column2 + column3)'
,
$this
->
_platform
->
getConcatExpression
(
'column1'
,
'column2'
,
'column3'
));
$this
->
assertEquals
(
'CHARACTER SET utf8'
,
$this
->
_platform
->
getCharsetFieldDeclaration
(
'utf8'
));
$this
->
assertEquals
(
'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED'
,
$this
->
_platform
->
getSetTransactionIsolationSql
(
\Doctrine\DBAL\Connection
::
TRANSACTION_READ_UNCOMMITTED
)
);
$this
->
assertEquals
(
'SET TRANSACTION ISOLATION LEVEL READ COMMITTED'
,
$this
->
_platform
->
getSetTransactionIsolationSql
(
\Doctrine\DBAL\Connection
::
TRANSACTION_READ_COMMITTED
)
);
$this
->
assertEquals
(
'SET TRANSACTION ISOLATION LEVEL REPEATABLE READ'
,
$this
->
_platform
->
getSetTransactionIsolationSql
(
\Doctrine\DBAL\Connection
::
TRANSACTION_REPEATABLE_READ
)
);
$this
->
assertEquals
(
'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE'
,
$this
->
_platform
->
getSetTransactionIsolationSql
(
\Doctrine\DBAL\Connection
::
TRANSACTION_SERIALIZABLE
)
);
}
public
function
testDDLSnippets
()
{
$this
->
assertEquals
(
'SHOW DATABASES'
,
$this
->
_platform
->
getShowDatabasesSql
());
$this
->
assertEquals
(
'CREATE DATABASE foobar'
,
$this
->
_platform
->
getCreateDatabaseSql
(
'foobar'
));
$this
->
assertEquals
(
'DROP DATABASE foobar'
,
$this
->
_platform
->
getDropDatabaseSql
(
'foobar'
));
$this
->
assertEquals
(
'DROP TABLE foobar'
,
$this
->
_platform
->
getDropTableSql
(
'foobar'
));
}
public
function
testTypeDeclarationSql
()
{
$this
->
assertEquals
(
'INT'
,
$this
->
_platform
->
getIntegerTypeDeclarationSql
(
array
())
);
$this
->
assertEquals
(
'INT AUTO_INCREMENT'
,
$this
->
_platform
->
getIntegerTypeDeclarationSql
(
array
(
'autoincrement'
=>
true
)
));
$this
->
assertEquals
(
'INT AUTO_INCREMENT'
,
$this
->
_platform
->
getIntegerTypeDeclarationSql
(
array
(
'autoincrement'
=>
true
,
'primary'
=>
true
)
));
$this
->
assertEquals
(
'CHAR(10)'
,
$this
->
_platform
->
getVarcharTypeDeclarationSql
(
array
(
'length'
=>
10
,
'fixed'
=>
true
)
));
$this
->
assertEquals
(
'VARCHAR(50)'
,
$this
->
_platform
->
getVarcharTypeDeclarationSql
(
array
(
'length'
=>
50
))
);
$this
->
assertEquals
(
'TEXT'
,
$this
->
_platform
->
getVarcharTypeDeclarationSql
(
array
())
);
}
public
function
testPreferences
()
{
$this
->
assertTrue
(
$this
->
_platform
->
prefersIdentityColumns
());
$this
->
assertTrue
(
$this
->
_platform
->
supportsIdentityColumns
());
$this
->
assertFalse
(
$this
->
_platform
->
supportsSavepoints
());
}
public
function
testGetCreateConstraintSql
()
{
$sql
=
$this
->
_platform
->
getCreateConstraintSql
(
'test'
,
'constraint_name'
,
array
(
'fields'
=>
array
(
'test'
=>
array
())));
$this
->
assertEquals
(
$sql
,
'ALTER TABLE test ADD CONSTRAINT constraint_name (test)'
);
}
public
function
testGetCreateIndexSql
()
{
$sql
=
$this
->
_platform
->
getCreateIndexSql
(
'test'
,
'index_name'
,
array
(
'type'
=>
'unique'
,
'fields'
=>
array
(
'test'
,
'test2'
)));
$this
->
assertEquals
(
$sql
,
'CREATE UNIQUE INDEX index_name ON test (test, test2)'
);
}
public
function
testGetCreateForeignKeySql
()
{
$sql
=
$this
->
_platform
->
getCreateForeignKeySql
(
'test'
,
array
(
'foreignTable'
=>
'other_table'
,
'local'
=>
'fk_name_id'
,
'foreign'
=>
'id'
));
$this
->
assertEquals
(
$sql
,
'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table(id)'
);
}
}
\ No newline at end of file
tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php
View file @
b9510560
...
@@ -146,7 +146,6 @@ class MySqlPlatformTest extends \Doctrine\Tests\DbalTestCase
...
@@ -146,7 +146,6 @@ class MySqlPlatformTest extends \Doctrine\Tests\DbalTestCase
}
}
/*
public
function
testGetCreateConstraintSql
()
public
function
testGetCreateConstraintSql
()
{
{
$sql
=
$this
->
_platform
->
getCreateConstraintSql
(
'test'
,
'constraint_name'
,
array
(
'fields'
=>
array
(
'test'
=>
array
())));
$sql
=
$this
->
_platform
->
getCreateConstraintSql
(
'test'
,
'constraint_name'
,
array
(
'fields'
=>
array
(
'test'
=>
array
())));
...
@@ -164,7 +163,4 @@ class MySqlPlatformTest extends \Doctrine\Tests\DbalTestCase
...
@@ -164,7 +163,4 @@ class MySqlPlatformTest extends \Doctrine\Tests\DbalTestCase
$sql
=
$this
->
_platform
->
getCreateForeignKeySql
(
'test'
,
array
(
'foreignTable'
=>
'other_table'
,
'local'
=>
'fk_name_id'
,
'foreign'
=>
'id'
));
$sql
=
$this
->
_platform
->
getCreateForeignKeySql
(
'test'
,
array
(
'foreignTable'
=>
'other_table'
,
'local'
=>
'fk_name_id'
,
'foreign'
=>
'id'
));
$this
->
assertEquals
(
$sql
,
'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table(id)'
);
$this
->
assertEquals
(
$sql
,
'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table(id)'
);
}
}
*/
}
}
\ 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