Skip to content

Commit 62c2cd1

Browse files
author
Rubens F. N. da Silva
committed
Minor fixes
* Includes missing frontier.inc file * Fixes regular expression used to serve files. * Fixes documentation.
1 parent a81f960 commit 62c2cd1

File tree

5 files changed

+53
-72
lines changed

5 files changed

+53
-72
lines changed

cls/Frontier/SQL/InlineQueryBuilder.cls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Include frontier
66
/// The filter format can be divided into two formats:
77
///
88
/// Simple: fieldnameA_operation:value;fieldnameB_operation:value
9-
/// Composited: _or:[fieldnameA_operation:value;fieldNameA_operation:value]
9+
/// Composited: _or:[fieldnameA_operation:value,fieldNameA_operation:value]
1010
///
1111
/// Supported operations:
1212
///
@@ -249,7 +249,7 @@ Method TransformFilter(filter As %String, value, op As %String) As %String [ Pri
249249
if op = "lt" set expression = filter_" < ?"
250250
if op = "lte" set expression = filter_" <= ?"
251251
if op = "sw" set expression = filter_" %STARTSWITH ? "
252-
if op = "nsw" set expression = filter_" NOT %STARTSWITH ?"
252+
if op = "nsw" set expression = "NOT "_filter_" %STARTSWITH ?"
253253
if op = "ct" set expression = filter_" [ ?"
254254
if op = "nct" set expression = filter_" '[ ?"
255255
if op = "lk" set expression = filter_" LIKE ?"

cls/Frontier/UnitTest/Fixtures/Student.cls

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Storage Default
7878
<Selectivity>50.0000%</Selectivity>
7979
</Property>
8080
<Property name="Adress">
81-
<AverageFieldSize>14.7</AverageFieldSize>
81+
<AverageFieldSize>17</AverageFieldSize>
8282
<Selectivity>10.0000%</Selectivity>
8383
</Property>
8484
<Property name="BirthDate">
@@ -98,11 +98,11 @@ Storage Default
9898
<Selectivity>10.0000%</Selectivity>
9999
</Property>
100100
<Property name="Name">
101-
<AverageFieldSize>15</AverageFieldSize>
101+
<AverageFieldSize>16</AverageFieldSize>
102102
<Selectivity>10.0000%</Selectivity>
103103
</Property>
104104
<Property name="PeriodEnd">
105-
<AverageFieldSize>4.9</AverageFieldSize>
105+
<AverageFieldSize>5</AverageFieldSize>
106106
<Selectivity>10.0000%</Selectivity>
107107
</Property>
108108
<Property name="PeriodStart">

cls/Frontier/UnitTest/Router.cls

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ XData UrlMap [ XMLNamespace = "http://github.com/rfns/frontier" ]
55
{
66
<Routes>
77
<Route Url="/public/single" Method="GET" Call="TestGETSingleStaticFile" />
8-
<Route Url="/public/?(.*)?" Strict="false" Method="GET" Call="TestGETStaticFile"/>
9-
<Route Url="/public/custom/?(.*)?" Strict="false" Method="GET" Call="TestGETStaticFileWithCustomConfig"/>
8+
<Route Url="/public/(.*)" Strict="false" Method="GET" Call="TestGETStaticFile"/>
9+
<Route Url="/public/custom/(.*)" Strict="false" Method="GET" Call="TestGETStaticFileWithCustomConfig"/>
1010
<Route Url="/upload/multi" Method="POST" Call="TestPOSTMultipartFileUpload"/>
1111
<Route Url="/upload" Method="POST" Call="TestPOSTSingleFileUpload"/>
1212
<Route Url="/route-params/:class" Method="GET" Call="TestGETRouteParams"/>
@@ -86,8 +86,6 @@ ClassMethod OnSetup() As %Status
8686
"validator": ($classname()_":ValidateSystemCredentials")
8787
})
8888

89-
set %frontier.StrictQueryParameters = 0
90-
9189
// This uses the cookie generated by the /sign-in route to validate the access.
9290
$$$QuitOnError(%frontier.AuthenticationManager.AddStrategy(cookieStrategy))
9391

@@ -107,7 +105,6 @@ ClassMethod OnSetup() As %Status
107105
/// {"Plate":"O5397","Students":[{"Name":"Drabek,Peter T.","__id__":"20"}],"__id__":"6"}
108106
ClassMethod TestGETRouteParams(class As Frontier.UnitTest.Fixtures.Class) As %Status
109107
{
110-
111108
return class
112109
}
113110

@@ -603,16 +600,5 @@ ClassMethod TestXWWWUrlEncoded(name As %String, birthDate As %String) As %String
603600
return { "name": (name), "birthDate": (birthDate) }
604601
}
605602

606-
ClassMethod T()
607-
{
608-
set agent = ##class(Forgery.Agent).%New()
609-
set sc = agent.Get({
610-
"url": "/api/frontier/test/sql/dynamic",
611-
"headers": {
612-
"Authorization": "Basic Zm9vOmJhcg=="
613-
}
614-
}, .r, 1)
615-
}
616-
617603
}
618604

frontier-prod.xml

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4739,7 +4739,7 @@ You'll probably never have to call it outside the context created by Frontier.
47394739
The filter format can be divided into two formats:
47404740
47414741
Simple: fieldnameA_operation:value;fieldnameB_operation:value
4742-
Composited: _or:[fieldnameA_operation:value;fieldNameA_operation:value]
4742+
Composited: _or:[fieldnameA_operation:value,fieldNameA_operation:value]
47434743
47444744
Supported operations:
47454745
@@ -5048,7 +5048,7 @@ HandleCompositeCondition(condition, conditionType)
50485048
if op = "lt" set expression = filter_" < ?"
50495049
if op = "lte" set expression = filter_" <= ?"
50505050
if op = "sw" set expression = filter_" %STARTSWITH ? "
5051-
if op = "nsw" set expression = filter_" NOT %STARTSWITH ?"
5051+
if op = "nsw" set expression = "NOT "_filter_" %STARTSWITH ?"
50525052
if op = "ct" set expression = filter_" [ ?"
50535053
if op = "nct" set expression = filter_" '[ ?"
50545054
if op = "lk" set expression = filter_" LIKE ?"
@@ -6202,7 +6202,7 @@ rchr(time) Quit ""
62026202
</Property>
62036203
<Property name="Adress">
62046204
<Selectivity>10.0000%</Selectivity>
6205-
<AverageFieldSize>16.2</AverageFieldSize>
6205+
<AverageFieldSize>17</AverageFieldSize>
62066206
</Property>
62076207
<Property name="BirthDate">
62086208
<Selectivity>10.0000%</Selectivity>
@@ -6222,15 +6222,15 @@ rchr(time) Quit ""
62226222
</Property>
62236223
<Property name="Name">
62246224
<Selectivity>10.0000%</Selectivity>
6225-
<AverageFieldSize>17.5</AverageFieldSize>
6225+
<AverageFieldSize>16</AverageFieldSize>
62266226
</Property>
62276227
<Property name="PeriodEnd">
62286228
<Selectivity>10.0000%</Selectivity>
62296229
<AverageFieldSize>5</AverageFieldSize>
62306230
</Property>
62316231
<Property name="PeriodStart">
62326232
<Selectivity>10.0000%</Selectivity>
6233-
<AverageFieldSize>5</AverageFieldSize>
6233+
<AverageFieldSize>4.9</AverageFieldSize>
62346234
</Property>
62356235
<Property name="SomeValue">
62366236
<Selectivity>100.0000%</Selectivity>
@@ -6252,8 +6252,8 @@ rchr(time) Quit ""
62526252
<Data><![CDATA[
62536253
<Routes>
62546254
<Route Url="/public/single" Method="GET" Call="TestGETSingleStaticFile" />
6255-
<Route Url="/public/?(.*)?" Strict="false" Method="GET" Call="TestGETStaticFile"/>
6256-
<Route Url="/public/custom/?(.*)?" Strict="false" Method="GET" Call="TestGETStaticFileWithCustomConfig"/>
6255+
<Route Url="/public/(.*)" Strict="false" Method="GET" Call="TestGETStaticFile"/>
6256+
<Route Url="/public/custom/(.*)" Strict="false" Method="GET" Call="TestGETStaticFileWithCustomConfig"/>
62576257
<Route Url="/upload/multi" Method="POST" Call="TestPOSTMultipartFileUpload"/>
62586258
<Route Url="/upload" Method="POST" Call="TestPOSTSingleFileUpload"/>
62596259
<Route Url="/route-params/:class" Method="GET" Call="TestGETRouteParams"/>
@@ -6342,8 +6342,6 @@ This method is reserved for setting up configurations.</Description>
63426342
"validator": ($classname()_":ValidateSystemCredentials")
63436343
})
63446344
6345-
set %frontier.StrictQueryParameters = 0
6346-
63476345
// This uses the cookie generated by the /sign-in route to validate the access.
63486346
$$$QuitOnError(%frontier.AuthenticationManager.AddStrategy(cookieStrategy))
63496347
@@ -6367,9 +6365,7 @@ curl -H "Content-Type: application/json" 'localhost:57772/api/frontier/test/rout
63676365
<ClassMethod>1</ClassMethod>
63686366
<FormalSpec>class:Frontier.UnitTest.Fixtures.Class</FormalSpec>
63696367
<ReturnType>%Status</ReturnType>
6370-
<Implementation><![CDATA[
6371-
6372-
return class
6368+
<Implementation><![CDATA[ return class
63736369
]]></Implementation>
63746370
</Method>
63756371

@@ -7016,19 +7012,6 @@ The purpose is to show that custom authentication strategies can be used exclusi
70167012
<Implementation><![CDATA[ return { "name": (name), "birthDate": (birthDate) }
70177013
]]></Implementation>
70187014
</Method>
7019-
7020-
<Method name="T">
7021-
<ClassMethod>1</ClassMethod>
7022-
<Implementation><![CDATA[
7023-
set agent = ##class(Forgery.Agent).%New()
7024-
set sc = agent.Get({
7025-
"url": "/api/frontier/test/sql/dynamic",
7026-
"headers": {
7027-
"Authorization": "Basic Zm9vOmJhcg=="
7028-
}
7029-
}, .r, 1)
7030-
]]></Implementation>
7031-
</Method>
70327015
</Class>
70337016

70347017

@@ -7319,4 +7302,25 @@ The purpose is to show that custom authentication strategies can be used exclusi
73197302
]]></Implementation>
73207303
</Method>
73217304
</Class>
7305+
7306+
7307+
<Routine name="frontier" type="INC"><![CDATA[
7308+
#include %ZEN.Utils
7309+
#include %occErrors
7310+
7311+
#define ltrim(%str) $zstrip(%str, "<W")
7312+
#define rtrim(%str) $zstrip(%str, ">W")
7313+
#define trim(%str) $zstrip(%str, "<>W")
7314+
#define trimQuote(%str) $zstrip(%str, "<>", $c(34))
7315+
#define IsSQLQuery(%str) ($$$ucase($extract($$$trim(%str), 6)) = "SELECT")
7316+
#define KeyGroup(%requestKey) $zstrip($zstrip(%requestKey, "<=N"), "=>N")
7317+
#define KeyIndex(%requestKey) $zstrip($zstrip(%requestKey, "<=N"), "<=A")
7318+
#define FormatBoolean(%value) $case(%value, 1: "true", 0: "false", : %value)
7319+
#define BooleanToBinary(%value) $case(%value, "true": 1, "false": 0, : %value)
7320+
#define NormalizeClassName(%cn) if $l(%cn, ".") = 1 && ($e(%cn) = "%") set %cn = "%Library."_$e(%cn, 2, *)
7321+
#define OSSlash $case($$$isWINDOWS, 1: "\", : "/")
7322+
#define AssertClassExists(%o) return:'$isobject(%o) $$$ERROR($$$ClassDoesNotExist, %o)
7323+
#define NULL $s($$$isWINDOWS : "//./nul", 1: "/dev/null")
7324+
#define ObjectOrNull(%obj) $select($isobject(%obj) : %obj, 1: "null")
7325+
]]></Routine>
73227326
</Export>

frontier.xml

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4739,7 +4739,7 @@ You'll probably never have to call it outside the context created by Frontier.
47394739
The filter format can be divided into two formats:
47404740
47414741
Simple: fieldnameA_operation:value;fieldnameB_operation:value
4742-
Composited: _or:[fieldnameA_operation:value;fieldNameA_operation:value]
4742+
Composited: _or:[fieldnameA_operation:value,fieldNameA_operation:value]
47434743
47444744
Supported operations:
47454745
@@ -5048,7 +5048,7 @@ HandleCompositeCondition(condition, conditionType)
50485048
if op = "lt" set expression = filter_" < ?"
50495049
if op = "lte" set expression = filter_" <= ?"
50505050
if op = "sw" set expression = filter_" %STARTSWITH ? "
5051-
if op = "nsw" set expression = filter_" NOT %STARTSWITH ?"
5051+
if op = "nsw" set expression = "NOT "_filter_" %STARTSWITH ?"
50525052
if op = "ct" set expression = filter_" [ ?"
50535053
if op = "nct" set expression = filter_" '[ ?"
50545054
if op = "lk" set expression = filter_" LIKE ?"
@@ -6202,7 +6202,7 @@ rchr(time) Quit ""
62026202
</Property>
62036203
<Property name="Adress">
62046204
<Selectivity>10.0000%</Selectivity>
6205-
<AverageFieldSize>16.2</AverageFieldSize>
6205+
<AverageFieldSize>17</AverageFieldSize>
62066206
</Property>
62076207
<Property name="BirthDate">
62086208
<Selectivity>10.0000%</Selectivity>
@@ -6222,15 +6222,15 @@ rchr(time) Quit ""
62226222
</Property>
62236223
<Property name="Name">
62246224
<Selectivity>10.0000%</Selectivity>
6225-
<AverageFieldSize>17.5</AverageFieldSize>
6225+
<AverageFieldSize>16</AverageFieldSize>
62266226
</Property>
62276227
<Property name="PeriodEnd">
62286228
<Selectivity>10.0000%</Selectivity>
62296229
<AverageFieldSize>5</AverageFieldSize>
62306230
</Property>
62316231
<Property name="PeriodStart">
62326232
<Selectivity>10.0000%</Selectivity>
6233-
<AverageFieldSize>5</AverageFieldSize>
6233+
<AverageFieldSize>4.9</AverageFieldSize>
62346234
</Property>
62356235
<Property name="SomeValue">
62366236
<Selectivity>100.0000%</Selectivity>
@@ -6252,8 +6252,8 @@ rchr(time) Quit ""
62526252
<Data><![CDATA[
62536253
<Routes>
62546254
<Route Url="/public/single" Method="GET" Call="TestGETSingleStaticFile" />
6255-
<Route Url="/public/?(.*)?" Strict="false" Method="GET" Call="TestGETStaticFile"/>
6256-
<Route Url="/public/custom/?(.*)?" Strict="false" Method="GET" Call="TestGETStaticFileWithCustomConfig"/>
6255+
<Route Url="/public/(.*)" Strict="false" Method="GET" Call="TestGETStaticFile"/>
6256+
<Route Url="/public/custom/(.*)" Strict="false" Method="GET" Call="TestGETStaticFileWithCustomConfig"/>
62576257
<Route Url="/upload/multi" Method="POST" Call="TestPOSTMultipartFileUpload"/>
62586258
<Route Url="/upload" Method="POST" Call="TestPOSTSingleFileUpload"/>
62596259
<Route Url="/route-params/:class" Method="GET" Call="TestGETRouteParams"/>
@@ -6342,8 +6342,6 @@ This method is reserved for setting up configurations.</Description>
63426342
"validator": ($classname()_":ValidateSystemCredentials")
63436343
})
63446344
6345-
set %frontier.StrictQueryParameters = 0
6346-
63476345
// This uses the cookie generated by the /sign-in route to validate the access.
63486346
$$$QuitOnError(%frontier.AuthenticationManager.AddStrategy(cookieStrategy))
63496347
@@ -6367,9 +6365,7 @@ curl -H "Content-Type: application/json" 'localhost:57772/api/frontier/test/rout
63676365
<ClassMethod>1</ClassMethod>
63686366
<FormalSpec>class:Frontier.UnitTest.Fixtures.Class</FormalSpec>
63696367
<ReturnType>%Status</ReturnType>
6370-
<Implementation><![CDATA[
6371-
6372-
return class
6368+
<Implementation><![CDATA[ return class
63736369
]]></Implementation>
63746370
</Method>
63756371

@@ -7016,19 +7012,6 @@ The purpose is to show that custom authentication strategies can be used exclusi
70167012
<Implementation><![CDATA[ return { "name": (name), "birthDate": (birthDate) }
70177013
]]></Implementation>
70187014
</Method>
7019-
7020-
<Method name="T">
7021-
<ClassMethod>1</ClassMethod>
7022-
<Implementation><![CDATA[
7023-
set agent = ##class(Forgery.Agent).%New()
7024-
set sc = agent.Get({
7025-
"url": "/api/frontier/test/sql/dynamic",
7026-
"headers": {
7027-
"Authorization": "Basic Zm9vOmJhcg=="
7028-
}
7029-
}, .r, 1)
7030-
]]></Implementation>
7031-
</Method>
70327015
</Class>
70337016

70347017

@@ -8163,7 +8146,7 @@ The purpose is to show that custom authentication strategies can be used exclusi
81638146
]]></Routine>
81648147

81658148

8166-
<Project name="frontier" LastModified="2019-07-25 08:30:49.311671" TargetType="2" HttpServer="http://localhost:57772">
8149+
<Project name="frontier" LastModified="2019-08-13 09:27:09.866402" Target="##class(Frontier.UnitTest.Router).T()" TargetType="2" HttpServer="http://localhost:57772">
81678150
<Items>
81688151
<ProjectItem name="Frontier.AbstractSerializer" type="CLS"></ProjectItem>
81698152
<ProjectItem name="Frontier.ArgumentDescription" type="CLS"></ProjectItem>
@@ -8217,5 +8200,13 @@ The purpose is to show that custom authentication strategies can be used exclusi
82178200
<ProjectItem name="UnitTest.Frontier.Types" type="CLS"></ProjectItem>
82188201
<ProjectItem name="frontier.INC" type="MAC"></ProjectItem>
82198202
</Items>
8203+
<BreakPoints>
8204+
<BreakPoint Routine="Frontier.Router.CLS" Offset="DispatchRequest+24"></BreakPoint>
8205+
<BreakPoint Routine="Frontier.SQL.InlineQueryBuilder.CLS" Offset="CreateWHEREStatement+2"></BreakPoint>
8206+
<BreakPoint Routine="Frontier.SQL.InlineQueryBuilder.CLS" Offset="TransformFilter+4"></BreakPoint>
8207+
</BreakPoints>
8208+
<WatchVariables>
8209+
<WatchVariable Variable="urlExpression" Pane="1"></WatchVariable>
8210+
</WatchVariables>
82208211
</Project>
82218212
</Export>

0 commit comments

Comments
 (0)