Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Driver/PDODblib/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Connection extends \Doctrine\DBAL\Driver\PDOConnection implements DriverCo
*/
public function rollback()
{
$this->exec('ROLLBACK TRANSACTION');
// $this->exec('ROLLBACK TRANSACTION');
}

/**
Expand Down
36 changes: 35 additions & 1 deletion Platforms/DblibPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Schema\Index;

/**
* The DblibPlatform provides the behavior, features and SQL dialect of the
Expand Down Expand Up @@ -133,17 +134,28 @@ protected function initializeDoctrineTypeMappings()
parent::initializeDoctrineTypeMappings();

// add uniqueidentifier
//$this->doctrineTypeMapping['timestamp'] = 'date';
$this->doctrineTypeMapping['uniqueidentifier'] = 'uniqueidentifier';
}

public function getTimestampTypeDeclarationSQL(array $fieldDeclaration)
{
return "TIMESTAMP";
}

/**
* @override
*/
public function getDateTimeFormatString()
{
return 'Y-m-d H:i:s.u';
return 'F d Y H:i:s:000A';
}

public function getTimestampFormatString()
{
return 'Y-m-d H:i:s';
}

/**
* @override
* @return bool
Expand All @@ -152,4 +164,26 @@ public function supportsLimitOffset()
{
return true;
}

public function getCreateIndexSQL(Index $index, $table)
{
if ($table instanceof Table) {
$table = $table->getQuotedName($this);
}
$name = $index->getQuotedName($this);
$columns = $index->getColumns();

if (count($columns) == 0) {
throw new \InvalidArgumentException("Incomplete definition. 'columns' required.");
}

if ($index->isPrimary()) {
return $this->getCreatePrimaryKeySQL($index, $table);
}

$query = 'CREATE ' . $this->getCreateIndexSQLFlags($index) . 'INDEX ' . $name . ' ON ' . $table;
$query .= ' (' . $this->getIndexFieldDeclarationListSQL($columns) . ')';

return $query;
}
}
28 changes: 15 additions & 13 deletions Schema/DblibSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,23 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys)
$list = array();
foreach ($tableForeignKeys as $key => $value) {
$value = \array_change_key_case($value, CASE_LOWER);
if (!isset($list[$value['constraint_name']])) {
if ($value['delete_rule'] == "NO ACTION") {
$value['delete_rule'] = null;
if(array_key_exists('constraint_name', $value)){
if (!isset($list[$value['constraint_name']])) {
if ($value['delete_rule'] == "NO ACTION") {
$value['delete_rule'] = null;
}

$list[$value['pkconstraint_name']] = array(
'name' => $value['pkconstraint_name'],
'local' => array(),
'foreign' => array(),
'foreignTable' => $value['fktable_name'],
'onDelete' => $value['delete_rule'],
);
}

$list[$value['pkconstraint_name']] = array(
'name' => $value['pkconstraint_name'],
'local' => array(),
'foreign' => array(),
'foreignTable' => $value['fktable_name'],
'onDelete' => $value['delete_rule'],
);
$list[$value['pkconstraint_name']]['local'][$value['deferrability']] = $value['pkcolumn_name'];
$list[$value['pkconstraint_name']]['foreign'][$value['deferrability']] = $value['fkcolumn_name'];
}
$list[$value['pkconstraint_name']]['local'][$value['deferrability']] = $value['pkcolumn_name'];
$list[$value['pkconstraint_name']]['foreign'][$value['deferrability']] = $value['fkcolumn_name'];
}

$result = array();
Expand Down
69 changes: 69 additions & 0 deletions Types/TimestampType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?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 LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/

namespace Realestate\MssqlBundle\Types;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;

/**
* Type that maps an SQL TIME to a PHP DateTime object.
*
* @since 2.0
*/
class TimestampType extends Type
{
public function getName()
{
return 'timestamp';
}

/**
* {@inheritdoc}
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return $platform->getTimestampTypeDeclarationSQL($fieldDeclaration);
}

/**
* {@inheritdoc}
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
return ($value !== null)
? $value->format($platform->getTimestampFormatString()) : null;
}

/**
* {@inheritdoc}
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value === null) {
return null;
}

$val = \Realestate\MssqlBundle\Types\RealestateDateTime::createFromFormat($platform->getTimestampFormatString(), $value);
if (!$val) {
throw ConversionException::conversionFailedFormat($value, $this->getName(), $platform->getTimestampFormatString());
}
return $val;
}
}