You are not logged in.
Pages: 1
A few problems I've stumbled into:
1. When using "stored AS_UNIQUE" or a calculated property like "discountedprice" below, those properties is lost using ObjectToJSON.
Why? and what can I do about it?
2. Why do I get the new function: "function AS_UNIQUE" when I press (ctrl-shift C)?
Is it possible to avoid?
Below a sample code:
TProduct = class(TSynAutoCreateFields)
private
fName: TProductName;
fPrice: TPrice;
fDiscount: TDiscount;
function getDiscountedPrice: TPrice;
function AS_UNIQUE: Boolean; <<<<----- Will be automatically created on (ctrl-shift C)
public
constructor create(const aName: TProductName; const aPrice: TPrice;
const aDiscount: TDiscount); overload;
class procedure RegressionTests(test: TSynTestCase);
published
property productName: TProductName index 80 read fName stored AS_UNIQUE;
property price: TPrice read fPrice write fPrice;
property discount: TDiscount read fDiscount write fDiscount;
property discountedPrice: TPrice read getDiscountedPrice;
end;
============
procedure T
var b,c: TProduct;
jsonC, jsonB: RawUTF8;
begin
c := TProduct.Create('HardDrive 2TB',12.5,5.0);
with test do
try
jsonC := ObjectToJSON(c)+'*';
---->>>> jsonC will not contain productName nor discountedPrice.
Delphi-11, WIN10
Offline
Hi,
1. AS_UNIQUE is meant to be used with TSQLRecord descendants only, it does not have the same meaning elsewhere.
Its value is False, so in your case for an ordinary published property it means "Do not store".
2. Its a code completion bug, I haven't found a solution yet.
Offline
Pages: 1