Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Update SQLServerPlatform.php by adding methods related to schema. #375

Merged
merged 2 commits into from

3 participants

@flip111

The platform indicates support for schema's here: https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php#L129

But is missing relevant methods:
schemaNeedsCreation() --> to detect if schema creation is needed
and
getCreateSchemaSQL() --> to create a schema

@flip111 flip111 Update SQLServerPlatform.php by adding methods related to schema.
The platform indicates support for schema's here: https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php#L129

But is missing relevant methods:
schemaNeedsCreation() --> to detect if schema creation is needed
and
getCreateSchemaSQL() --> to create a schema
97b70b2
@doctrinebot
Collaborator

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DBAL-611

We use Jira to track the state of pull requests and the versions they got
included in.

@flip111

Together with this PR #376 it will reduce unittest errors/failure from 732/15 to 72/18 on MSSQL

@flip111

I can not reproduce the failing Travis-CI build. Using environment:

Windows 7 Professional 64 bits
PHP 5.4.11 (cli) (built: Jan 16 2013 20:26:26)
Doctrine dev-master from 18-9-2013.

With either

mysql-5.6.13-winx64

or

PostgreSQL 9.2.4 build 1600, 64-bits

Without any modification this setup fails some tests in the test suite, see http://www.doctrine-project.org/jira/browse/DDC-2689 and http://www.doctrine-project.org/jira/browse/DDC-2690 With modifications from this PR the test output stays exactly the same.

@guilhermeblanco guilhermeblanco merged commit 899c98d into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 18, 2013
  1. @flip111

    Update SQLServerPlatform.php by adding methods related to schema.

    flip111 authored
    The platform indicates support for schema's here: https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php#L129
    
    But is missing relevant methods:
    schemaNeedsCreation() --> to detect if schema creation is needed
    and
    getCreateSchemaSQL() --> to create a schema
Commits on Sep 27, 2013
  1. @flip111
This page is out of date. Refresh to see the latest.
View
16 lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php
@@ -166,6 +166,22 @@ public function supportsCreateDropDatabase()
/**
* {@inheritDoc}
*/
+ public function getCreateSchemaSQL($schemaName)
+ {
+ return 'CREATE SCHEMA ' . $schemaName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function schemaNeedsCreation($schemaName)
+ {
+ return $schemaName !== 'dbo';
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public function getDropForeignKeySQL($foreignKey, $table)
{
if ($foreignKey instanceof ForeignKeyConstraint) {
View
19 tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php
@@ -317,4 +317,23 @@ protected function getQuotedColumnInForeignKeySQL()
'ALTER TABLE [quoted] ADD CONSTRAINT FK_WITH_INTENDED_QUOTATION FOREIGN KEY ([create], foo, [bar]) REFERENCES [foo-bar] ([create], bar, [foo-bar])',
);
}
+
+ public function testGetCreateSchemaSQL()
+ {
+ $schemaName = 'schema';
+ $sql = $this->_platform->getCreateSchemaSQL($schemaName);
+ $this->assertEquals('CREATE SCHEMA ' . $schemaName, $sql);
+ }
+
+ public function testSchemaNeedsCreation()
+ {
+ $schemaNames = array(
+ 'dbo' => false,
+ 'schema' => true,
+ );
+ foreach ($schemaNames as $name => $expected) {
+ $actual = $this->_platform->schemaNeedsCreation($name);
+ $this->assertEquals($expected, $actual);
+ }
+ }
}
Something went wrong with that request. Please try again.