Skip to content

Commit 135dd2f

Browse files
committed
MAGETWO-65420: Update reports definitions for the Advanced Reporting service
1 parent b8bb664 commit 135dd2f

File tree

11 files changed

+39
-19
lines changed

11 files changed

+39
-19
lines changed

app/code/Magento/Analytics/ReportXml/DB/ColumnsResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Magento\Analytics\ReportXml\DB;
88

9-
use Magento\Framework\DB\Sql\JsonSerializableExpression;
9+
use Magento\Framework\DB\Sql\ColumnValueExpression;
1010

1111
/**
1212
* Class ColumnsResolver
@@ -53,7 +53,7 @@ public function getColumns(SelectBuilder $selectBuilder, $entityConfig)
5353
if (isset($attributeData['distinct']) && $attributeData['distinct'] == true) {
5454
$prefix = ' DISTINCT ';
5555
}
56-
$expression = new JsonSerializableExpression(
56+
$expression = new ColumnValueExpression(
5757
strtoupper($attributeData['function']) . '(' . $prefix . $tableAlias . '.' . $columnName . ')'
5858
);
5959
} else {

app/code/Magento/Analytics/ReportXml/DB/ConditionResolver.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Analytics\ReportXml\DB;
88

99
use Magento\Framework\App\ResourceConnection;
10+
use Magento\Framework\DB\Sql\MagentoDbExpression;
1011

1112
/**
1213
* Class ConditionResolver
@@ -87,7 +88,7 @@ private function getValue($condition, $referencedEntity)
8788
$value = $this->getConnection()->quote($argument);
8889
break;
8990
case "variable":
90-
$value = new \Zend_Db_Expr($argument);
91+
$value = new MagentoDbExpression($argument);
9192
break;
9293
case "identifier":
9394
$value = $this->getConnection()->quoteIdentifier(
@@ -110,7 +111,9 @@ private function getValue($condition, $referencedEntity)
110111
private function getCondition(SelectBuilder $selectBuilder, $tableName, $condition, $referencedEntity = null)
111112
{
112113
$columns = $selectBuilder->getColumns();
113-
if (isset($columns[$condition['attribute']]) && $columns[$condition['attribute']] instanceof \Zend_Db_Expr) {
114+
if (isset($columns[$condition['attribute']])
115+
&& $columns[$condition['attribute']] instanceof MagentoDbExpression
116+
) {
114117
$expression = $columns[$condition['attribute']];
115118
} else {
116119
$expression = $tableName . '.' . $condition['attribute'];

app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ColumnsResolverTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Magento\Analytics\ReportXml\DB\NameResolver;
99
use Magento\Analytics\ReportXml\DB\ColumnsResolver;
1010
use Magento\Analytics\ReportXml\DB\SelectBuilder;
11-
use Magento\Framework\DB\Sql\JsonSerializableExpression;
11+
use Magento\Framework\DB\Sql\ColumnValueExpression;
1212

1313
/**
1414
* Class ColumnsResolverTest
@@ -57,7 +57,7 @@ public function testGetColumnsWithoutAttributes()
5757
public function testGetColumns($expression, $attributeData)
5858
{
5959
$columnAlias = 'fn';
60-
$expr = new JsonSerializableExpression($expression);
60+
$expr = new ColumnValueExpression($expression);
6161
$expectedResult = [$columnAlias => $expr];
6262
$columns = [$columnAlias => 'name'];
6363
$entityConfig['attribute'] = ['attribute1' => $attributeData];

app/code/Magento/Analytics/Test/Unit/ReportXml/DB/ConditionResolverTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\App\ResourceConnection;
1010
use Magento\Analytics\ReportXml\DB\SelectBuilder;
1111
use Magento\Framework\DB\Adapter\AdapterInterface;
12+
use Magento\Framework\DB\Sql\MagentoDbExpression;
1213

1314
/**
1415
* Class ConditionResolverTest
@@ -80,7 +81,7 @@ public function testGetFilter()
8081

8182
$this->selectBuilderMock->expects($this->any())
8283
->method('getColumns')
83-
->willReturn(['price' => new \Zend_Db_Expr("(n.price = 400)")]);
84+
->willReturn(['price' => new MagentoDbExpression("(n.price = 400)")]);
8485

8586
$this->resourceConnectionMock->expects($this->once())
8687
->method('getConnection')

lib/internal/Magento/Framework/DB/Sql/ColumnValueExpression.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@
55
*/
66
namespace Magento\Framework\DB\Sql;
77

8-
use Magento\Framework\App\ResourceConnection;
9-
use Magento\Framework\DB\Adapter\AdapterInterface;
10-
118
/**
129
* Class Column Value Expression
1310
*
14-
* Just a wrapper over Zend_Db_Expr to eliminate direct dependency on it
11+
* Just a wrapper over MagentoDbExpression for implementing the specific type of expression.
1512
* @api
1613
*/
17-
class ColumnValueExpression extends \Zend_Db_Expr
14+
class ColumnValueExpression extends MagentoDbExpression
1815
{
1916
}

lib/internal/Magento/Framework/DB/Sql/ConcatExpression.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* Class Concat
1313
*/
14-
class ConcatExpression extends \Zend_Db_Expr
14+
class ConcatExpression extends MagentoDbExpression
1515
{
1616
/**
1717
* @var AdapterInterface

lib/internal/Magento/Framework/DB/Sql/LimitExpression.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Class LimitExpression
1010
*/
11-
class LimitExpression extends \Zend_Db_Expr
11+
class LimitExpression extends MagentoDbExpression
1212
{
1313
/**
1414
* @var string

lib/internal/Magento/Framework/DB/Sql/LookupExpression.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/**
1313
* Class LookupExpression
1414
*/
15-
class LookupExpression extends \Zend_Db_Expr
15+
class LookupExpression extends MagentoDbExpression
1616
{
1717

1818
/**

lib/internal/Magento/Framework/DB/Sql/JsonSerializableExpression.php renamed to lib/internal/Magento/Framework/DB/Sql/MagentoDbExpression.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
*/
66
namespace Magento\Framework\DB\Sql;
77

8-
use Zend\Stdlib\JsonSerializable;
9-
108
/**
119
* Class is wrapper over Zend_Db_Expr for implement JsonSerializable interface.
1210
*/
13-
class JsonSerializableExpression extends \Zend_Db_Expr implements JsonSerializable
11+
class MagentoDbExpression extends \Zend_Db_Expr implements MagentoDbExpressionInterface
1412
{
1513
/**
1614
* @inheritdoc
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\DB\Sql;
7+
8+
use Zend\Stdlib\JsonSerializable;
9+
10+
/**
11+
* Interface MagentoDbExpressionInterface
12+
*
13+
* Defines interface was implemented in Zend_Db_Expr.
14+
*/
15+
interface MagentoDbExpressionInterface extends JsonSerializable
16+
{
17+
/**
18+
* @inheritdoc
19+
*/
20+
public function __toString();
21+
}

0 commit comments

Comments
 (0)