-
-
Notifications
You must be signed in to change notification settings - Fork 505
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
[WIP] Feature sharding #325
Changes from all commits
d90bba9
b6e2885
4398382
76b3528
373cecc
9257840
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,8 @@ final class DiscriminatorField extends Annotation | |
final class DiscriminatorMap extends Annotation {} | ||
/** @Annotation */ | ||
final class DiscriminatorValue extends Annotation {} | ||
/** @Annotation */ | ||
final class QueryFields extends Annotation {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would make more sense for this to be named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. I will change this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The class-level annotation should be |
||
|
||
/** @Annotation */ | ||
final class Indexes extends Annotation {} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,6 +182,11 @@ class ClassMetadataInfo implements \Doctrine\Common\Persistence\Mapping\ClassMet | |
*/ | ||
public $requireIndexes = false; | ||
|
||
/** | ||
* READ-ONLY: The fields for the query for the document collection. | ||
*/ | ||
public $queryFields = array(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming this |
||
|
||
/** | ||
* READ-ONLY: The name of the document class. | ||
*/ | ||
|
@@ -681,6 +686,43 @@ public function hasIndexes() | |
return $this->indexes ? true : false; | ||
} | ||
|
||
/** | ||
* Returns the custom query fields for this Document. | ||
* | ||
* @return array $fields The fields for the query. | ||
*/ | ||
public function getQueryFields() | ||
{ | ||
return $this->queryFields; | ||
} | ||
|
||
/** | ||
* Checks whether this document has custom query fields or not. | ||
* | ||
* @return boolean | ||
*/ | ||
public function hasQueryFields() | ||
{ | ||
return (boolean) $this->queryFields; | ||
} | ||
|
||
/** | ||
* Sets the custom query fields for this Document. | ||
* | ||
* @param array $fields Array of fields for the query. | ||
*/ | ||
public function setQueryFields($fields) | ||
{ | ||
$fields = is_array($fields) ? $fields : array($fields); | ||
foreach ($fields as $field) { | ||
if (strpos($field, '.') !== false) { | ||
return new MongoDBException(sprintf('Embedded or reference shard keys not supported. Key "%s" in class "%s"', $field, $this->name)); | ||
} | ||
} | ||
|
||
$this->queryFields = $fields; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $this->queryFields = is_array($fields) ? $fields : array($fields); Imo easier to read. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed in the next commits There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes easier, but using if () provide better performance, what is more important? |
||
} | ||
|
||
/** | ||
* Sets the change tracking policy used by this class. | ||
* | ||
|
@@ -1123,6 +1165,17 @@ public function addInheritedFieldMapping(array $fieldMapping) | |
$this->fieldMappings[$fieldMapping['fieldName']] = $fieldMapping; | ||
} | ||
|
||
/** | ||
* Gets the database field name. | ||
* | ||
* @param string $fieldName | ||
* @return string | ||
*/ | ||
public function getDatabaseFieldName($fieldName) | ||
{ | ||
return $this->fieldMappings[$fieldName]['name']; | ||
} | ||
|
||
/** | ||
* Checks whether the class has a mapped association with the given field name. | ||
* | ||
|
@@ -1289,7 +1342,7 @@ public function getIdentifierValue($document) | |
if ($document instanceof Proxy && !$document->__isInitialized()) { | ||
return $document->__identifier__; | ||
} | ||
return (string) $this->reflFields[$this->identifier]->getValue($document); | ||
return $this->reflFields[$this->identifier]->getValue($document); | ||
} | ||
|
||
/** | ||
|
@@ -1346,6 +1399,30 @@ public function getFieldValue($document, $field) | |
return $this->reflFields[$field]->getValue($document); | ||
} | ||
|
||
/** | ||
* Casts the field value to its php type. | ||
* | ||
* @param mixed $value | ||
* @param string $field | ||
*/ | ||
public function getPHPFieldValue($value, $field) | ||
{ | ||
$type = $this->fieldMappings[$field]['type']; | ||
return Types\Type::getType($type)->convertToPHPValue($value); | ||
} | ||
|
||
/** | ||
* Casts the field value to its database type. | ||
* | ||
* @param mixed $value | ||
* @param string $field | ||
*/ | ||
public function getDatabaseFieldValue($value, $field) | ||
{ | ||
$type = $this->fieldMappings[$field]['type']; | ||
return Types\Type::getType($type)->convertToDatabaseValue($value); | ||
} | ||
|
||
/** | ||
* Gets the mapping of a field. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the
$sort
parameter used for, if this is for creating a proxy object?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes its for the inverse side proxy. in this case we need the
$sort
parameter