Files
dataease/backend/src/main/resources/sql/sqlTemplate.stg
2021-12-07 17:13:36 +08:00

62 lines
1.7 KiB
Plaintext

querySql(limitFiled, groups, aggregators, filters, orders, table)
::=<<
SELECT
<if(limitFiled)>
<limitFiled.limitFiled>
<endif>
<if(!groups && !aggregators)>
*
<endif>
<if(groups)>
<groups:{group|<if(group)><group.fieldName> AS <group.fieldAlias><endif>}; separator=",\n">
<endif>
<if(groups && aggregators)>,<endif>
<if(aggregators)>
<aggregators:{agg|<if(agg)><agg.fieldName> AS <agg.fieldAlias><endif>}; separator=",\n">
<endif>
FROM
<table.tableName> <table.tableAlias>
<if(filters)>
WHERE
<filters:{filter|<if(filter)><filter.whereField> <filter.whereTermAndValue><endif>}; separator="\nAND ">
<endif>
<if(groups)>
GROUP BY
<groups:{group|<if(group)><group.fieldName><endif>}; separator=",\n">
<endif>
<if(orders)>
ORDER BY
<orders:{order|<if(order)><order.orderAlias> <order.orderDirection><endif>}; separator=",\n">
<endif>
>>
previewSql(groups, aggregators, filters, orders, table, isGroup)
::=<<
SELECT
<if(!groups && !aggregators)>
*
<endif>
<if(groups)>
<groups:{group|<if(group)><group.fieldName> AS <group.fieldAlias><endif>}; separator=",\n">
<endif>
<if(groups && aggregators)>,<endif>
<if(aggregators)>
<aggregators:{agg|<if(agg)><agg.fieldName> AS <agg.fieldAlias><endif>}; separator=",\n">
<endif>
FROM
<table.tableName> <table.tableAlias>
<if(filters)>
WHERE
<filters:{filter|<if(filter)><filter.whereField> <filter.whereTermAndValue><endif>}; separator="\nAND ">
<endif>
<if(isGroup && groups)>
GROUP BY
<groups:{group|<if(group)><group.fieldName><endif>}; separator=",\n">
<endif>
<if(orders)>
ORDER BY
<orders:{order|<if(order)><order.orderAlias> <order.orderDirection><endif>}; separator=",\n">
<endif>
>>