Merge lp:~zorba-coders/zorba/couchbase-view-changes into lp:zorba/couchbase-module

Proposed by Juan Zacarias
Status: Merged
Merged at revision: 29
Proposed branch: lp:~zorba-coders/zorba/couchbase-view-changes
Merge into: lp:zorba/couchbase-module
Diff against target: 218 lines (+41/-12)
9 files modified
examples/example.xq (+1/-1)
examples/example2.xq (+1/-1)
examples/example3.xq (+1/-1)
examples/example4.xq (+1/-1)
src/couchbase.xq (+32/-3)
src/couchbase.xq.src/couchbase.cpp (+1/-1)
src/couchbase.xq.src/couchbase.h (+1/-1)
test/Queries/couchbase_module/connect2.xq (+1/-1)
test/Queries/couchbase_module/view.xq (+2/-2)
To merge this branch: bzr merge lp:~zorba-coders/zorba/couchbase-view-changes
Reviewer Review Type Date Requested Status
Matthias Brantner Pending
Chris Hillery Pending
Review via email: mp+141968@code.launchpad.net

Commit message

Changed the return type of the view function from xs:string to object()

Description of the change

Changed the return type of the view function from xs:string to object()

To post a comment you must log in.
29. By Juan Zacarias

Added comment for the return of functions that return an empty sequence

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/example.xq'
2--- examples/example.xq 2012-11-07 17:08:47 +0000
3+++ examples/example.xq 2013-01-04 21:31:35 +0000
4@@ -7,7 +7,7 @@
5 "password" : null,
6 "bucket" : "default"});
7 variable $view-name := cb:create-view($instance, "zip", "zip", {"key" : "doc.state", "values" : "doc.pop"});
8-variable $data := jn:parse-json(cb:view($instance, $view-name))("rows");
9+variable $data := cb:view($instance, $view-name)("rows");
10 for $d in jn:members($data)
11 let $state := $d("key")
12 group by $state
13
14=== modified file 'examples/example2.xq'
15--- examples/example2.xq 2012-11-07 17:08:47 +0000
16+++ examples/example2.xq 2013-01-04 21:31:35 +0000
17@@ -8,7 +8,7 @@
18 "bucket" : "default"});
19
20 variable $view-name := cb:create-view($instance, "zip", "zip", {"key" : "doc.state", "values" : "doc.pop"});
21-variable $data := jn:parse-json(cb:view($instance, $view-name))("rows");
22+variable $data := cb:view($instance, $view-name)("rows");
23 for $d in jn:members($data)
24 let $state := $d("key")
25 group by $state
26
27=== modified file 'examples/example3.xq'
28--- examples/example3.xq 2012-11-07 17:08:47 +0000
29+++ examples/example3.xq 2013-01-04 21:31:35 +0000
30@@ -8,7 +8,7 @@
31 "bucket" : "default"});
32
33 variable $view-name := cb:create-view($instance, "zip", "zip", {"key" : "doc.state", "values" : "doc.pop"});
34-variable $data := jn:parse-json(cb:view($instance, $view-name))("rows");
35+variable $data := cb:view($instance, $view-name)("rows");
36 for $d in jn:members($data)
37 let $state := $d("key")
38 group by $state
39
40=== modified file 'examples/example4.xq'
41--- examples/example4.xq 2012-11-07 19:33:40 +0000
42+++ examples/example4.xq 2013-01-04 21:31:35 +0000
43@@ -8,7 +8,7 @@
44 "bucket" : "default"});
45
46 variable $view-name := cb:create-view($instance, "zip", "zip", {"key" : "doc.state", "values" : ["doc.pop", "doc.city"]});
47-variable $data := jn:parse-json(cb:view($instance, $view-name))("rows");
48+variable $data := cb:view($instance, $view-name)("rows");
49
50
51 let $city-pop :=
52
53=== modified file 'src/couchbase.xq'
54--- src/couchbase.xq 2012-12-23 09:46:07 +0000
55+++ src/couchbase.xq 2013-01-04 21:31:35 +0000
56@@ -105,6 +105,8 @@
57 :
58 : @error cb:LCB0002 if any error occurs in the communication with
59 : the server.
60+ :
61+ : @return a empty sequence.
62 :)
63 declare %an:sequential function cb:disconnect($db as xs:anyURI)
64 as empty-sequence() external;
65@@ -200,6 +202,7 @@
66 :
67 : @error cb:LCB0002 if any error occurs in the communication with
68 : the server.
69+ : @return a empty sequence.
70 :)
71 declare %an:sequential function cb:remove($db as xs:anyURI, $key as xs:string*)
72 as empty-sequence() external;
73@@ -218,6 +221,7 @@
74 : the server.
75 : @error cb:CB0005 if the number of keys doesn't match the number
76 : of values.
77+ : @return a empty sequence.
78 :)
79 declare %an:sequential function cb:put-text(
80 $db as xs:anyURI,
81@@ -249,7 +253,9 @@
82 : of values.
83 : @error cb:CB0006 if the given encoding is not supported.
84 : @error cb:CB0007 if any of the options is not supported.
85- : @error cb:CB0009 if the given expiration time is not an xs:integer.
86+ : @error cb:CB0009 if the given expiration time is not an xs:integer.
87+ :
88+ : @return a empty sequence.
89 :)
90 declare %an:sequential function cb:put-text(
91 $db as xs:anyURI,
92@@ -269,6 +275,8 @@
93 : the server.
94 : @error cb:CB0005 if the number of keys doesn't match the number
95 : of values.
96+ :
97+ : @return a empty sequence.
98 :)
99 declare %an:sequential function cb:put-binary(
100 $db as xs:anyURI,
101@@ -298,6 +306,8 @@
102 : of values.
103 : @error cb:CB0007 if any of the options is not supported.
104 : @error cb:CB0009 if the given expiration time is not an xs:integer.
105+ :
106+ : @return a empty sequence.
107 :)
108 declare %an:sequential function cb:put-binary(
109 $db as xs:anyURI,
110@@ -314,6 +324,8 @@
111 :
112 : @error cb:LCB0002 if any error occurs in the communication with
113 : the server.
114+ :
115+ : @return a empty sequence.
116 :)
117 declare %an:sequential function cb:flush($db as xs:anyURI)
118 as empty-sequence() external;
119@@ -327,6 +339,8 @@
120 :
121 : @error cb:LCB0002 if any error occurs in the communication with
122 : the server.
123+ :
124+ : @return a empty sequence.
125 :)
126 declare %an:sequential function cb:touch(
127 $db as xs:anyURI,
128@@ -346,8 +360,14 @@
129 :
130 : @return a sequence of strings (as JSON) containing information of the views.
131 :)
132+declare %fn:private %an:sequential function cb:view-text($db as xs:anyURI, $path as xs:string*)
133+ as xs:string* external;
134+
135 declare %an:sequential function cb:view($db as xs:anyURI, $path as xs:string*)
136- as xs:string* external;
137+ as object()*
138+{
139+ jn:parse-json(cb:view-text($db, $path))
140+};
141
142 (:~
143 : Retrieve the content of existing views.
144@@ -366,11 +386,20 @@
145 :
146 : @return a sequence of strings (as JSON) containing information of the views.
147 :)
148+declare %fn:private %an:sequential function cb:view-text(
149+ $db as xs:anyURI,
150+ $path as xs:string*,
151+ $options as object())
152+as xs:string* external;
153+
154 declare %an:sequential function cb:view(
155 $db as xs:anyURI,
156 $path as xs:string*,
157 $options as object())
158-as xs:string* external;
159+as object()*
160+{
161+ jn:parse-json(cb:view-text($db, $path, $options))
162+};
163
164 (:~
165 : Create a document/view.
166
167=== modified file 'src/couchbase.xq.src/couchbase.cpp'
168--- src/couchbase.xq.src/couchbase.cpp 2012-12-18 09:15:12 +0000
169+++ src/couchbase.xq.src/couchbase.cpp 2013-01-04 21:31:35 +0000
170@@ -85,7 +85,7 @@
171 {
172 lFunc = new TouchFunction(this);
173 }
174- else if (localname == "view")
175+ else if (localname == "view-text")
176 {
177 lFunc = new ViewFunction(this);
178 }
179
180=== modified file 'src/couchbase.xq.src/couchbase.h'
181--- src/couchbase.xq.src/couchbase.h 2012-11-06 19:59:19 +0000
182+++ src/couchbase.xq.src/couchbase.h 2013-01-04 21:31:35 +0000
183@@ -552,7 +552,7 @@
184 virtual ~ViewFunction(){}
185
186 virtual zorba::String
187- getLocalName() const { return "view"; }
188+ getLocalName() const { return "view-text"; }
189
190 virtual zorba::ItemSequence_t
191 evaluate( const Arguments_t&,
192
193=== modified file 'test/Queries/couchbase_module/connect2.xq'
194--- test/Queries/couchbase_module/connect2.xq 2012-10-19 21:11:28 +0000
195+++ test/Queries/couchbase_module/connect2.xq 2013-01-04 21:31:35 +0000
196@@ -1,7 +1,7 @@
197 import module namespace cb = "http://www.zorba-xquery.com/modules/couchbase";
198
199 variable $instance := cb:connect({
200- "host": "none",
201+ "host": "12492873009",
202 "username" : null,
203 "password" : null,
204 "bucket" : "default"});
205
206=== modified file 'test/Queries/couchbase_module/view.xq'
207--- test/Queries/couchbase_module/view.xq 2012-11-07 17:08:47 +0000
208+++ test/Queries/couchbase_module/view.xq 2013-01-04 21:31:35 +0000
209@@ -10,8 +10,8 @@
210
211 variable $view-name := cb:create-view($instance, "test-view", "test", {"key":"doc.view"});
212
213-variable $data := jn:parse-json(cb:view($instance, $view-name))("rows");
214+variable $data := cb:view($instance, $view-name)("rows");
215 for $d in jn:members($data)
216-where $d("key") > 0
217+where $d("key") >0
218 return $d
219

Subscribers

People subscribed via source and target branches

to all changes: