mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-11 08:24:57 +03:00
feat(skd): nilValue marker для параметров с xsi:nil="true"
Параметры со скалярным типом (decimal/string/dateTime) и <value xsi:nil="true"/>
теперь сохраняют значение nil через object form {nilValue:true}. Раньше compile
эмитил типизированный default (xs:decimal>0, xs:string/>, xs:dateTime>0001-01-01)
вместо nil — мismatch на bit-perfect round-trip.
sample30: −22 строки (2034 → 2012).
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# skd-compile v1.72 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.73 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -1273,6 +1273,9 @@ function Emit-SingleParam {
|
||||
if (Test-EmptyValue $parsed.value) {
|
||||
if (-not $vla) { X "`t`t<value xsi:nil=`"true`"/>" }
|
||||
}
|
||||
} elseif ($parsed.nilValue -eq $true) {
|
||||
# Принудительный xsi:nil даже когда тип известен (для bit-perfect round-trip).
|
||||
if (-not $vla) { X "`t`t<value xsi:nil=`"true`"/>" }
|
||||
} else {
|
||||
Emit-ParamValue -type $parsed.type -val $parsed.value -indent "`t`t" -valueListAllowed $vla
|
||||
}
|
||||
@@ -1379,6 +1382,7 @@ function Emit-Parameters {
|
||||
if ($p.valueListAllowed -eq $true) { $parsed.valueListAllowed = $true }
|
||||
if ($p.hidden -eq $true) { $parsed.hidden = $true }
|
||||
if ($p.autoDates -eq $true) { $parsed.autoDates = $true }
|
||||
if ($p.nilValue -eq $true) { $parsed.nilValue = $true }
|
||||
}
|
||||
|
||||
# @autoDates implies use=Always + denyIncompleteValues=true by default
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# skd-compile v1.72 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.73 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
@@ -1086,6 +1086,10 @@ def emit_single_param(lines, p, parsed):
|
||||
if is_empty_value(parsed.get('value')):
|
||||
if not vla:
|
||||
lines.append('\t\t<value xsi:nil="true"/>')
|
||||
elif parsed.get('nilValue') is True:
|
||||
# Принудительный xsi:nil даже когда тип известен (для bit-perfect round-trip).
|
||||
if not vla:
|
||||
lines.append('\t\t<value xsi:nil="true"/>')
|
||||
else:
|
||||
emit_param_value(lines, p_type, parsed.get('value'), '\t\t', vla)
|
||||
|
||||
@@ -1192,6 +1196,8 @@ def emit_parameters(lines, defn):
|
||||
parsed['hidden'] = True
|
||||
if p.get('autoDates') is True:
|
||||
parsed['autoDates'] = True
|
||||
if p.get('nilValue') is True:
|
||||
parsed['nilValue'] = True
|
||||
|
||||
# @autoDates implies use=Always + denyIncompleteValues=true by default
|
||||
# (derived &НачалоПериода/&КонецПериода need a populated period).
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# skd-decompile v0.55 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||
# skd-decompile v0.56 — Decompile 1C DCS Template.xml to JSON DSL (draft)
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
@@ -824,6 +824,15 @@ function Render-Parameter {
|
||||
if ($p.expression) { $needsObject = $true }
|
||||
if ($p.notAField) { $needsObject = $true }
|
||||
|
||||
# valueIsNil на non-композитном типе требует object form, чтобы compile
|
||||
# знал что вместо xs:string/xs:decimal-default нужно эмитить xsi:nil="true".
|
||||
# Для ref-типов compile в любом случае эмитит nil, шорткод покрывает.
|
||||
$refTypePattern = '^(Catalog|Document|Enum|ChartOfAccounts|ChartOfCharacteristicTypes|ChartOfCalculationTypes|BusinessProcess|Task|InformationRegister|ExchangePlan|CatalogRef|DocumentRef|EnumRef|ChartOfAccountsRef|ChartOfCharacteristicTypesRef|ChartOfCalculationTypesRef|BusinessProcessRef|TaskRef|InformationRegisterRef|ExchangePlanRef|AnyRef)'
|
||||
$typeIsRef = $false
|
||||
if ($typeShort -is [string] -and $typeShort -match $refTypePattern) { $typeIsRef = $true }
|
||||
$nilNeedsObject = $valueIsNil -and -not $typeIsRef -and $typeShort -and -not ($typeShort -is [array])
|
||||
if ($nilNeedsObject) { $needsObject = $true }
|
||||
|
||||
if (-not $needsObject) {
|
||||
$s = $name
|
||||
if ($title) { $s += " [$title]" }
|
||||
@@ -837,6 +846,7 @@ function Render-Parameter {
|
||||
if ($title) { $obj['title'] = $title }
|
||||
if ($typeShort) { $obj['type'] = $typeShort }
|
||||
if (-not $valueIsNil -and $null -ne $valueDisplay -and $valueDisplay -ne '') { $obj['value'] = $valueDisplay }
|
||||
if ($nilNeedsObject) { $obj['nilValue'] = $true }
|
||||
if ($p.useAttr -and -not $p.autoDates) { $obj['use'] = $p.useAttr }
|
||||
if ($p.denyIncomplete -and -not $p.autoDates) { $obj['denyIncompleteValues'] = $true }
|
||||
if ($p.hidden) { $obj['hidden'] = $true }
|
||||
|
||||
Reference in New Issue
Block a user