Adding method for client/builder to detect that a table supports SQL filtering.
This commit is contained in:
parent
e48e21ffb8
commit
0ff9bfbe99
|
@ -2,7 +2,7 @@ const CouchDB = require("../../../db")
|
||||||
const internal = require("./internal")
|
const internal = require("./internal")
|
||||||
const external = require("./external")
|
const external = require("./external")
|
||||||
const csvParser = require("../../../utilities/csvParser")
|
const csvParser = require("../../../utilities/csvParser")
|
||||||
const { isExternalTable } = require("../../../integrations/utils")
|
const { isExternalTable, isSQL } = require("../../../integrations/utils")
|
||||||
const {
|
const {
|
||||||
getTableParams,
|
getTableParams,
|
||||||
getDatasourceParams,
|
getDatasourceParams,
|
||||||
|
@ -49,6 +49,7 @@ exports.fetch = async function (ctx) {
|
||||||
...entity,
|
...entity,
|
||||||
type: "external",
|
type: "external",
|
||||||
sourceId: row.doc._id,
|
sourceId: row.doc._id,
|
||||||
|
sql: isSQL(row.doc),
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ const { USERS_TABLE_SCHEMA, SwitchableTypes } = require("../../../constants")
|
||||||
const {
|
const {
|
||||||
isExternalTable,
|
isExternalTable,
|
||||||
breakExternalTableId,
|
breakExternalTableId,
|
||||||
|
isSQL,
|
||||||
} = require("../../../integrations/utils")
|
} = require("../../../integrations/utils")
|
||||||
const { getViews, saveView } = require("../view/utils")
|
const { getViews, saveView } = require("../view/utils")
|
||||||
const viewTemplate = require("../view/viewBuilder")
|
const viewTemplate = require("../view/viewBuilder")
|
||||||
|
@ -242,7 +243,9 @@ exports.getTable = async (appId, tableId) => {
|
||||||
const db = new CouchDB(appId)
|
const db = new CouchDB(appId)
|
||||||
if (isExternalTable(tableId)) {
|
if (isExternalTable(tableId)) {
|
||||||
let { datasourceId, tableName } = breakExternalTableId(tableId)
|
let { datasourceId, tableName } = breakExternalTableId(tableId)
|
||||||
return exports.getExternalTable(appId, datasourceId, tableName)
|
const datasource = await db.get(datasourceId)
|
||||||
|
const table = await exports.getExternalTable(appId, datasourceId, tableName)
|
||||||
|
return { ...table, sql: isSQL(datasource) }
|
||||||
} else {
|
} else {
|
||||||
return db.get(tableId)
|
return db.get(tableId)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { SqlQuery } from "../definitions/datasource"
|
import { SourceNames, SqlQuery } from "../definitions/datasource"
|
||||||
import { Datasource, Table } from "../definitions/common"
|
import { Datasource, Table } from "../definitions/common"
|
||||||
import { SourceNames } from "../definitions/datasource"
|
|
||||||
const { DocumentTypes, SEPARATOR } = require("../db/utils")
|
const { DocumentTypes, SEPARATOR } = require("../db/utils")
|
||||||
const {
|
const {
|
||||||
FieldTypes,
|
FieldTypes,
|
||||||
|
@ -131,7 +131,12 @@ export function isSQL(datasource: Datasource): boolean {
|
||||||
if (!datasource || !datasource.source) {
|
if (!datasource || !datasource.source) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
const SQL = [SourceNames.POSTGRES, SourceNames.SQL_SERVER, SourceNames.MYSQL]
|
const SQL = [
|
||||||
|
SourceNames.POSTGRES,
|
||||||
|
SourceNames.SQL_SERVER,
|
||||||
|
SourceNames.MYSQL,
|
||||||
|
SourceNames.ORACLE,
|
||||||
|
]
|
||||||
return SQL.indexOf(datasource.source) !== -1
|
return SQL.indexOf(datasource.source) !== -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue