Fixing test cases.
This commit is contained in:
parent
7d6b45c1e6
commit
df074c6004
|
@ -4,10 +4,8 @@ const { InternalTables } = require("../../../db/utils")
|
||||||
const userController = require("../user")
|
const userController = require("../user")
|
||||||
const { FieldTypes } = require("../../../constants")
|
const { FieldTypes } = require("../../../constants")
|
||||||
const { getAppDB } = require("@budibase/backend-core/context")
|
const { getAppDB } = require("@budibase/backend-core/context")
|
||||||
const {
|
const { makeExternalQuery } = require("../../../integrations/base/query")
|
||||||
makeExternalQuery,
|
const { removeKeyNumbering } = require("../../../integrations/base/utils")
|
||||||
removeKeyNumbering,
|
|
||||||
} = require("../../../integrations/base/utils")
|
|
||||||
|
|
||||||
validateJs.extend(validateJs.validators.datetime, {
|
validateJs.extend(validateJs.validators.datetime, {
|
||||||
parse: function (value) {
|
parse: function (value) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ const {
|
||||||
FieldTypes,
|
FieldTypes,
|
||||||
RelationshipTypes,
|
RelationshipTypes,
|
||||||
} = require("../../../constants")
|
} = require("../../../constants")
|
||||||
const { makeExternalQuery } = require("../../../integrations/base/utils")
|
const { makeExternalQuery } = require("../../../integrations/base/query")
|
||||||
const { cloneDeep } = require("lodash/fp")
|
const { cloneDeep } = require("lodash/fp")
|
||||||
const csvParser = require("../../../utilities/csvParser")
|
const csvParser = require("../../../utilities/csvParser")
|
||||||
const { handleRequest } = require("../row/external")
|
const { handleRequest } = require("../row/external")
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { QueryJson } from "../../definitions/datasource"
|
||||||
|
import { Datasource } from "../../definitions/common"
|
||||||
|
const { integrations } = require("../index")
|
||||||
|
|
||||||
|
export async function makeExternalQuery(
|
||||||
|
datasource: Datasource,
|
||||||
|
json: QueryJson
|
||||||
|
) {
|
||||||
|
const Integration = integrations[datasource.source]
|
||||||
|
// query is the opinionated function
|
||||||
|
if (Integration.prototype.query) {
|
||||||
|
const integration = new Integration(datasource.config)
|
||||||
|
return integration.query(json)
|
||||||
|
} else {
|
||||||
|
throw "Datasource does not support query."
|
||||||
|
}
|
||||||
|
}
|
|
@ -584,4 +584,3 @@ class SqlQueryBuilder extends SqlTableQueryBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SqlQueryBuilder
|
export default SqlQueryBuilder
|
||||||
module.exports = SqlQueryBuilder
|
|
||||||
|
|
|
@ -1,23 +1,5 @@
|
||||||
import { QueryJson } from "../../definitions/datasource"
|
|
||||||
import { Datasource } from "../../definitions/common"
|
|
||||||
const { integrations } = require("../index")
|
|
||||||
|
|
||||||
const QUERY_START_REGEX = /\d[0-9]*:/g
|
const QUERY_START_REGEX = /\d[0-9]*:/g
|
||||||
|
|
||||||
export async function makeExternalQuery(
|
|
||||||
datasource: Datasource,
|
|
||||||
json: QueryJson
|
|
||||||
) {
|
|
||||||
const Integration = integrations[datasource.source]
|
|
||||||
// query is the opinionated function
|
|
||||||
if (Integration.prototype.query) {
|
|
||||||
const integration = new Integration(datasource.config)
|
|
||||||
return integration.query(json)
|
|
||||||
} else {
|
|
||||||
throw "Datasource does not support query."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function removeKeyNumbering(key: any): string {
|
export function removeKeyNumbering(key: any): string {
|
||||||
if (typeof key === "string" && key.match(QUERY_START_REGEX) != null) {
|
if (typeof key === "string" && key.match(QUERY_START_REGEX) != null) {
|
||||||
const parts = key.split(":")
|
const parts = key.split(":")
|
||||||
|
|
|
@ -15,10 +15,10 @@ import {
|
||||||
} from "./utils"
|
} from "./utils"
|
||||||
import { DatasourcePlus } from "./base/datasourcePlus"
|
import { DatasourcePlus } from "./base/datasourcePlus"
|
||||||
import { Table, TableSchema } from "../definitions/common"
|
import { Table, TableSchema } from "../definitions/common"
|
||||||
|
import Sql from "./base/sql"
|
||||||
|
|
||||||
module MSSQLModule {
|
module MSSQLModule {
|
||||||
const sqlServer = require("mssql")
|
const sqlServer = require("mssql")
|
||||||
const Sql = require("./base/sql")
|
|
||||||
const DEFAULT_SCHEMA = "dbo"
|
const DEFAULT_SCHEMA = "dbo"
|
||||||
|
|
||||||
interface MSSQLConfig {
|
interface MSSQLConfig {
|
||||||
|
@ -96,7 +96,8 @@ module MSSQLModule {
|
||||||
class SqlServerIntegration extends Sql implements DatasourcePlus {
|
class SqlServerIntegration extends Sql implements DatasourcePlus {
|
||||||
private readonly config: MSSQLConfig
|
private readonly config: MSSQLConfig
|
||||||
private index: number = 0
|
private index: number = 0
|
||||||
static pool: any
|
private readonly pool: any
|
||||||
|
private client: any
|
||||||
public tables: Record<string, Table> = {}
|
public tables: Record<string, Table> = {}
|
||||||
public schemaErrors: Record<string, string> = {}
|
public schemaErrors: Record<string, string> = {}
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,10 @@ import {
|
||||||
import { DatasourcePlus } from "./base/datasourcePlus"
|
import { DatasourcePlus } from "./base/datasourcePlus"
|
||||||
import dayjs from "dayjs"
|
import dayjs from "dayjs"
|
||||||
const { NUMBER_REGEX } = require("../utilities")
|
const { NUMBER_REGEX } = require("../utilities")
|
||||||
|
import Sql from "./base/sql"
|
||||||
|
|
||||||
module MySQLModule {
|
module MySQLModule {
|
||||||
const mysql = require("mysql2/promise")
|
const mysql = require("mysql2/promise")
|
||||||
const Sql = require("./base/sql")
|
|
||||||
|
|
||||||
interface MySQLConfig {
|
interface MySQLConfig {
|
||||||
host: string
|
host: string
|
||||||
|
|
|
@ -14,10 +14,10 @@ import {
|
||||||
SqlClients,
|
SqlClients,
|
||||||
} from "./utils"
|
} from "./utils"
|
||||||
import { DatasourcePlus } from "./base/datasourcePlus"
|
import { DatasourcePlus } from "./base/datasourcePlus"
|
||||||
|
import Sql from "./base/sql"
|
||||||
|
|
||||||
module PostgresModule {
|
module PostgresModule {
|
||||||
const { Client, types } = require("pg")
|
const { Client, types } = require("pg")
|
||||||
const Sql = require("./base/sql")
|
|
||||||
const { escapeDangerousCharacters } = require("../utilities")
|
const { escapeDangerousCharacters } = require("../utilities")
|
||||||
|
|
||||||
// Return "date" and "timestamp" types as plain strings.
|
// Return "date" and "timestamp" types as plain strings.
|
||||||
|
@ -117,6 +117,7 @@ module PostgresModule {
|
||||||
private readonly client: any
|
private readonly client: any
|
||||||
private readonly config: PostgresConfig
|
private readonly config: PostgresConfig
|
||||||
private index: number = 1
|
private index: number = 1
|
||||||
|
private open: boolean
|
||||||
public tables: Record<string, Table> = {}
|
public tables: Record<string, Table> = {}
|
||||||
public schemaErrors: Record<string, string> = {}
|
public schemaErrors: Record<string, string> = {}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const Sql = require("../base/sql")
|
const Sql = require("../base/sql").default
|
||||||
const { SqlClients } = require("../utils")
|
const { SqlClients } = require("../utils")
|
||||||
|
|
||||||
const TABLE_NAME = "test"
|
const TABLE_NAME = "test"
|
||||||
|
|
Loading…
Reference in New Issue