Linting.
This commit is contained in:
parent
4d3e033435
commit
b72edc21ec
|
@ -1,4 +1,11 @@
|
|||
import { Datasource, DatasourcePlusQueryResponse, Operation, QueryJson, Row, SearchFilters } from "@budibase/types"
|
||||
import {
|
||||
Datasource,
|
||||
DatasourcePlusQueryResponse,
|
||||
Operation,
|
||||
QueryJson,
|
||||
Row,
|
||||
SearchFilters,
|
||||
} from "@budibase/types"
|
||||
import { getSQLClient } from "../../../sdk/app/rows/utils"
|
||||
import { cloneDeep } from "lodash"
|
||||
import sdk from "../../../sdk"
|
||||
|
@ -10,7 +17,11 @@ const WRITE_OPERATIONS: Operation[] = [
|
|||
Operation.UPDATE,
|
||||
Operation.DELETE,
|
||||
]
|
||||
const DISABLED_WRITE_CLIENTS: SqlClient[] = [SqlClient.MY_SQL, SqlClient.MS_SQL, SqlClient.ORACLE]
|
||||
const DISABLED_WRITE_CLIENTS: SqlClient[] = [
|
||||
SqlClient.MY_SQL,
|
||||
SqlClient.MS_SQL,
|
||||
SqlClient.ORACLE,
|
||||
]
|
||||
|
||||
class CharSequence {
|
||||
static alphabet = "abcdefghijklmnopqrstuvwxyz"
|
||||
|
|
|
@ -214,59 +214,95 @@ describe("Captures of real examples", () => {
|
|||
endpoint: { datasourceId: "", entityId: "", operation: op },
|
||||
resource: {
|
||||
fields,
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
it("should check for Postgres aliased status", () => {
|
||||
const aliasing = new AliasTables(tables)
|
||||
const datasource = getDatasource(SourceName.POSTGRES)
|
||||
expect(aliasing.isAliasingEnabled(getQuery(Operation.CREATE), datasource)).toEqual(true)
|
||||
expect(aliasing.isAliasingEnabled(getQuery(Operation.READ), datasource)).toEqual(true)
|
||||
expect(aliasing.isAliasingEnabled(getQuery(Operation.UPDATE), datasource)).toEqual(true)
|
||||
expect(aliasing.isAliasingEnabled(getQuery(Operation.DELETE), datasource)).toEqual(true)
|
||||
expect(
|
||||
aliasing.isAliasingEnabled(getQuery(Operation.CREATE), datasource)
|
||||
).toEqual(true)
|
||||
expect(
|
||||
aliasing.isAliasingEnabled(getQuery(Operation.READ), datasource)
|
||||
).toEqual(true)
|
||||
expect(
|
||||
aliasing.isAliasingEnabled(getQuery(Operation.UPDATE), datasource)
|
||||
).toEqual(true)
|
||||
expect(
|
||||
aliasing.isAliasingEnabled(getQuery(Operation.DELETE), datasource)
|
||||
).toEqual(true)
|
||||
})
|
||||
|
||||
it("should check for MS-SQL aliased status", () => {
|
||||
const aliasing = new AliasTables(tables)
|
||||
const datasource = getDatasource(SourceName.SQL_SERVER)
|
||||
expect(aliasing.isAliasingEnabled(getQuery(Operation.CREATE), datasource)).toEqual(false)
|
||||
expect(aliasing.isAliasingEnabled(getQuery(Operation.READ), datasource)).toEqual(true)
|
||||
expect(aliasing.isAliasingEnabled(getQuery(Operation.UPDATE), datasource)).toEqual(false)
|
||||
expect(aliasing.isAliasingEnabled(getQuery(Operation.DELETE), datasource)).toEqual(false)
|
||||
expect(
|
||||
aliasing.isAliasingEnabled(getQuery(Operation.CREATE), datasource)
|
||||
).toEqual(false)
|
||||
expect(
|
||||
aliasing.isAliasingEnabled(getQuery(Operation.READ), datasource)
|
||||
).toEqual(true)
|
||||
expect(
|
||||
aliasing.isAliasingEnabled(getQuery(Operation.UPDATE), datasource)
|
||||
).toEqual(false)
|
||||
expect(
|
||||
aliasing.isAliasingEnabled(getQuery(Operation.DELETE), datasource)
|
||||
).toEqual(false)
|
||||
})
|
||||
|
||||
it("should check for MySQL aliased status", () => {
|
||||
const aliasing = new AliasTables(tables)
|
||||
const datasource = getDatasource(SourceName.MYSQL)
|
||||
expect(aliasing.isAliasingEnabled(getQuery(Operation.CREATE), datasource)).toEqual(false)
|
||||
expect(aliasing.isAliasingEnabled(getQuery(Operation.READ), datasource)).toEqual(true)
|
||||
expect(aliasing.isAliasingEnabled(getQuery(Operation.UPDATE), datasource)).toEqual(false)
|
||||
expect(aliasing.isAliasingEnabled(getQuery(Operation.DELETE), datasource)).toEqual(false)
|
||||
expect(
|
||||
aliasing.isAliasingEnabled(getQuery(Operation.CREATE), datasource)
|
||||
).toEqual(false)
|
||||
expect(
|
||||
aliasing.isAliasingEnabled(getQuery(Operation.READ), datasource)
|
||||
).toEqual(true)
|
||||
expect(
|
||||
aliasing.isAliasingEnabled(getQuery(Operation.UPDATE), datasource)
|
||||
).toEqual(false)
|
||||
expect(
|
||||
aliasing.isAliasingEnabled(getQuery(Operation.DELETE), datasource)
|
||||
).toEqual(false)
|
||||
})
|
||||
|
||||
it("should check for Oracle aliased status", () => {
|
||||
const aliasing = new AliasTables(tables)
|
||||
const datasource = getDatasource(SourceName.ORACLE)
|
||||
expect(aliasing.isAliasingEnabled(getQuery(Operation.CREATE), datasource)).toEqual(false)
|
||||
expect(aliasing.isAliasingEnabled(getQuery(Operation.READ), datasource)).toEqual(true)
|
||||
expect(aliasing.isAliasingEnabled(getQuery(Operation.UPDATE), datasource)).toEqual(false)
|
||||
expect(aliasing.isAliasingEnabled(getQuery(Operation.DELETE), datasource)).toEqual(false)
|
||||
expect(
|
||||
aliasing.isAliasingEnabled(getQuery(Operation.CREATE), datasource)
|
||||
).toEqual(false)
|
||||
expect(
|
||||
aliasing.isAliasingEnabled(getQuery(Operation.READ), datasource)
|
||||
).toEqual(true)
|
||||
expect(
|
||||
aliasing.isAliasingEnabled(getQuery(Operation.UPDATE), datasource)
|
||||
).toEqual(false)
|
||||
expect(
|
||||
aliasing.isAliasingEnabled(getQuery(Operation.DELETE), datasource)
|
||||
).toEqual(false)
|
||||
})
|
||||
|
||||
it("should disable aliasing for non-SQL datasources", () => {
|
||||
const aliasing = new AliasTables(tables)
|
||||
expect(aliasing.isAliasingEnabled(getQuery(Operation.READ), {
|
||||
source: SourceName.GOOGLE_SHEETS,
|
||||
type: "datasource",
|
||||
isSQL: false,
|
||||
}))
|
||||
expect(
|
||||
aliasing.isAliasingEnabled(getQuery(Operation.READ), {
|
||||
source: SourceName.GOOGLE_SHEETS,
|
||||
type: "datasource",
|
||||
isSQL: false,
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("should disable when no fields", () => {
|
||||
const aliasing = new AliasTables(tables)
|
||||
const datasource = getDatasource(SourceName.POSTGRES)
|
||||
expect(aliasing.isAliasingEnabled(getQuery(Operation.READ, []), datasource)).toEqual(false)
|
||||
expect(
|
||||
aliasing.isAliasingEnabled(getQuery(Operation.READ, []), datasource)
|
||||
).toEqual(false)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue