1
0
Fork 0
mirror of synced 2024-07-16 03:35:56 +12:00

Linking up to existing SQL integrations.

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

View file

@ -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,

View file

@ -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

View file

@ -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 = {

View file

@ -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`)
})
}) })