search by opted out and bool where redefinition in ORM

This commit is contained in:
yuri
2018-08-30 11:30:33 +03:00
parent cb42bfe8e7
commit 7c1d587ae0
2 changed files with 37 additions and 2 deletions
@@ -88,7 +88,16 @@ class Email extends Base
$fieldName .'IsOptedOut' => array(
'type' => 'bool',
'notStorable' => true,
'select' => 'emailAddresses.opt_out'
'select' => 'emailAddresses.opt_out',
'where' => [
'= TRUE' => [
'sql' => 'emailAddresses.opt_out = true AND emailAddresses.opt_out IS NOT NULL'
],
'= FALSE' => [
'sql' => 'emailAddresses.opt_out = false OR emailAddresses.opt_out IS NULL'
]
],
'orderBy' => 'emailAddresses.opt_out {direction}'
)
),
'relations' => array(
+27 -1
View File
@@ -856,7 +856,33 @@ abstract class Base
$fieldDefs = $entity->fields[$field];
$operatorModified = $operator;
if (is_array($value)) {
$attributeType = null;
if (!empty($fieldDefs['type'])) {
$attributeType = $fieldDefs['type'];
}
if (
is_bool($value)
&&
in_array($operator, ['=', '<>'])
&&
$attributeType == IEntity::BOOL
) {
if ($value) {
if ($operator === '=') {
$operatorModified = '= TRUE';
} else {
$operatorModified = '= FALSE';
}
} else {
if ($operator === '=') {
$operatorModified = '= FALSE';
} else {
$operatorModified = '= TRUE';
}
}
} else if (is_array($value)) {
if ($operator == '=') {
$operatorModified = 'IN';
} else if ($operator == '<>') {