Skip to content

Commit 90c572e

Browse files
Scott DoverScott Dover
authored andcommitted
chore: apply sort to itc connections
Signed-off-by: Scott Dover <[email protected]>
1 parent f2fab8c commit 90c572e

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

client/src/connection/itc/ItcLibraryAdapter.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class ItcLibraryAdapter implements LibraryAdapter {
9898
item,
9999
start,
100100
limit,
101+
sortModel,
101102
);
102103

103104
const rows = rawRowValues.map((line, idx: number): TableRow => {
@@ -179,10 +180,14 @@ class ItcLibraryAdapter implements LibraryAdapter {
179180
item: LibraryItem,
180181
start: number,
181182
limit: number,
183+
sortModel: SortModelItem[],
182184
): Promise<{ rows: Array<string[]>; count: number }> {
185+
const sortString = sortModel
186+
.map((col) => `${col.colId} ${col.sort}`)
187+
.join(",");
183188
const fullTableName = `${item.library}.${item.name}`;
184189
const code = `
185-
$runner.GetDatasetRecords("${fullTableName}", ${start}, ${limit})
190+
$runner.GetDatasetRecords("${fullTableName}", ${start}, ${limit}, "${sortString}")
186191
`;
187192
const output = await executeRawCode(code);
188193
try {

client/src/connection/itc/script.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,17 +244,21 @@ class SASRunner{
244244
Write-Host "${LineCodes.ResultsFetchedCode}"
245245
}
246246
247-
[void]GetDatasetRecords([string]$tableName, [int]$start = 0, [int]$limit = 100) {
247+
[void]GetDatasetRecords([string]$tableName, [int]$start = 0, [int]$limit = 100, [string]$sortCriteria = "") {
248248
$objRecordSet = New-Object -comobject ADODB.Recordset
249249
$objRecordSet.ActiveConnection = $this.dataConnection # This is needed to set the properties for sas formats.
250250
$objRecordSet.Properties.Item("SAS Formats").Value = "_ALL_"
251251
252+
$query = "SELECT * FROM $tableName"
253+
if ($sortCriteria -ne "") {
254+
$query = $query + " ORDER BY " + $sortCriteria
255+
}
252256
$objRecordSet.Open(
253-
$tableName,
254-
[System.Reflection.Missing]::Value, # Use the active connection
255-
2, # adOpenDynamic
257+
$query,
258+
$this.dataConnection, # Use the active connection
259+
3, # adOpenStatic
256260
1, # adLockReadOnly
257-
512 # adCmdTableDirect
261+
1 # adCmdTableDirect
258262
)
259263
260264
$records = [List[List[object]]]::new()

0 commit comments

Comments
 (0)