Linking up to existing SQL integrations.

This commit is contained in:
mike12345567 2021-06-03 16:45:43 +01:00
parent a669fa1025
commit 65f3e84a0e
4 changed files with 20 additions and 4 deletions

View File

@ -1,5 +1,6 @@
const sqlServer = require("mssql")
const { FIELD_TYPES } = require("./Integration")
const Sql = require("./base/sql")
const SCHEMA = {
docs: "https://github.com/tediousjs/node-mssql",
@ -50,10 +51,11 @@ const SCHEMA = {
},
}
class SqlServerIntegration {
class SqlServerIntegration extends Sql {
static pool
constructor(config) {
super("mssql")
this.config = config
this.config.options = {
encrypt: this.config.encrypt,

View File

@ -1,5 +1,6 @@
const mysql = require("mysql")
const { FIELD_TYPES, QUERY_TYPES } = require("./Integration")
const Sql = require("./base/sql")
const SCHEMA = {
docs: "https://github.com/mysqljs/mysql",
@ -52,8 +53,9 @@ const SCHEMA = {
},
}
class MySQLIntegration {
class MySQLIntegration extends Sql {
constructor(config) {
super("mysql")
this.config = config
if (Object.keys(config.ssl).length === 0) {
delete config.ssl

View File

@ -1,5 +1,6 @@
const { Pool } = require("pg")
const { FIELD_TYPES } = require("./Integration")
const Sql = require("./base/sql")
const SCHEMA = {
docs: "https://node-postgres.com",
@ -54,10 +55,11 @@ const SCHEMA = {
},
}
class PostgresIntegration {
class PostgresIntegration extends Sql {
static pool
constructor(config) {
super("pg")
this.config = config
if (this.config.ssl) {
this.config.ssl = {

View File

@ -117,4 +117,14 @@ describe("SQL query builder", () => {
}))
expect(query).toEqual(`delete from "${TABLE_NAME}" where "id" = 1001`)
})
})
it("should work with MS-SQL", () => {
const query = new Sql("mssql", 10).buildQuery(generateReadJson())
expect(query).toEqual(`select top (10) * from [${TABLE_NAME}]`)
})
it("should work with mySQL", () => {
const query = new Sql("mysql", 10).buildQuery(generateReadJson())
expect(query).toEqual(`select * from \`${TABLE_NAME}\` limit 10`)
})
})