Better exception description and better recognize of boolean type when database doesn't know boolean field types

This commit is contained in:
Daniele Teti 2023-08-08 18:54:44 +02:00
parent c201c916cb
commit 0053885bc1
2 changed files with 3 additions and 3 deletions

View File

@ -1330,7 +1330,7 @@ begin
begin
if [eaCreate, eaUpdate, eaDelete] * lTableMap.fEntityAllowedActions <> [] then
begin
raise Exception.Create('Cannot find TableNameAttribute');
raise Exception.Create('Cannot find TableNameAttribute on class ' + ClassName + ' - [HINT] Is this class decorated with MVCTable and its fields with MVCTableField?');
end;
end;
@ -1390,7 +1390,7 @@ begin
lTableMap.fMap.EndUpdates;
if (lPKCount + lTableMap.fMap.WritableFieldsCount + lTableMap.fMap.ReadableFieldsCount) = 0 then
raise EMVCActiveRecord.Create(
'No fields nor PKs defined. [HINT] Use MVCTableField in private fields');
'No fields nor PKs defined in class ' + ClassName + '. [HINT] Use MVCTableField in private fields');
lTableMap.fPartitionInfoInternal := nil;
ActiveRecordTableMapRegistry.AddTableMap(Self, lTableMap);

View File

@ -1141,7 +1141,7 @@ begin
begin
// sqlite doesn't support boolean, so are identified as integers
// so we need to do some more checks...
if (aRTTIField.FieldType.TypeKind = tkEnumeration) and (aRTTIField.Name.ToLower.Contains('bool')) then
if (aRTTIField.FieldType.TypeKind = tkEnumeration) and (aRTTIField.FieldType.Handle = TypeInfo(Boolean)) then
begin
aRTTIField.SetValue(AObject, AField.AsInteger = 1);
end