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
7034f99a
Commit
7034f99a
authored
Feb 03, 2013
by
Guilherme Blanco
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #260 from deeky666/add-sql-server-2012-platform
Add SQL Server 2012 platform
parents
02ea5f03
061045d4
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
212 additions
and
1 deletion
+212
-1
MsSQLKeywords.php
lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php
+8
-1
SQLServer2012Keywords.php
...octrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php
+54
-0
SQLServer2012Platform.php
lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php
+96
-0
SQLServerSchemaManager.php
lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php
+9
-0
SQLServer2012PlatformTest.php
...ctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php
+45
-0
No files found.
lib/Doctrine/DBAL/Platforms/Keywords/MsSQLKeywords.php
View file @
7034f99a
...
...
@@ -28,14 +28,21 @@ 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
{
/**
* {@inheritdoc}
*/
public
function
getName
()
{
return
'MsSQL'
;
}
/**
* {@inheritdoc}
*/
protected
function
getKeywords
()
{
return
array
(
...
...
@@ -237,7 +244,7 @@ class MsSQLKeywords extends KeywordList
'CURRENT_TIME'
,
'GRANT'
,
'OPENDATASOURCE'
,
'SELECT'
,
'SELECT'
);
}
}
lib/Doctrine/DBAL/Platforms/Keywords/SQLServer2012Keywords.php
0 → 100644
View file @
7034f99a
<?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\Keywords
;
/**
* SQL Server 2012 reserved keywords list.
*
* @license BSD http://www.opensource.org/licenses/bsd-license.php
* @link www.doctrine-project.com
* @since 2.3
* @author Steve Müller <st.mueller@dzh-online.de>
*/
class
SQLServer2012Keywords
extends
MsSQLKeywords
{
/**
* {@inheritdoc}
*/
public
function
getName
()
{
return
'SQLServer2012'
;
}
/**
* {@inheritdoc}
*/
protected
function
getKeywords
()
{
return
array_merge
(
parent
::
getKeywords
(),
array
(
'SEMANTICKEYPHRASETABLE'
,
'SEMANTICSIMILARITYDETAILSTABLE'
,
'SEMANTICSIMILARITYTABLE'
,
'TRY_CONVERT'
,
'WITHIN'
,
'SEQUENCE'
));
}
}
lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php
0 → 100644
View file @
7034f99a
<?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
)
{
return
'SELECT NEXT VALUE FOR '
.
$sequenceName
;
}
/**
* {@inheritdoc}
*/
public
function
supportsSequences
()
{
return
true
;
}
/**
* {@inheritdoc}
*/
protected
function
getReservedKeywordsClass
()
{
return
'Doctrine\DBAL\Platforms\Keywords\SQLServer2012Keywords'
;
}
}
lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php
View file @
7034f99a
...
...
@@ -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/SQLServer2012PlatformTest.php
0 → 100644
View file @
7034f99a
<?php
namespace
Doctrine\Tests\DBAL\Platforms
;
use
Doctrine\DBAL\Platforms\SQLServer2012Platform
;
use
Doctrine\DBAL\Schema\Sequence
;
class
SQLServer2012PlatformTest
extends
SQLServerPlatformTest
{
public
function
createPlatform
()
{
return
new
SQLServer2012Platform
;
}
public
function
testSupportsSequences
()
{
$this
->
assertTrue
(
$this
->
_platform
->
supportsSequences
());
}
public
function
testDoesNotPreferSequences
()
{
$this
->
assertFalse
(
$this
->
_platform
->
prefersSequences
());
}
public
function
testGeneratesSequenceSqlCommands
()
{
$sequence
=
new
Sequence
(
'myseq'
,
20
,
1
);
$this
->
assertEquals
(
'CREATE SEQUENCE myseq START WITH 1 INCREMENT BY 20 MINVALUE 1'
,
$this
->
_platform
->
getCreateSequenceSQL
(
$sequence
)
);
$this
->
assertEquals
(
'ALTER SEQUENCE myseq INCREMENT BY 20'
,
$this
->
_platform
->
getAlterSequenceSQL
(
$sequence
)
);
$this
->
assertEquals
(
'DROP SEQUENCE myseq'
,
$this
->
_platform
->
getDropSequenceSQL
(
'myseq'
)
);
$this
->
assertEquals
(
"SELECT NEXT VALUE FOR myseq"
,
$this
->
_platform
->
getSequenceNextValSQL
(
'myseq'
)
);
}
}
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