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
479a6ddd
Commit
479a6ddd
authored
Jan 29, 2013
by
Steve Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add SQL Server 2012 platform
parent
19269218
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
131 additions
and
0 deletions
+131
-0
MsSQLKeywords.php
lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php
+7
-0
SQLServer2012Platform.php
lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php
+88
-0
SQLServerSchemaManager.php
lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php
+9
-0
SQLServerPlatformTest.php
...s/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php
+27
-0
No files found.
lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php
View file @
479a6ddd
...
...
@@ -28,6 +28,7 @@ namespace Doctrine\DBAL\Platforms\Keywords;
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @author David Coallier <davidc@php.net>
* @author Steve Müller <st.mueller@dzh-online.de>
*/
class
MsSQLKeywords
extends
KeywordList
{
...
...
@@ -238,6 +239,12 @@ class MsSQLKeywords extends KeywordList
'GRANT'
,
'OPENDATASOURCE'
,
'SELECT'
,
'SEMANTICKEYPHRASETABLE'
,
'SEMANTICSIMILARITYDETAILSTABLE'
,
'SEMANTICSIMILARITYTABLE'
,
'TRY_CONVERT'
,
'WITHIN'
,
'SEQUENCE'
);
}
}
lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php
0 → 100644
View file @
479a6ddd
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace
Doctrine\DBAL\Platforms
;
use
Doctrine\DBAL\Schema\Sequence
;
/**
* Platform to ensure compatibility of Doctrine with SQLServer2012 version.
*
* Differences to SQL Server 2008 and before are that sequences are introduced.
*
* @author Steve Müller <st.mueller@dzh-online.de>
*/
class
SQLServer2012Platform
extends
SQLServer2008Platform
{
/**
* {@inheritdoc}
*/
public
function
getAlterSequenceSQL
(
Sequence
$sequence
)
{
return
'ALTER SEQUENCE '
.
$sequence
->
getQuotedName
(
$this
)
.
' INCREMENT BY '
.
$sequence
->
getAllocationSize
();
}
/**
* {@inheritdoc}
*/
public
function
getCreateSequenceSQL
(
Sequence
$sequence
)
{
return
'CREATE SEQUENCE '
.
$sequence
->
getQuotedName
(
$this
)
.
' START WITH '
.
$sequence
->
getInitialValue
()
.
' INCREMENT BY '
.
$sequence
->
getAllocationSize
()
.
' MINVALUE '
.
$sequence
->
getInitialValue
();
}
/**
* {@inheritdoc}
*/
public
function
getDropSequenceSQL
(
$sequence
)
{
if
(
$sequence
instanceof
Sequence
)
{
$sequence
=
$sequence
->
getQuotedName
(
$this
);
}
return
'DROP SEQUENCE '
.
$sequence
;
}
/**
* {@inheritdoc}
*/
public
function
getListSequencesSQL
(
$database
)
{
return
'SELECT seq.name, seq.increment, seq.start_value FROM sys.sequences AS seq'
;
}
/**
* {@inheritdoc}
*/
public
function
getSequenceNextValSQL
(
$sequenceName
)
{
throw
'SELECT NEXT VALUE FOR '
.
$sequenceName
;
}
/**
* {@inheritdoc}
*/
public
function
supportsSequences
()
{
return
true
;
}
}
lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php
View file @
479a6ddd
...
...
@@ -30,10 +30,19 @@ use Doctrine\DBAL\Driver\SQLSrv\SQLSrvException;
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @author Juozas Kaziukenas <juozas@juokaz.com>
* @author Steve Müller <st.mueller@dzh-online.de>
* @since 2.0
*/
class
SQLServerSchemaManager
extends
AbstractSchemaManager
{
/**
* {@inheritdoc}
*/
protected
function
_getPortableSequenceDefinition
(
$sequence
)
{
return
new
Sequence
(
$sequence
[
'name'
],
$sequence
[
'increment'
],
$sequence
[
'start_value'
]);
}
/**
* @override
*/
...
...
tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php
View file @
479a6ddd
...
...
@@ -114,6 +114,11 @@ class SQLServerPlatformTest extends AbstractPlatformTestCase
$this
->
assertTrue
(
$this
->
_platform
->
prefersIdentityColumns
());
}
public
function
testDoesNotPreferSequences
()
{
$this
->
assertFalse
(
$this
->
_platform
->
prefersSequences
());
}
public
function
testSupportsIdentityColumns
()
{
$this
->
assertTrue
(
$this
->
_platform
->
supportsIdentityColumns
());
...
...
@@ -124,6 +129,11 @@ class SQLServerPlatformTest extends AbstractPlatformTestCase
$this
->
assertTrue
(
$this
->
_platform
->
supportsSavepoints
());
}
public
function
testSupportsSequences
()
{
$this
->
assertTrue
(
$this
->
_platform
->
supportsSequences
());
}
public
function
getGenerateIndexSql
()
{
return
'CREATE INDEX my_idx ON mytable (user_name, last_login)'
;
...
...
@@ -228,6 +238,23 @@ class SQLServerPlatformTest extends AbstractPlatformTestCase
$this
->
assertEquals
(
'ALTER TABLE tbl ADD PRIMARY KEY (id)'
,
$this
->
_platform
->
getCreateIndexSQL
(
$idx
,
'tbl'
));
}
public
function
testGeneratesSequenceSqlCommands
()
{
$sequence
=
new
\Doctrine\DBAL\Schema\Sequence
(
'myseq'
,
20
,
1
);
$this
->
assertEquals
(
'CREATE SEQUENCE myseq START WITH 1 INCREMENT BY 20 MINVALUE 1'
,
$this
->
_platform
->
getCreateSequenceSQL
(
$sequence
)
);
$this
->
assertEquals
(
'DROP SEQUENCE myseq'
,
$this
->
_platform
->
getDropSequenceSQL
(
'myseq'
)
);
$this
->
assertEquals
(
"SELECT NEXT VALUE FOR myseq"
,
$this
->
_platform
->
getSequenceNextValSQL
(
'myseq'
)
);
}
protected
function
getQuotedColumnInPrimaryKeySQL
()
{
return
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