不要怂,就是干,撸起袖子干!

Commit 4c7b103d by Sushant Committed by GitHub

performance: remove terraformer-wkt-parser dependency (#9545)

1 parent 175c4e27
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
const util = require('util'); const util = require('util');
const inherits = require('./utils/inherits'); const inherits = require('./utils/inherits');
const _ = require('lodash'); const _ = require('lodash');
const Wkt = require('terraformer-wkt-parser'); const wkx = require('wkx');
const sequelizeErrors = require('./errors'); const sequelizeErrors = require('./errors');
const warnings = {}; const warnings = {};
const Validator = require('./utils/validator-extras').validator; const Validator = require('./utils/validator-extras').validator;
...@@ -724,10 +724,10 @@ GEOMETRY.prototype.key = GEOMETRY.key = 'GEOMETRY'; ...@@ -724,10 +724,10 @@ GEOMETRY.prototype.key = GEOMETRY.key = 'GEOMETRY';
GEOMETRY.prototype.escape = false; GEOMETRY.prototype.escape = false;
GEOMETRY.prototype._stringify = function _stringify(value, options) { GEOMETRY.prototype._stringify = function _stringify(value, options) {
return 'GeomFromText(' + options.escape(Wkt.convert(value)) + ')'; return 'GeomFromText(' + options.escape(wkx.Geometry.parseGeoJSON(value).toWkt()) + ')';
}; };
GEOMETRY.prototype._bindParam = function _bindParam(value, options) { GEOMETRY.prototype._bindParam = function _bindParam(value, options) {
return 'GeomFromText(' + options.bindParam(Wkt.convert(value)) + ')'; return 'GeomFromText(' + options.bindParam(wkx.Geometry.parseGeoJSON(value).toWkt()) + ')';
}; };
function GEOGRAPHY(type, srid) { function GEOGRAPHY(type, srid) {
...@@ -745,10 +745,10 @@ GEOGRAPHY.prototype.key = GEOGRAPHY.key = 'GEOGRAPHY'; ...@@ -745,10 +745,10 @@ GEOGRAPHY.prototype.key = GEOGRAPHY.key = 'GEOGRAPHY';
GEOGRAPHY.prototype.escape = false; GEOGRAPHY.prototype.escape = false;
GEOGRAPHY.prototype._stringify = function _stringify(value, options) { GEOGRAPHY.prototype._stringify = function _stringify(value, options) {
return 'GeomFromText(' + options.escape(Wkt.convert(value)) + ')'; return 'GeomFromText(' + options.escape(wkx.Geometry.parseGeoJSON(value).toWkt()) + ')';
}; };
GEOGRAPHY.prototype._bindParam = function _bindParam(value, options) { GEOGRAPHY.prototype._bindParam = function _bindParam(value, options) {
return 'GeomFromText(' + options.bindParam(Wkt.convert(value)) + ')'; return 'GeomFromText(' + options.bindParam(wkx.Geometry.parseGeoJSON(value).toWkt()) + ')';
}; };
for (const helper of Object.keys(helpers)) { for (const helper of Object.keys(helpers)) {
......
...@@ -14,8 +14,8 @@ class ConnectionManager extends AbstractConnectionManager { ...@@ -14,8 +14,8 @@ class ConnectionManager extends AbstractConnectionManager {
constructor(dialect, sequelize) { constructor(dialect, sequelize) {
super(dialect, sequelize); super(dialect, sequelize);
this.sequelize = sequelize;
this.sequelize.config.port = this.sequelize.config.port || 1433; this.sequelize.config.port = this.sequelize.config.port || 1433;
try { try {
if (sequelize.config.dialectModulePath) { if (sequelize.config.dialectModulePath) {
this.lib = require(sequelize.config.dialectModulePath); this.lib = require(sequelize.config.dialectModulePath);
......
...@@ -24,8 +24,8 @@ class ConnectionManager extends AbstractConnectionManager { ...@@ -24,8 +24,8 @@ class ConnectionManager extends AbstractConnectionManager {
constructor(dialect, sequelize) { constructor(dialect, sequelize) {
super(dialect, sequelize); super(dialect, sequelize);
this.sequelize = sequelize;
this.sequelize.config.port = this.sequelize.config.port || 3306; this.sequelize.config.port = this.sequelize.config.port || 3306;
try { try {
if (sequelize.config.dialectModulePath) { if (sequelize.config.dialectModulePath) {
this.lib = require(sequelize.config.dialectModulePath); this.lib = require(sequelize.config.dialectModulePath);
......
...@@ -14,8 +14,8 @@ class ConnectionManager extends AbstractConnectionManager { ...@@ -14,8 +14,8 @@ class ConnectionManager extends AbstractConnectionManager {
constructor(dialect, sequelize) { constructor(dialect, sequelize) {
super(dialect, sequelize); super(dialect, sequelize);
this.sequelize = sequelize;
this.sequelize.config.port = this.sequelize.config.port || 5432; this.sequelize.config.port = this.sequelize.config.port || 5432;
try { try {
let pgLib; let pgLib;
if (sequelize.config.dialectModulePath) { if (sequelize.config.dialectModulePath) {
......
...@@ -11,10 +11,7 @@ const parserStore = require('../parserStore')('sqlite'); ...@@ -11,10 +11,7 @@ const parserStore = require('../parserStore')('sqlite');
class ConnectionManager extends AbstractConnectionManager { class ConnectionManager extends AbstractConnectionManager {
constructor(dialect, sequelize) { constructor(dialect, sequelize) {
super(dialect, sequelize); super(dialect, sequelize);
this.sequelize = sequelize;
this.config = sequelize.config;
this.dialect = dialect;
this.dialectName = this.sequelize.options.dialect;
this.connections = {}; this.connections = {};
// We attempt to parse file location from a connection uri but we shouldn't match sequelize default host. // We attempt to parse file location from a connection uri but we shouldn't match sequelize default host.
......
...@@ -30,11 +30,10 @@ ...@@ -30,11 +30,10 @@
"moment-timezone": "^0.5.14", "moment-timezone": "^0.5.14",
"retry-as-promised": "^3.0.0", "retry-as-promised": "^3.0.0",
"semver": "^5.5.0", "semver": "^5.5.0",
"terraformer-wkt-parser": "^1.1.2",
"toposort-class": "^1.0.1", "toposort-class": "^1.0.1",
"uuid": "^3.2.1", "uuid": "^3.2.1",
"validator": "^10.0.0", "validator": "^10.0.0",
"wkx": "^0.4.1" "wkx": "^0.4.5"
}, },
"devDependencies": { "devDependencies": {
"@semantic-release/github": "^4.x", "@semantic-release/github": "^4.x",
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!