mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-14 01:44:57 +03:00
fix(skd): empty xs:string placeholder в SettingsParameterValue use=false
Параметр типа DateTime в dataParameters внутри settings с use=false и
без значения сохраняется оригиналом как <dcscor:value xsi:type="xs:string"/>
(пустой placeholder), а не xsi:nil. См. АнализПлановыхНачислений @1506
для ОкончаниеПериода.
decompile: detect-ит empty xs:string + use=false → object form
{parameter, use:false, value:'', valueType:'xs:string'}.
compile: Emit-EmptyValue нормализует префикс xs: (xs:string → ^string),
теперь корректно эмитит пустой xs:string вместо fallback xsi:nil.
PS и Py синхронизированы.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# skd-compile v1.87 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.88 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -1468,6 +1468,8 @@ function Emit-EmptyValue {
|
||||
|
||||
if ($valueListAllowed) { return }
|
||||
$t = if ($null -eq $type) { "" } else { "$type" }
|
||||
# Нормализация: убираем префикс xs: (валидный для valueType из decompile/DSL)
|
||||
$tBare = if ($t -match '^xs:(.+)$') { $matches[1] } else { $t }
|
||||
$pf = $tagPrefix
|
||||
|
||||
if ($t -eq "") {
|
||||
@@ -1478,13 +1480,13 @@ function Emit-EmptyValue {
|
||||
X "$indent`t<v8:startDate>0001-01-01T00:00:00</v8:startDate>"
|
||||
X "$indent`t<v8:endDate>0001-01-01T00:00:00</v8:endDate>"
|
||||
X "$indent</${pf}value>"
|
||||
} elseif ($t -match '^string') {
|
||||
} elseif ($tBare -match '^string') {
|
||||
X "$indent<${pf}value xsi:type=`"xs:string`"/>"
|
||||
} elseif ($t -match '^(date|time)') {
|
||||
} elseif ($tBare -match '^(date|time)') {
|
||||
X "$indent<${pf}value xsi:type=`"xs:dateTime`">0001-01-01T00:00:00</${pf}value>"
|
||||
} elseif ($t -match '^decimal') {
|
||||
} elseif ($tBare -match '^decimal') {
|
||||
X "$indent<${pf}value xsi:type=`"xs:decimal`">0</${pf}value>"
|
||||
} elseif ($t -eq "boolean") {
|
||||
} elseif ($tBare -eq "boolean") {
|
||||
X "$indent<${pf}value xsi:type=`"xs:boolean`">false</${pf}value>"
|
||||
} else {
|
||||
# Ref types or unknown — safe nil
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# skd-compile v1.87 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.88 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
@@ -1010,6 +1010,8 @@ def emit_empty_value(lines, type_str, indent, tag_prefix='', value_list_allowed=
|
||||
if value_list_allowed:
|
||||
return
|
||||
t = type_str or ''
|
||||
# Нормализация: убираем префикс xs: (валидный для valueType из decompile/DSL)
|
||||
t_bare = t[3:] if t.startswith('xs:') else t
|
||||
pf = tag_prefix
|
||||
|
||||
if t == '':
|
||||
@@ -1020,13 +1022,13 @@ def emit_empty_value(lines, type_str, indent, tag_prefix='', value_list_allowed=
|
||||
lines.append(f'{indent}\t<v8:startDate>0001-01-01T00:00:00</v8:startDate>')
|
||||
lines.append(f'{indent}\t<v8:endDate>0001-01-01T00:00:00</v8:endDate>')
|
||||
lines.append(f'{indent}</{pf}value>')
|
||||
elif re.match(r'^string', t):
|
||||
elif re.match(r'^string', t_bare):
|
||||
lines.append(f'{indent}<{pf}value xsi:type="xs:string"/>')
|
||||
elif re.match(r'^(date|time)', t):
|
||||
elif re.match(r'^(date|time)', t_bare):
|
||||
lines.append(f'{indent}<{pf}value xsi:type="xs:dateTime">0001-01-01T00:00:00</{pf}value>')
|
||||
elif re.match(r'^decimal', t):
|
||||
elif re.match(r'^decimal', t_bare):
|
||||
lines.append(f'{indent}<{pf}value xsi:type="xs:decimal">0</{pf}value>')
|
||||
elif t == 'boolean':
|
||||
elif t_bare == 'boolean':
|
||||
lines.append(f'{indent}<{pf}value xsi:type="xs:boolean">false</{pf}value>')
|
||||
else:
|
||||
# Ref types or unknown — safe nil
|
||||
|
||||
@@ -1868,12 +1868,21 @@ function Build-DataParameters {
|
||||
# Compare to top-level default
|
||||
if ($tp -and $tp.valueDisplay -ne $vDisplay) { $canAuto = $false }
|
||||
if (-not $tp) { $canAuto = $false } # extra param not in top-level
|
||||
# Object form требуется если есть viewMode / userSettingPresentation / StandardPeriod-с-датами
|
||||
if ($stdPeriodObj -or $vmN -or $uspN) {
|
||||
# Empty xs:string + use=false — оригинальный placeholder для disabled-параметра
|
||||
# (используется для типа DateTime в settings; см. АнализПлановыхНачислений @1506).
|
||||
# Сохраняем явный valueType чтобы compile эмитил <value xsi:type="xs:string"/>
|
||||
# вместо xsi:nil.
|
||||
$isEmptyStringPlaceholder = ($vt -eq 'string') -and (-not $valNode.InnerText) -and ($use -eq 'false')
|
||||
if ($isEmptyStringPlaceholder) { $canAuto = $false }
|
||||
# Object form требуется если есть viewMode / userSettingPresentation / StandardPeriod-с-датами / xs:string-placeholder
|
||||
if ($stdPeriodObj -or $vmN -or $uspN -or $isEmptyStringPlaceholder) {
|
||||
$obj = [ordered]@{ parameter = $pn }
|
||||
if ($stdPeriodObj) {
|
||||
$obj['value'] = $stdPeriodObj
|
||||
# valueType не нужен — compile определит StandardPeriod по value.variant
|
||||
} elseif ($isEmptyStringPlaceholder) {
|
||||
$obj['value'] = ''
|
||||
$obj['valueType'] = 'xs:string'
|
||||
} elseif ($null -ne $vDisplay -and $vDisplay -ne '') {
|
||||
# Конвертация для типизированных значений (compile различает по типу JSON)
|
||||
if ($vt -eq 'boolean') { $obj['value'] = ($vDisplay -eq 'true') }
|
||||
|
||||
Reference in New Issue
Block a user