-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix #1534 #1566
Merged
Merged
Fix #1534 #1566
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
phalcon
pushed a commit
that referenced
this pull request
Nov 18, 2013
Thanks, could you please submit a fix for 2.0? |
ghost
deleted the
issue-1534
branch
November 19, 2013 06:11
I get a compiler error from zephir:
|
This is the patch for 2.0: diff --git a/phalcon/mvc/model.zep b/phalcon/mvc/model.zep
index 4d057b6..6e387e0 100644
--- a/phalcon/mvc/model.zep
+++ b/phalcon/mvc/model.zep
@@ -880,7 +880,7 @@ abstract class Model implements Phalcon\Mvc\ModelInterface, Phalcon\Mvc\Model\Re
int numberEmpty, numberPrimary;
var uniqueParams, uniqueTypes, uniqueKey, columnMap, primaryKeys,
wherePk, field, attributeField, value, bindDataTypes,
- joinWhere, num, type, schema, source;
+ joinWhere, num, type, schema, source, v, seen_rawvalue;
let uniqueParams = null,
uniqueTypes = null;
@@ -938,19 +938,24 @@ abstract class Model implements Phalcon\Mvc\ModelInterface, Phalcon\Mvc\Model\Re
if empty value {
let numberEmpty++;
}
- let uniqueParams[] = value;
-
+ let v = value;
} else {
- let uniqueParams[] = null,
- numberEmpty++;
+ let v = null;
+ let numberEmpty++;
}
if !fetch type, bindDataTypes[field] {
throw new Phalcon\Mvc\Model\Exception("Column '" . field . "' isn't part of the table columns");
}
-
- let uniqueTypes[] = type,
- wherePk[] = connection->escapeIdentifier(field) . " = ?";
+
+ if is_object(v) && v instanceof "Phalcon\Db\RawValue" {
+ let wherePk[] = connection->escapeIdentifier(field) . " = " . v;
+ let seen_rawvalue = 1;
+ }
+ else {
+ let uniqueTypes[] = type,
+ wherePk[] = connection->escapeIdentifier(field) . " = ?";
+ }
}
/**
@@ -965,8 +970,11 @@ abstract class Model implements Phalcon\Mvc\ModelInterface, Phalcon\Mvc\Model\Re
/**
* The unique key is composed of 3 parts _uniqueKey, uniqueParams, uniqueTypes
*/
- let this->_uniqueKey = joinWhere,
- this->_uniqueParams = uniqueParams,
+ if !seen_rawvalue {
+ let this->_uniqueKey = joinWhere;
+ }
+
+ let this->_uniqueParams = uniqueParams,
this->_uniqueTypes = uniqueTypes,
uniqueKey = joinWhere;
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #1534