mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-08-10 05:23:21 +03:00
fix(skd-compile): identity totalField shorthand treated as aggregation function
When totalField shorthand right-hand side is not a known aggregate function (e.g. "Проверка: Проверка"), emit expression as-is instead of wrapping it as Проверка(Проверка). Known aggregates (Сумма, Количество, etc.) still wrap. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
e2924c4ae0
commit
73242ee60e
@@ -1,4 +1,4 @@
|
||||
# skd-compile v1.8 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.9 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -300,12 +300,20 @@ function Parse-TotalShorthand {
|
||||
$dataPath = $parts[0].Trim()
|
||||
$funcPart = $parts[1].Trim()
|
||||
|
||||
# Known DCS aggregate functions (ru + en)
|
||||
$aggFuncs = @('Сумма','Количество','Минимум','Максимум','Среднее',
|
||||
'Sum','Count','Min','Max','Avg',
|
||||
'Minimum','Maximum','Average')
|
||||
|
||||
if ($funcPart -match '^\w+\(') {
|
||||
# Already has expression form: Func(expr)
|
||||
return @{ dataPath = $dataPath; expression = $funcPart }
|
||||
} else {
|
||||
} elseif ($funcPart -in $aggFuncs) {
|
||||
# Short: Func → Func(DataPath)
|
||||
return @{ dataPath = $dataPath; expression = "$funcPart($dataPath)" }
|
||||
} else {
|
||||
# Identity or custom expression — use as-is
|
||||
return @{ dataPath = $dataPath; expression = $funcPart }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# skd-compile v1.8 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.9 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
@@ -221,10 +221,18 @@ def parse_total_shorthand(s):
|
||||
data_path = parts[0].strip()
|
||||
func_part = parts[1].strip()
|
||||
|
||||
# Known DCS aggregate functions (ru + en)
|
||||
_agg_funcs = {'Сумма','Количество','Минимум','Максимум','Среднее',
|
||||
'Sum','Count','Min','Max','Avg',
|
||||
'Minimum','Maximum','Average'}
|
||||
|
||||
if re.match(r'^\w+\(', func_part):
|
||||
return {'dataPath': data_path, 'expression': func_part}
|
||||
else:
|
||||
elif func_part in _agg_funcs:
|
||||
return {'dataPath': data_path, 'expression': f'{func_part}({data_path})'}
|
||||
else:
|
||||
# Identity or custom expression — use as-is
|
||||
return {'dataPath': data_path, 'expression': func_part}
|
||||
|
||||
|
||||
# --- Parameter shorthand parser ---
|
||||
|
||||
Reference in New Issue
Block a user