Skip to content

Commit

Permalink
Fixes yiisoft#3976: Fixed MSSQL command builderto comply with the DEL…
Browse files Browse the repository at this point in the history
…ETE command syntax
  • Loading branch information
odalecne authored and samdark committed Nov 10, 2015
1 parent f9db072 commit 82e09d2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG
Expand Up @@ -6,7 +6,7 @@ Version 1.1.17 work in progress

- Bug #2881: CGridView was blocking refresh on filter field change event after previous filtering using ENTER key (sivir)
- Bug #2921: Fixed CStatePersister read/write concurrency issue causing state data corruption (matteosistisette, samdark)
- Bug #2993: Fixed Mysql datetime fields can have default CURRENT_TIMESTAMP (tomvdp)
- Bug #2993: Fixed MySQL datetime fields can have default CURRENT_TIMESTAMP (tomvdp)
- Bug #3144: Fixed regression introduced in 1.1.16, whitespace before and after attributes in validation rules where not ignored (cebe)
- Bug #3497: CErrorHandler messages for HTTP response codes were not matching RFCs (TeMPOraL)
- Bug #3637: Fixed not quoting primary key in count statements (applee)
Expand All @@ -20,6 +20,7 @@ Version 1.1.17 work in progress
- Bug #3879: Numeric labels in CBreadCrumbs reindex after using array_merge (AloneCoder)
- Bug #3947: Fix error with `array_diff` when one of CDbCriteria->select contains "false" (askobara, cebe)
- Bug #3974: Fixed warning when request parameter contains array (cmazx)
- Bug #3976: Fixed MSSQL command builderto comply with the DELETE command syntax (odalecne)
- Bug #3980: Fixed CRedisCache error when using `mbstring.func_overload` and UTF-8 as `mbstring.internal_encoding` (Lexx918)
- Enh #2399: It is now possible to use table names containing spaces by introducing alias (devivan)
- Enh #3686: Wrapper div of hidden fields in CForm now have style `display:none` instead of `visibility:hidden` to not affect the layout (cebe, alaabadran)
Expand Down
14 changes: 14 additions & 0 deletions framework/db/schema/mssql/CMssqlCommandBuilder.php
Expand Up @@ -133,6 +133,20 @@ public function createUpdateCounterCommand($table,$counters,$criteria)
return parent::createUpdateCounterCommand($table, $counters, $criteria);
}

/**
* Alters the SQL to apply JOIN clause.
* Overrides parent implementation to comply with the DELETE command syntax required when multiple tables are referenced.
* @param string $sql the SQL statement to be altered
* @param string $join the JOIN clause (starting with join type, such as INNER JOIN)
* @return string the altered SQL statement
*/
public function applyJoin($sql,$join)
{
if(trim($join)!=='')
$sql=preg_replace('/^\s*DELETE\s+FROM\s+((\[.+\])|([^\s]+))\s*/i',"DELETE \\1 FROM \\1",$sql);
return parent::applyJoin($sql,$join);
}

/**
* This is a port from Prado Framework.
*
Expand Down

0 comments on commit 82e09d2

Please sign in to comment.