Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rework of pull request #354 on issue #124 #525

Merged
merged 6 commits into from Aug 28, 2012
Merged

Conversation

cebe
Copy link
Member

@cebe cebe commented Mar 19, 2012

cleanup of @DaSourcerer's pull request #354 on issue #124

the new CMysqlCommandBuilder overides the complete method but the only difference to the original implementation is

line 61-63 and 100-103 each:

-    $sql="UPDATE {$table->rawName} SET ".implode(', ',$fields);
+    $sql="UPDATE {$table->rawName}";
     $sql=$this->applyJoin($sql,$criteria->join);
+    $sql.=" SET ".implode(', ',$fields);

and lines 68 + 106:

-    $command=$this->_connection->createCommand($sql);
+    $command=$this->getDbConnection()->createCommand($sql);

Tested this with my application and a unit test is also attached so I think it is ready for merge now.

DaSourcerer and others added 4 commits March 19, 2012 16:46
Fixes issue yiisoft#124
CDbCommandBuilder produced faulty mysql update queries
when joins are involved. JOIN has to come before SET in mysql.
testing mysql update commands with new CMysqlCommandBuilder
issue yiisoft#124
@cebe cebe mentioned this pull request Mar 19, 2012
@qiangxue
Copy link
Member

That's quite some duplicated code. Could you please check if other DBMS supports similar syntax? If so, we should modify CDbCommandBuilder.php directly. Even if it is not, we should still try to refactor the code to avoid copy large chunk of code.

@cebe
Copy link
Member Author

cebe commented Mar 21, 2012

Okay, will check it.

@DaSourcerer
Copy link
Contributor

A little support: The command builder seems to be fine with pgsql. Oracle will need a subquery for the same functionailty. And this seems to be outright impossible all on SQLite.

@DaSourcerer
Copy link
Contributor

w/o link: mssql seems to be content with what the unaltered command builder provides.

@DaSourcerer
Copy link
Contributor

bump
Any news on this?

@cebe
Copy link
Member Author

cebe commented Apr 27, 2012

nope, sorry have not much time at the moment.

@DaSourcerer
Copy link
Contributor

That's okay. But this has been left withoug a notice on Google Code for almost half a year before, so I just want to make sure it's not forgotten.

@ghost ghost assigned cebe Aug 2, 2012
* 'master' of https://github.com/yiisoft/yii: (651 commits)
  Updated guide Gii Model Generator page screenshot.
  adjusted CHANGELOG
  Requirements checking slightly improved.
  Enhanced CHANGELOG description
  Requirements checker: added support of the Oracle database (pdo_oci extension)
  MSSQL driver types refinements.
  Requirements checker: added support of the MSSQL (pdo_dblib and pdo_sqlsrv extensions).
  Language fixes.
  Preparations for merging fixes of the yiisoft#556 into 1.1.13 codebase.
  [docs][blog] 'yiic' to 'Gii'
  ajaxUpdate is never false in jquery.yiilistview.js
  Added /docs/guide/fr/caching.overview.twt
  Added /docs/guide/fr/basics.controller.txt
  Added /docs/guide/fr/basics.mvc.txt
  Update framework/web/filters/CHttpCacheFilter.php
  Update docs/guide/fr/toc.txt
  [NL] Dutch messages translation updated
  added history.js license
  prepare for next release.
  prepare for 1.1.12 release.
  ...

Conflicts:
	CHANGELOG
changed position of JOIN in UPDATE by overwriting applyJoin()
@cebe
Copy link
Member Author

cebe commented Aug 28, 2012

Found a better solution by overwriting applyJoin() and insert JOIN part before SET.

@DaSourcerer
Copy link
Contributor

Nice. No idea why this didn't occur to me in the first place.

cebe added a commit that referenced this pull request Aug 28, 2012
* issue-124:
  better fix for issues #124
  added @SInCE annotation
  added docblocks to CMysqlCommandBuilder+CHANGELOG
  added some unit tests mysql
  Add CMysqlCommandBuilder to handle joins on update
@cebe cebe merged commit 266df50 into yiisoft:master Aug 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants