Skip to content

Commit e397ca8

Browse files
author
Jareth Hein
committed
Complete previous change to DoQuery
Handle cases of no query string properly, and support column lists. Also remove a VS2015ism for backwords compatibility
1 parent 19c988f commit e397ca8

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

Intuit.QuickBase.Client/QTable.cs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ private void _doQuery(DoQuery qry)
181181
//split into smaller queries automagically
182182
List<string> optionsList = new List<string>();
183183
string query = qry.Query;
184+
string collist = qry.Collist;
184185
int maxCount = 0;
185186
int baseSkip = 0;
186187
if (!string.IsNullOrEmpty(qry.Options))
@@ -204,10 +205,15 @@ private void _doQuery(DoQuery qry)
204205
}
205206
if (maxCount == 0)
206207
{
207-
var doQuery = new DoQueryCount.Builder(Application.Client.Ticket, Application.Token, Application.Client.AccountDomain, TableId)
208-
.SetQuery(query)
209-
.Build();
210-
var cntXml = doQuery.Post().CreateNavigator();
208+
DoQueryCount dqryCnt;
209+
if (string.IsNullOrEmpty(query))
210+
dqryCnt = new DoQueryCount.Builder(Application.Client.Ticket, Application.Token, Application.Client.AccountDomain, TableId)
211+
.Build();
212+
else
213+
dqryCnt = new DoQueryCount.Builder(Application.Client.Ticket, Application.Token, Application.Client.AccountDomain, TableId)
214+
.SetQuery(query)
215+
.Build();
216+
var cntXml = dqryCnt.Post().CreateNavigator();
211217
maxCount = int.Parse(cntXml.SelectSingleNode("/qdbapi/numMatches").Value);
212218
}
213219
int stride = maxCount/2;
@@ -216,18 +222,26 @@ private void _doQuery(DoQuery qry)
216222
{
217223
List<string> optLst = new List<string>();
218224
optLst.AddRange(optionsList);
219-
optLst.Add($"skp-{fetched + baseSkip}");
220-
optLst.Add($"num-{stride}");
225+
optLst.Add("skp-" + (fetched + baseSkip));
226+
optLst.Add("num-" + stride);
221227
string options = string.Join(".",optLst);
222-
var doQuery = new DoQuery.Builder(Application.Client.Ticket, Application.Token, Application.Client.AccountDomain, TableId)
223-
.SetQuery(query)
224-
.SetCList("a")
225-
.SetOptions(options)
226-
.SetFmt(true)
227-
.Build();
228+
DoQuery dqry;
229+
if (string.IsNullOrEmpty(query))
230+
dqry = new DoQuery.Builder(Application.Client.Ticket, Application.Token, Application.Client.AccountDomain, TableId)
231+
.SetCList(collist)
232+
.SetOptions(options)
233+
.SetFmt(true)
234+
.Build();
235+
else
236+
dqry = new DoQuery.Builder(Application.Client.Ticket, Application.Token, Application.Client.AccountDomain, TableId)
237+
.SetQuery(query)
238+
.SetCList(collist)
239+
.SetOptions(options)
240+
.SetFmt(true)
241+
.Build();
228242
try
229243
{
230-
XPathNavigator xml = doQuery.Post().CreateNavigator();
244+
XPathNavigator xml = dqry.Post().CreateNavigator();
231245
if (fetched == 0) LoadColumns(xml);
232246
LoadRecords(xml);
233247
fetched += stride;

Intuit.QuickBase.Core/DoQuery.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class DoQuery : IQObject
2727
private readonly IQUri _uri;
2828
private readonly string _options;
2929
private readonly string _query;
30+
private readonly string _collist;
3031

3132
public class Builder
3233
{
@@ -129,6 +130,7 @@ private DoQuery(Builder builder)
129130
.Build();
130131
_options = builder.Options;
131132
_query = builder.Query;
133+
_collist = builder.CList;
132134
_doQueryPayload = new ApplicationTicket(_doQueryPayload, builder.Ticket);
133135
_doQueryPayload = new ApplicationToken(_doQueryPayload, builder.AppToken);
134136
_doQueryPayload = new WrapPayload(_doQueryPayload);
@@ -145,6 +147,11 @@ public string Query
145147
get { return _query; }
146148
}
147149

150+
public string Collist
151+
{
152+
get { return _collist; }
153+
}
154+
148155
public string XmlPayload
149156
{
150157
get

0 commit comments

Comments
 (0)