Skip to main content
Version: 3.9

QuerySelectExpression 查询选择子句

1. 结构声明

class QuerySelectExpression extends LogicItem {
distinct: boolean = false;
star: boolean = true;
selectElements: Array<QueryAggregateExpression | QueryFieldExpression> = [];
}

2. 节点示例

(1) 示例

AST 如下:

{
"concept": "QuerySelectExpression",
"distinct": false,
"star": true,
"selectElements": [
{
"concept": "QueryFieldExpression",
"isDotStar": true,
"entityAsName": "Product",
"propertyName": "",
"asName": ""
}
]
}

对应的代码如下:

select {
product: Product,
}

(2) 示例

AST 如下:

{
"concept": "QuerySelectExpression",
"distinct": false,
"star": true,
"selectElements": [
{
"concept": "QueryFieldExpression",
"isDotStar": true,
"entityAsName": "OrderProduct",
"propertyName": "",
"asName": ""
},
{
"concept": "QueryFieldExpression",
"isDotStar": true,
"entityAsName": "OrderForm",
"propertyName": "",
"asName": ""
},
{
"concept": "QueryFieldExpression",
"isDotStar": true,
"entityAsName": "Product",
"propertyName": "",
"asName": ""
},
{
"concept": "QueryAggregateExpression",
"asName": "totalAmount",
"aggregateName": "SUM",
"aggregateParam": {
"concept": "QueryFieldExpression",
"isDotStar": false,
"entityAsName": "OrderProduct",
"propertyName": "amount",
"asName": ""
}
}
]
}

对应的代码如下:

select {
orderProduct: OrderProduct,
orderForm: OrderForm,
product: Product,
totalAmount: SUM(OrderProduct.amount),
}