Browse Source

Linking up to existing SQL integrations.

gh-pages
mike12345567 5 years ago
parent
commit
65f3e84a0e
  1. 4
      packages/server/src/integrations/microsoftSqlServer.js
  2. 4
      packages/server/src/integrations/mysql.js
  3. 4
      packages/server/src/integrations/postgres.js
  4. 12
      packages/server/src/integrations/tests/sql.spec.js

4
packages/server/src/integrations/microsoftSqlServer.js

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

4
packages/server/src/integrations/mysql.js

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

4
packages/server/src/integrations/postgres.js

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

12
packages/server/src/integrations/tests/sql.spec.js

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

Loading…
Cancel
Save