meadow-connection-mssql 1.0.14 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meadow-connection-mssql",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "Meadow MSSQL Plugin",
5
5
  "main": "source/Meadow-Connection-MSSQL.js",
6
6
  "scripts": {
@@ -32,6 +32,59 @@ class MeadowConnectionMSSQL extends libFableServiceProviderBase
32
32
 
33
33
  this.connected = false;
34
34
 
35
+ // Resolve MSSQL connection settings from options or fable settings
36
+ if (typeof(this.options.MSSQL) == 'object')
37
+ {
38
+ // Options were passed in with an MSSQL sub-object; coerce PascalCase to lowercase
39
+ if (!this.options.MSSQL.hasOwnProperty('server') && this.options.MSSQL.hasOwnProperty('Server'))
40
+ {
41
+ this.options.MSSQL.server = this.options.MSSQL.Server;
42
+ }
43
+ if (!this.options.MSSQL.hasOwnProperty('port') && this.options.MSSQL.hasOwnProperty('Port'))
44
+ {
45
+ this.options.MSSQL.port = this.options.MSSQL.Port;
46
+ }
47
+ if (!this.options.MSSQL.hasOwnProperty('user') && this.options.MSSQL.hasOwnProperty('User'))
48
+ {
49
+ this.options.MSSQL.user = this.options.MSSQL.User;
50
+ }
51
+ if (!this.options.MSSQL.hasOwnProperty('password') && this.options.MSSQL.hasOwnProperty('Password'))
52
+ {
53
+ this.options.MSSQL.password = this.options.MSSQL.Password;
54
+ }
55
+ if (!this.options.MSSQL.hasOwnProperty('database') && this.options.MSSQL.hasOwnProperty('Database'))
56
+ {
57
+ this.options.MSSQL.database = this.options.MSSQL.Database;
58
+ }
59
+ }
60
+ else if (typeof(this.options.server) === 'string')
61
+ {
62
+ // Options were passed in flat (already has server, user, etc.)
63
+ this.options.MSSQL = (
64
+ {
65
+ server: this.options.server,
66
+ port: this.options.port,
67
+ user: this.options.user,
68
+ password: this.options.password,
69
+ database: this.options.database,
70
+ ConnectionPoolLimit: this.options.ConnectionPoolLimit
71
+ });
72
+ }
73
+ else if (typeof(this.fable.settings.MSSQL) == 'object')
74
+ {
75
+ // Fall back to fable settings
76
+ let tmpSettings = this.fable.settings.MSSQL;
77
+ this.options.MSSQL = (
78
+ {
79
+ server: tmpSettings.server || tmpSettings.Server,
80
+ port: tmpSettings.port || tmpSettings.Port,
81
+ user: tmpSettings.user || tmpSettings.User,
82
+ password: tmpSettings.password || tmpSettings.Password,
83
+ database: tmpSettings.database || tmpSettings.Database,
84
+ ConnectionPoolLimit: tmpSettings.ConnectionPoolLimit
85
+ });
86
+ }
87
+
35
88
  // Schema provider handles DDL operations (create, drop, index, etc.)
36
89
  this._SchemaProvider = new libMeadowSchemaMSSQL(this.fable, this.options, `${this.Hash}-Schema`);
37
90
  }
@@ -142,18 +195,19 @@ class MeadowConnectionMSSQL extends libFableServiceProviderBase
142
195
  this.log.error(`Meadow MSSQL connect() called without a callback; this could lead to connection race conditions.`);
143
196
  tmpCallback = () => { };
144
197
  }
198
+ let tmpMSSQLSettings = this.options.MSSQL || {};
145
199
  let tmpConnectionSettings = (
146
200
  {
147
- server: this.options.server,
148
- user: this.options.user,
149
- password: this.options.password,
150
- database: this.options.database,
201
+ server: tmpMSSQLSettings.server,
202
+ user: tmpMSSQLSettings.user,
203
+ password: tmpMSSQLSettings.password,
204
+ database: tmpMSSQLSettings.database,
151
205
  requestTimeout: 80000,
152
206
  connectionTimeout: 80000,
153
- port: this.options.port,
207
+ port: tmpMSSQLSettings.port,
154
208
  pool:
155
209
  {
156
- max: 10,
210
+ max: tmpMSSQLSettings.ConnectionPoolLimit || 10,
157
211
  min: 0,
158
212
  idleTimeoutMillis: 30000
159
213
  },
@@ -70,7 +70,7 @@ class MeadowSchemaMSSQL extends libFableServiceProviderBase
70
70
  tmpCreateTableStatement += ` [${tmpColumn.Column}] VARCHAR(254) DEFAULT '00000000-0000-0000-0000-000000000000'`;
71
71
  break;
72
72
  case 'ForeignKey':
73
- tmpCreateTableStatement += ` [${tmpColumn.Column}] INT UNSIGNED NOT NULL DEFAULT 0`;
73
+ tmpCreateTableStatement += ` [${tmpColumn.Column}] INT NOT NULL DEFAULT 0`;
74
74
  tmpPrimaryKey = tmpColumn.Column;
75
75
  break;
76
76
  case 'Numeric':