Quick updates to make sure mySQL works with automations.
This commit is contained in:
parent
40e06cc5d1
commit
eb2cf1afa6
|
@ -22,19 +22,26 @@ function inputProcessing(row, table) {
|
||||||
return newRow
|
return newRow
|
||||||
}
|
}
|
||||||
|
|
||||||
function outputProcessing(rows, table) {
|
function generateIdForRow(row, table) {
|
||||||
// if no rows this is what is returned? Might be PG only
|
if (!row) {
|
||||||
if (rows[0].read === true) {
|
return
|
||||||
return []
|
|
||||||
}
|
}
|
||||||
const primary = table.primary
|
const primary = table.primary
|
||||||
for (let row of rows) {
|
|
||||||
// build id array
|
// build id array
|
||||||
let idParts = []
|
let idParts = []
|
||||||
for (let field of primary) {
|
for (let field of primary) {
|
||||||
idParts.push(row[field])
|
idParts.push(row[field])
|
||||||
}
|
}
|
||||||
row._id = generateRowIdField(idParts)
|
return generateRowIdField(idParts)
|
||||||
|
}
|
||||||
|
|
||||||
|
function outputProcessing(rows, table) {
|
||||||
|
// if no rows this is what is returned? Might be PG only
|
||||||
|
if (rows[0].read === true) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
for (let row of rows) {
|
||||||
|
row._id = generateIdForRow(row, table)
|
||||||
row.tableId = table._id
|
row.tableId = table._id
|
||||||
row._rev = "rev"
|
row._rev = "rev"
|
||||||
}
|
}
|
||||||
|
@ -89,8 +96,6 @@ async function handleRequest(
|
||||||
}
|
}
|
||||||
// clean up row on ingress using schema
|
// clean up row on ingress using schema
|
||||||
filters = buildFilters(id, filters, table)
|
filters = buildFilters(id, filters, table)
|
||||||
// get the id after building filters, but before it is removed from the row
|
|
||||||
id = id || (row ? row._id : null)
|
|
||||||
row = inputProcessing(row, table)
|
row = inputProcessing(row, table)
|
||||||
if (
|
if (
|
||||||
operation === DataSourceOperation.DELETE &&
|
operation === DataSourceOperation.DELETE &&
|
||||||
|
@ -114,7 +119,7 @@ async function handleRequest(
|
||||||
body: row,
|
body: row,
|
||||||
// pass an id filter into extra, purely for mysql/returning
|
// pass an id filter into extra, purely for mysql/returning
|
||||||
extra: {
|
extra: {
|
||||||
idFilter: buildFilters(id, {}, table),
|
idFilter: buildFilters(id || generateIdForRow(row, table), {}, table),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// can't really use response right now
|
// can't really use response right now
|
||||||
|
|
|
@ -180,6 +180,9 @@ class MySQLIntegration extends Sql {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getReturningRow(json) {
|
async getReturningRow(json) {
|
||||||
|
if (!json.extra.idFilter) {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
const input = this._query({
|
const input = this._query({
|
||||||
endpoint: {
|
endpoint: {
|
||||||
...json.endpoint,
|
...json.endpoint,
|
||||||
|
|
Loading…
Reference in New Issue