Linking up to existing SQL integrations.
This commit is contained in:
parent
a669fa1025
commit
65f3e84a0e
|
@ -1,5 +1,6 @@
|
||||||
const sqlServer = require("mssql")
|
const sqlServer = require("mssql")
|
||||||
const { FIELD_TYPES } = require("./Integration")
|
const { FIELD_TYPES } = require("./Integration")
|
||||||
|
const Sql = require("./base/sql")
|
||||||
|
|
||||||
const SCHEMA = {
|
const SCHEMA = {
|
||||||
docs: "https://github.com/tediousjs/node-mssql",
|
docs: "https://github.com/tediousjs/node-mssql",
|
||||||
|
@ -50,10 +51,11 @@ const SCHEMA = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
class SqlServerIntegration {
|
class SqlServerIntegration extends Sql {
|
||||||
static pool
|
static pool
|
||||||
|
|
||||||
constructor(config) {
|
constructor(config) {
|
||||||
|
super("mssql")
|
||||||
this.config = config
|
this.config = config
|
||||||
this.config.options = {
|
this.config.options = {
|
||||||
encrypt: this.config.encrypt,
|
encrypt: this.config.encrypt,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
const mysql = require("mysql")
|
const mysql = require("mysql")
|
||||||
const { FIELD_TYPES, QUERY_TYPES } = require("./Integration")
|
const { FIELD_TYPES, QUERY_TYPES } = require("./Integration")
|
||||||
|
const Sql = require("./base/sql")
|
||||||
|
|
||||||
const SCHEMA = {
|
const SCHEMA = {
|
||||||
docs: "https://github.com/mysqljs/mysql",
|
docs: "https://github.com/mysqljs/mysql",
|
||||||
|
@ -52,8 +53,9 @@ const SCHEMA = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
class MySQLIntegration {
|
class MySQLIntegration extends Sql {
|
||||||
constructor(config) {
|
constructor(config) {
|
||||||
|
super("mysql")
|
||||||
this.config = config
|
this.config = config
|
||||||
if (Object.keys(config.ssl).length === 0) {
|
if (Object.keys(config.ssl).length === 0) {
|
||||||
delete config.ssl
|
delete config.ssl
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
const { Pool } = require("pg")
|
const { Pool } = require("pg")
|
||||||
const { FIELD_TYPES } = require("./Integration")
|
const { FIELD_TYPES } = require("./Integration")
|
||||||
|
const Sql = require("./base/sql")
|
||||||
|
|
||||||
const SCHEMA = {
|
const SCHEMA = {
|
||||||
docs: "https://node-postgres.com",
|
docs: "https://node-postgres.com",
|
||||||
|
@ -54,10 +55,11 @@ const SCHEMA = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
class PostgresIntegration {
|
class PostgresIntegration extends Sql {
|
||||||
static pool
|
static pool
|
||||||
|
|
||||||
constructor(config) {
|
constructor(config) {
|
||||||
|
super("pg")
|
||||||
this.config = config
|
this.config = config
|
||||||
if (this.config.ssl) {
|
if (this.config.ssl) {
|
||||||
this.config.ssl = {
|
this.config.ssl = {
|
||||||
|
|
|
@ -117,4 +117,14 @@ describe("SQL query builder", () => {
|
||||||
}))
|
}))
|
||||||
expect(query).toEqual(`delete from "${TABLE_NAME}" where "id" = 1001`)
|
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`)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in New Issue