Rules: properties
Properties
Property rules
-
The assistant MUST NOT declare a property if it is used only once.
Exception: a property may still be declared if it is added to a form.
-
Every property parameter MUST be used in its expression. Unused parameters are forbidden.
-
The assistant MUST assume standard
NULLpropagation for property expressions: if any operand isNULL, the result isNULL. ANULLargument acts only through the operands that use it: with aDATApropertya,OVERRIDE a(x, d), b(x)isb(x)for aNULLdated. To getNULL, use(OVERRIDE a(x, d), b(x)) IF d IS DATE. InGROUP, however, an upper parameterdin an aggregate operand is a grouping:NULLhas no group, even withNOT d OR .... A value for that case MUST be selected outsideGROUP(IF d THEN ... ELSE ...), see composition.Exceptions that do NOT nullify on one
NULLoperand: the selection operators —OVERRIDE(returns the first non-NULLoperand) andIF ... THEN ... ELSE, which returns the selected value as is (ELSEfor aNULLcondition,THENotherwise), soIF TRUE THEN NULL ELSE 1isNULL—MIN/MAX, the arithmetic(+)/(-)(numeric only: it does not concatenate strings),CONCAT(concatenation skipsNULLwith its separator), andGROUPaggregates (GROUP SUM,GROUP MAX, etc.) — aNULLoperand or value is skipped.OR,NOTandXORdo not propagate either: a non-NULLoperand reads asTRUE, soNULL OR TRUEandNOT NULLareTRUE.ANDdoes: it isTRUEonly when both operands are non-NULL, soTRUE AND NULLisNULL.GROUP LASTskips aNULLonly withoutWHERE, when non-NULLness of the aggregated expression is the condition. WithWHERE, each matching row contributes its value, includingNULL.These exceptions still yield
NULLwhen:- every operand or aggregated value is
NULL— exceptNOT, which answersTRUEthere; (+)/(-)orGROUP SUMproduces0(zero is returned asNULL).
A custom formula (
FORMULA) runs as written. The platform does not check it against its form's rules. Without the trailingNULLthe SQL text MUST returnNULLwhen any argument isNULL: an SQL function returning a value forNULLinput (concat,COALESCE,string_to_arraywith aNULLdelimiter) needs an explicit check (CASE WHEN $2 IS NULL THEN NULL ELSE ... END). With the trailingNULLthe SQL text MUST return a non-NULLvalue when any argument is non-NULL, see custom formula. - every operand or aggregated value is
-
The assistant MUST NOT use
GROUPwith aBYblock (includingGROUP AGGR) inside expressions: in a type cast, in arithmetic (including(+)/(-)), as an argument of another property, or as an implementation of an abstract property via+=.Such an operator defines the parameters of its result itself, so it is allowed only as an entire property definition: the right-hand side of a definition via
=or an inline definition in square brackets; in any other position the platform raises the errorBY clause in GROUP operator cannot be used in expressions. To use the result in an expression, the assistant SHOULD first rewrite the operator withoutBY, replacing each grouping with an equality condition on an outer parameter (GROUP SUM f(x) IF g(x) = y). Otherwise, apply the inline form[GROUP ... BY ...](...)to arguments or declare a separate property and refer to it.The restriction is tied specifically to the
BYblock:GROUPwithoutBYtakes its parameters from the outer context and may be used inside expressions.When reasoning about
GROUP AGGR, the assistant MUST treat it asGROUP MAXwith an additional constraint. -
The assistant SHOULD avoid unnecessary conditions when the language semantics already produce the required result.
-
The assistant MUST NOT create a property whose expression is equal to one of its parameters.
-
The assistant MUST NOT create multiple properties with identical expressions.
-
To check whether a property is
NULL, the assistant SHOULD useIF NOT property(...).To check that it is not
NULL, the assistant SHOULD useIF property(...).This applies to a property of any class, not only
BOOLEAN: a condition holds when its value is notNULL, whatever that value is —hasNotes(o) = IF notes(o) THEN TRUEfor aSTRING,isScheduled(o) = IF scheduledAt(o) THEN TRUEfor aDATETIME,hasDepartment(e) = IF department(e) THEN TRUEfor an object-valued property,NOT minSum() OR sum(o) >= minSum()for a bound that passes everything while unset (NOTandORdo not propagateNULL, rule 3).The assistant MUST NOT compare with the
NULLliteral:expr = NULL,expr == NULLandexpr != NULLare ordinary comparisons, and by rule 3 theNULLoperand makes the resultNULLwhateverexprholds —scheduledAt(o) != NULLis neverTRUE, so aFILTERorWHEREon it selects nothing, aSHOWIFon it always hides, anIFon it always takes theELSEbranch — and the server only reports a warning when it loads the module, the code still compiles and starts. -
The assistant SHOULD specify
CHARWIDTHin the property definition rather than in form design.For a simple property composition that only forwards another property, the assistant SHOULD NOT repeat
CHARWIDTHon the derived property unless it must differ. -
For static objects, the assistant MUST NOT use
staticCaptionorstaticNameproperties.The assistant MUST use
captionandnameinstead.This applies to writing as well:
captionandnameare simple compositions over the stored caption and name, so an assignment to them passes into the stored property. A static object's caption is assigned throughcaption; the name must not be changed — changingnameis forbidden by a system constraint.namereturns the static object's canonical name —<namespace>_<Class>.<object>, not the short identifier. When the part after the dot is needed, the assistant SHOULD usebasicNamefrom theUtilssystem module. -
The assistant SHOULD NOT specify an explicit namespace for a property unless necessary.
-
When creating a DATA property — or a simple composition over a DATA property (for example, pulling the name of a related object) — for a single object's own attribute, the assistant MUST deliberately decide whether to place it in the system
idorbasegroup viaIN.Attributes that form the object's business identity and appear in its representation SHOULD go in the
idgroup, and other primary attributes go in thebasegroup (idis nested underbase).A property SHOULD NOT be placed in
idorbasewhen it is not the object's own primary attribute. -
When dividing values of integer classes, the assistant MUST cast one of the operands to
NUMERIC, not the result.The ratio of two integers is integer division, so an outer cast like
NUMERIC[16,4](a * b / c)silently drops the fractional part; the correct form isNUMERIC[16,4](a) * b / c. -
The class of an expression's result can be wider than the classes it is built from, and the assistant MUST account for that wherever a narrower class is required (a
+=implementation above all: the abstract property rules).Arithmetic widens further than it looks:
+and-— likeMIN/MAXand the selection operators — take the common ancestor, widening the whole part and the scale independently, so the result can be wider than either operand:NUMERIC[16,2] + NUMERIC[10,4]isNUMERIC[18,4];*adds both the whole parts and the scales:NUMERIC[16,2] * NUMERIC[10,4]isNUMERIC[26,6];/widens catastrophically: with the default settings its scale is always the maximumNUMERICscale (32), soNUMERIC[16,2] / NUMERIC[16,2]isNUMERIC[48,32].
A
GROUPaggregate mostly keeps the class of what it aggregates — aGROUP SUM,GROUP MAXorGROUP LASTover aNUMERIC[16,2]isNUMERIC[16,2]— but it carries outward whatever that expression already widened to.GROUP CONCATis the aggregate that widens by itself: its result is a string of unlimited length. String concatenation widens as well, summing the operands' lengths:ISTRING[200] + ISTRING[126]isISTRING[326].A narrower class is obtained only by an explicit cast of the whole expression. With operands of integer classes the operand cast of rule 13 does not bound the result — the division still widens to scale
32— so both casts are needed:NUMERIC[16,2](NUMERIC[16,2](a(x)) / b(x)).For a
GROUP SUMoverNUMERICwhose total can exceed the class of its operand, the assistant MUST widen the operand inside the aggregate (GROUP SUM NUMERIC[16,2](x)), not cast the result: the precision of the class is enforced only where the sum is materialized into a column of that class, and the materialization of a subquery happens intermittently, so the overflow can escape a single run, even on a cold server. -
A parameter's class annotation (
prop(SubClass x)) is a signature, not a runtime filter: it resolves same-named properties and sets the signature, but the computed set is determined by the properties used in the expression. Reading a parent-class property with a subclass-annotated parameter still ranges over ALL objects of the parent class (e.g. in aGROUP SUM— silently wrong totals).To restrict the set to a class, the assistant MUST add an explicit
x IS SubClasscondition (or use a property declared on that subclass). -
In the
GROUP ... BYoperator the assistant MUST NOT list in theBYblock the upper parameters used in the operator's expressions: each such parameter is already implicitly a group — a parameter of the created property — and keeps its place in the signature.With an explicit parameter list on the left, the
BYexpressions are mapped in order only to the parameters not used in the expressions; a mismatch in count or classes is an error.In the inline form
[GROUP ... BY ...](...)such parameters are passed automatically: the arguments correspond in order only to theBYexpressions ([GROUP SUM f(x) IF g(x) = s BY h(x)](y)), and listingsamong them is a parameter-count error. The assistant MUST make sure that a name used inside the brackets without a class is already declared outside, earlier in the text: otherwise it silently becomes a parameter of theGROUPitself, and the aggregate runs over all its values. -
MAXandMINare prefix operators over a comma-separated operand list (MAX a, b), not infix ones:a MAX bdoes not parse — the platform reportsno viable alternative at input 'MAX'.The operand list extends as far as the expression allows, so everything after the comma belongs to the operator:
MAX a, b * cisMAX(a, b * c), whilex * MAX a, bis fine as it stands. Where a following operator must apply to the maximum itself, the operator MUST be parenthesized:(MAX a, b) * c.These operators compare the operands of a single row; a maximum across rows is
GROUP MAX. -
AND,OR,XORandNOTalways yieldBOOLEAN(TRUEorNULL), never the value of an operand:name(o) AND active(o)isTRUE, not the name, anda OR bisTRUE, not the first non-NULLvalue. The assistant MUST NOT use them to select or pass a value through. For that useexpr IF condandOVERRIDE a, b. -
The assistant MUST use
GROUP ... WHEREonly withAGGR,NAGGR,CONCATorLAST. ForSUM,MAX,MINandEQUALthe condition goes into the aggregated expression withIF(GROUP MAX f(x) IF cond(x) BY k(x)), because these grouping types do not acceptWHERE— see theGROUPoperator.
Abstract property rules (+=)
-
The value class of a
+=implementation MUST fit within the value class declared on the abstract property. There is no implicit cast — an implementation with a wider class is rejected at server startup with a "wrong value class of implementation" error, whosespecifiedandexpectedlines name the implementation's class and the declared one.An expression that widens the value class — arithmetic above all, and division most of all (rule 14 of the property rules) — the assistant MUST wrap in an explicit cast to the declared class:
f(X x) += NUMERIC[16,2](a(x) / b(x));f(X x) += ISTRING[250](a(x) + b(x));
Ordering rules (ORDER)
-
Where two rows can share an order key and the answer depends on which of them wins — which of two same-date rows is the
GROUP LAST, which of two equal-priority rows aTOP 1takes, where aPARTITION PREVsteps back to — the assistant MUST spell the tiebreak out, usually as the object itself:ORDER date(d), d.The platform does fill an incomplete order in on its own for several of these, so the symptom is not randomness between runs. It is that the row chosen is whichever one a service order over the interfaces selects, which is not what the domain asked for. Writing the tiebreak is how the choice becomes the intended one.
-
A cumulative
PARTITION SUM ... ORDERwith noTOPorOFFSETis the case where a tiebreak MUST NOT be added by reflex. Its default frame gives every row sharing an order key the same cumulative value. Adding a tiebreak changes the result — from a total per group of equal keys to a total per row — which is a decision about the domain, not a safety measure. UnderTOPorOFFSETrule 1 applies as usual: those pick rows, and which rows they pick is worth saying. -
PARTITION LASTdoes not read the order to compute its value: it is the value of the current row.GROUP LASTis the one that picks by order. -
PARTITION(alsoPARTITION UNGROUP) does not split its window by property parameters: to number rows perlocinidx(loc, x) <- PARTITION SUM 1 IF cond(loc, x) ORDER x, the assistant MUST addBY loc, or alllocvalues share a window. This holds inidx(x) <- ...for an action or loop parameterloc, unlessPARTITIONreads aLOCALofxfirst filled withcond(loc, x). InPARTITIONwithoutBY loc,NOTor a one-sided bound gives such alocno source: with no other there, execution fails withSet operation is incorrect. Rows with aNULLsummed expression are outside the window, so under a unique orderSUM 1 IF condalone numbers the rows wherecondholds from 1.