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 () => {
|
it('should throw an error when the CSV exceeds the maximum length', async () => {
|
||||||
const data = { foo: 'bar' }
|
const data = { foo: 'bar' }
|
||||||
jest
|
jest
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { prefixMessage } from '@sasjs/utils/error'
|
import { prefixMessage } from '@sasjs/utils/error'
|
||||||
import { RequestClient } from '../../request/RequestClient'
|
import { RequestClient } from '../../request/RequestClient'
|
||||||
import { convertToCSV } from '../../utils/convertToCsv'
|
import { convertToCSV, isFormatsTable } from '../../utils/convertToCsv'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uploads tables to SAS as specially formatted CSVs.
|
* Uploads tables to SAS as specially formatted CSVs.
|
||||||
@@ -18,6 +18,10 @@ export async function uploadTables(
|
|||||||
const uploadedFiles = []
|
const uploadedFiles = []
|
||||||
|
|
||||||
for (const tableName in data) {
|
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)
|
const csv = convertToCSV(data, tableName)
|
||||||
if (csv === 'ERROR: LARGE STRING LENGTH') {
|
if (csv === 'ERROR: LARGE STRING LENGTH') {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
|||||||
Reference in New Issue
Block a user