Bladeren bron

* Merging revisions 42004,42005,42009,42012 from trunk:
------------------------------------------------------------------------
r42004 | michael | 2019-05-06 09:37:15 +0200 (Mon, 06 May 2019) | 1 line

* Copy connection name in assign
------------------------------------------------------------------------
r42005 | michael | 2019-05-06 09:38:00 +0200 (Mon, 06 May 2019) | 1 line

* Split out processing of SQL so it can be used in editor. Correct LoadFromFile
------------------------------------------------------------------------
r42009 | michael | 2019-05-06 13:45:06 +0200 (Mon, 06 May 2019) | 1 line

* Remove unused unit from uses clause
------------------------------------------------------------------------
r42012 | michael | 2019-05-06 17:47:45 +0200 (Mon, 06 May 2019) | 1 line

* Fix redirect codes (bug ID 0035532)
------------------------------------------------------------------------

git-svn-id: branches/fixes_3_2@42423 -

michael 6 jaren geleden
bovenliggende
commit
1a568f4178

+ 2 - 1
packages/fcl-web/src/base/fphttpclient.pp

@@ -1480,7 +1480,8 @@ begin
     301,
     302,
     303,
-    307,808 : Result:=True;
+    307,
+    308 : Result:=True;
   else
     Result:=False;
   end;

+ 3 - 2
packages/fcl-web/src/restbridge/sqldbrestbridge.pp

@@ -19,7 +19,7 @@ unit sqldbrestbridge;
 interface
 
 uses
-  Classes, SysUtils, DB, SqlTypes, SQLDB, httpdefs, httproute, fpjson, sqldbrestschema, sqldbrestio, sqldbrestdata, sqldbrestauth;
+  Classes, SysUtils, DB, SQLDB, httpdefs, httproute, fpjson, sqldbrestschema, sqldbrestio, sqldbrestdata, sqldbrestauth;
 
 Type
   TRestDispatcherOption = (rdoConnectionInURL,     // Route includes connection :Connection/:Resource[/:ID]
@@ -358,7 +358,7 @@ Type
     Property CORSAllowedOrigins: String Read FCORSAllowedOrigins  Write FCORSAllowedOrigins;
     // Access-Control-Max-Age header value. Set to zero not to send the header
     Property CORSMaxAge : Integer Read FCORSMaxAge Write FCORSMaxAge;
-    // Access-Control-Allow-Credentials header value. Set to zero not to send the header
+    // Access-Control-Allow-Credentials header value. Set to false not to send the header
     Property CORSAllowCredentials : Boolean Read FCORSAllowCredentials Write FCORSAllowCredentials;
     // UserIDs of the user(s) that are allowed to see and modify the connection resource.
     Property AdminUserIDs : TStrings Read FAdminUserIDs Write SetAdminUserIDS;
@@ -2312,6 +2312,7 @@ begin
     DatabaseName:=C.DatabaseName;
     ConnectionType:=C.ConnectionType;
     Port:=C.Port;
+    Name:=C.Name;
     SchemaName:=C.SchemaName;
     Params.Assign(C.Params);
     end

+ 18 - 5
packages/fcl-web/src/restbridge/sqldbrestschema.pp

@@ -49,6 +49,7 @@ Const
   JSONSchemaRoot = 'schema';
   JSONResourcesRoot = 'resources';
   JSONConnectionsRoot = 'connections';
+  JSONConnectionName = 'connectionName';
 
 Type
 
@@ -200,6 +201,7 @@ Type
     function GetFieldList(aListKind: TFieldListKind; ASep : String = ''): UTF8String;
     function GetFieldArray(aListKind: TFieldListKind): TSQLDBRestFieldArray;
     Function GetResolvedSQl(aKind : TSQLKind; Const AWhere : UTF8String; Const aOrderBy : UTF8String = ''; aLimit : UTF8String = '') : UTF8String;
+    Function ProcessSQl(aSQL : String; Const AWhere : UTF8String; Const aOrderBy : UTF8String = ''; aLimit : UTF8String = '') : UTF8String;
     Procedure PopulateFieldsFromFieldDefs(Defs : TFieldDefs; aIndexFields : TStringArray; aProcessIdentifier : TProcessIdentifier; aMinFieldOpts : TRestFieldOptions);
     Property SQL [aKind : TSQLKind] : TStrings Read GetSQLTyped;
     Property BusinessProcessor : TSQLDBRestCustomBusinessProcessor Read FBusinessProcessor;
@@ -521,7 +523,7 @@ end;
 function TSQLDBRestSchema.AsJSON(const aPropName: UTF8String): TJSONData;
 
 begin
-  Result:=TJSONObject.Create([JSONResourcesRoot,Resources.AsJSON(),'connectionName',ConnectionName]);
+  Result:=TJSONObject.Create([JSONResourcesRoot,Resources.AsJSON(),JSONConnectionName,ConnectionName]);
   if (aPropName<>'') then
     Result:=TJSONObject.Create([aPropName,Result]);
 end;
@@ -559,8 +561,10 @@ Var
 
 begin
   J:=aData as TJSONObject;
+  if (aPropName<>'') then
+    J:=J.Objects[aPropName];
   Resources.FromJSON(J,JSONResourcesRoot);
-  ConnectionName:=J.Get(aPropName,'');
+  ConnectionName:=J.Get(JSONConnectionName,'');
   AttachAllProcessors;
 end;
 
@@ -1159,13 +1163,21 @@ function TSQLDBRestResource.GetResolvedSQl(aKind: TSQLKind;
   const AWhere: UTF8String; const aOrderBy: UTF8String; aLimit: UTF8String
   ): UTF8String;
 
-Var
-  S : UTF8String;
-
 begin
   Result:=SQL[aKind].Text;
   if (Result='') then
     Result:=GenerateDefaultSQL(aKind);
+  Result:=ProcessSQL(Result,aWhere,aOrderBy,aLimit);
+end;
+
+function TSQLDBRestResource.ProcessSQl(aSQL: String; const AWhere: UTF8String;
+  const aOrderBy: UTF8String; aLimit: UTF8String): UTF8String;
+
+Var
+  S : UTF8String;
+
+begin
+  Result:=aSQL;
   if (aWhere<>'') then
     S:='WHERE '+aWhere
   else
@@ -1240,6 +1252,7 @@ begin
       Exclude(O,foFilter);
       end;
     F:=Fields.AddField(FN,RFT,O);
+    F.NativeFieldType:=FD.DataType;
     if F.FieldType=rftString then
       F.MaxLen:=FD.Size;
     F.PublicName:=PN;