Skip to main content

AsSQLTrim

property AsSQLTrim: String read write;

Example

procedure ScriptEvent(var Value: variant);
var
Text: TJSONString;
Item: TJSONValue;
begin
Text := TJSONString.Create;
try
Item := Text;
Item.AsString := ' ready ';
Value := Item.AsSQLTrim; // 'ready'
finally
Text.Free;
end;
end;

Usage

AsSQLTrim trims and quotes legacy SQL-like text while retaining the same lossy non-inverse setter as AsSQL.

Additional Technical Info

The getter obtains the null-aware value, trims leading/trailing characters handled by Delphi Trim, then calls Velox SafeSQL. SafeSQL removes NUL characters, doubles apostrophes and adds outer apostrophes. Null, empty and whitespace-only values all become ''; this is quoted empty text, not SQL NULL.

The setter is not the inverse. Like AsSQL, it applies Copy(Value, 2, Length(Value)-3) without validating quotation, losing the first and final two characters of normal input. It collapses doubled apostrophes, trims the already truncated text, then invokes the concrete virtual setter. Assigning this property's own output loses the final payload character for a normal nonempty value.

Trimming is destructive and uses Delphi's exact UnicodeString overload. Do not use the property where boundary whitespace is data, and do not use either SQL helper as a substitute for query parameters. A concrete scalar parse or container replacement can raise; no rollback restores the old value/null state.

External references

Created 2026-07-15