Linting and updating csv parser test case to match new functionality.
This commit is contained in:
parent
86eec3bb52
commit
0cf612029e
|
@ -601,7 +601,10 @@ module External {
|
||||||
throw `Unable to process query, table "${tableName}" not defined.`
|
throw `Unable to process query, table "${tableName}" not defined.`
|
||||||
}
|
}
|
||||||
// look for specific components of config which may not be considered acceptable
|
// look for specific components of config which may not be considered acceptable
|
||||||
let { id, row, filters, sort, paginate, rows } = cleanupConfig(config, table)
|
let { id, row, filters, sort, paginate, rows } = cleanupConfig(
|
||||||
|
config,
|
||||||
|
table
|
||||||
|
)
|
||||||
filters = buildFilters(id, filters || {}, table)
|
filters = buildFilters(id, filters || {}, table)
|
||||||
const relationships = this.buildRelationships(table)
|
const relationships = this.buildRelationships(table)
|
||||||
// clean up row on ingress using schema
|
// clean up row on ingress using schema
|
||||||
|
|
|
@ -29,10 +29,7 @@ function generateSchema(
|
||||||
for (let [key, column] of Object.entries(table.schema)) {
|
for (let [key, column] of Object.entries(table.schema)) {
|
||||||
// skip things that are already correct
|
// skip things that are already correct
|
||||||
const oldColumn = oldTable ? oldTable.schema[key] : null
|
const oldColumn = oldTable ? oldTable.schema[key] : null
|
||||||
if (
|
if ((oldColumn && oldColumn.type) || (primaryKey === key && !isJunction)) {
|
||||||
(oldColumn && oldColumn.type) ||
|
|
||||||
(primaryKey === key && !isJunction)
|
|
||||||
) {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
switch (column.type) {
|
switch (column.type) {
|
||||||
|
|
|
@ -165,11 +165,11 @@ module PostgresModule {
|
||||||
|
|
||||||
setSchema() {
|
setSchema() {
|
||||||
if (!this.config.schema) {
|
if (!this.config.schema) {
|
||||||
this.config.schema = 'public'
|
this.config.schema = "public"
|
||||||
}
|
}
|
||||||
this.client.on('connect', (client: any) => {
|
this.client.on("connect", (client: any) => {
|
||||||
client.query(`SET search_path TO ${this.config.schema}`);
|
client.query(`SET search_path TO ${this.config.schema}`)
|
||||||
});
|
})
|
||||||
this.COLUMNS_SQL = `select * from information_schema.columns where table_schema = '${this.config.schema}'`
|
this.COLUMNS_SQL = `select * from information_schema.columns where table_schema = '${this.config.schema}'`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,9 @@ async function transform({ schema, csvString, existingTable }) {
|
||||||
const colParser = {}
|
const colParser = {}
|
||||||
|
|
||||||
// make sure the table has all the columns required for import
|
// make sure the table has all the columns required for import
|
||||||
|
if (existingTable) {
|
||||||
schema = updateSchema({ schema, existingTable })
|
schema = updateSchema({ schema, existingTable })
|
||||||
|
}
|
||||||
|
|
||||||
for (let key of Object.keys(schema)) {
|
for (let key of Object.keys(schema)) {
|
||||||
colParser[key] = PARSERS[schema[key].type] || schema[key].type
|
colParser[key] = PARSERS[schema[key].type] || schema[key].type
|
||||||
|
|
|
@ -3,19 +3,13 @@
|
||||||
exports[`CSV Parser transformation transforms a CSV file into JSON 1`] = `
|
exports[`CSV Parser transformation transforms a CSV file into JSON 1`] = `
|
||||||
Array [
|
Array [
|
||||||
Object {
|
Object {
|
||||||
"Address": "5 Sesame Street",
|
|
||||||
"Age": 4324,
|
"Age": 4324,
|
||||||
"Name": "Bertå",
|
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"Address": "1 World Trade Center",
|
|
||||||
"Age": 34,
|
"Age": 34,
|
||||||
"Name": "Ernie",
|
|
||||||
},
|
},
|
||||||
Object {
|
Object {
|
||||||
"Address": "44 Second Avenue",
|
|
||||||
"Age": 23423,
|
"Age": 23423,
|
||||||
"Name": "Big Bird",
|
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -24,6 +24,9 @@ const SCHEMAS = {
|
||||||
Age: {
|
Age: {
|
||||||
type: "omit",
|
type: "omit",
|
||||||
},
|
},
|
||||||
|
Name: {
|
||||||
|
type: "string",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
BROKEN: {
|
BROKEN: {
|
||||||
Address: {
|
Address: {
|
||||||
|
|
Loading…
Reference in New Issue