mirror of
https://github.com/sasjs/adapter.git
synced 2026-06-08 18:20:20 +00:00
fix(viya): skip formats keys in uploadTables
This commit is contained in:
@@ -23,6 +23,20 @@ describe('uploadTables', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('should skip $tablename formats metadata keys', async () => {
|
||||
const data = {
|
||||
tablewith2cols2rows: [{ col1: 'val1', specialMissingsCol: 'A' }],
|
||||
$tablewith2cols2rows: { formats: { specialMissingsCol: 'best.' } }
|
||||
}
|
||||
|
||||
const files = await uploadTables(requestClient, data, 't0k3n')
|
||||
|
||||
expect(files).toEqual([
|
||||
{ tableName: 'tablewith2cols2rows', file: 'test-file' }
|
||||
])
|
||||
expect(requestClient.uploadFile).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('should throw an error when the CSV exceeds the maximum length', async () => {
|
||||
const data = { foo: 'bar' }
|
||||
jest
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { prefixMessage } from '@sasjs/utils/error'
|
||||
import { RequestClient } from '../../request/RequestClient'
|
||||
import { convertToCSV } from '../../utils/convertToCsv'
|
||||
import { convertToCSV, isFormatsTable } from '../../utils/convertToCsv'
|
||||
|
||||
/**
|
||||
* Uploads tables to SAS as specially formatted CSVs.
|
||||
@@ -18,6 +18,10 @@ export async function uploadTables(
|
||||
const uploadedFiles = []
|
||||
|
||||
for (const tableName in data) {
|
||||
// $tablename keys carry only column-format metadata for the matching
|
||||
// tablename payload; they must not be uploaded as separate files.
|
||||
if (isFormatsTable(tableName)) continue
|
||||
|
||||
const csv = convertToCSV(data, tableName)
|
||||
if (csv === 'ERROR: LARGE STRING LENGTH') {
|
||||
throw new Error(
|
||||
|
||||
Reference in New Issue
Block a user