meadow 2.0.15 → 2.0.17

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.
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "optOut": false,
3
- "lastUpdateCheck": 1699195015190
3
+ "lastUpdateCheck": 1761078031905
4
4
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "numericVersion": 10000,
3
3
  "releaseNotes": "https://vscode-sqltools.mteixeira.dev/changelog#v-1-0-0",
4
- "run": 1699195007876,
4
+ "run": 1754854114603,
5
5
  "updated": false,
6
6
  "version": "1.0.0",
7
7
  "lastNotificationDate": 0,
@@ -26,47 +26,6 @@ RUN ( sudo mysqld_safe --skip-grant-tables --skip-networking & ) && sleep 5 &&
26
26
  # Import the initial database
27
27
  RUN sudo service mariadb restart && sleep 5 && mysql -u root -p"123456789" -e "CREATE DATABASE FableTest;"
28
28
 
29
- RUN echo "...installing vscode extensions..."
30
- # Mocha unit testing in the sidebar
31
- RUN code-server --install-extension hbenl.vscode-mocha-test-adapter
32
- RUN code-server --install-extension hbenl.test-adapter-converter
33
- RUN code-server --install-extension hbenl.vscode-test-explorer
34
-
35
- # Magic indentation rainbow
36
- RUN code-server --install-extension oderwat.indent-rainbow
37
- RUN code-server --install-extension dbaeumer.vscode-eslint
38
-
39
- # Contextual git
40
- RUN code-server --install-extension eamodio.gitlens
41
-
42
- # Other extensions (uncomment them to have them automagic, or run this from a terminal to install in the container):
43
-
44
- # SQL Tools
45
- RUN code-server --install-extension mtxr.sqltools
46
- RUN code-server --install-extension mtxr.sqltools-driver-mysql
47
-
48
- # Microsoft's AI code completion
49
- # RUN code-server --install-extension VisualStudioExptTeam.vscodeintellicode
50
-
51
- # Live server -- make sure to open up the port on the docker image
52
- # RUN code-server --install-extension ritwickdey.LiveServer
53
-
54
- # Quick link to required modules' documentation
55
- # RUN code-server --install-extension bengreenier.vscode-node-readme
56
-
57
- # Switch up fonts
58
- # RUN code-server --install-extension evan-buss.font-switcher
59
-
60
- # Icons
61
- # RUN code-server --install-extension vscode-icons-team.vscode-icons
62
- # RUN code-server --install-extension PKief.material-icon-theme
63
-
64
- # Hover over CSS colors to see them previewed
65
- # RUN code-server --install-extension bierner.color-info
66
-
67
- # An easy on the eyes color theme
68
- # RUN code-server --install-extension daylerees.rainglow
69
-
70
29
  SHELL ["/bin/bash", "-c"]
71
30
  USER coder
72
31
 
@@ -88,4 +47,4 @@ RUN . ~/.nvm/nvm.sh && source ~/.bashrc && nvm alias default 14
88
47
 
89
48
  WORKDIR /home/coder/meadow
90
49
 
91
- ENTRYPOINT ["/usr/bin/MySQL-Laden-Entry.sh"]
50
+ ENTRYPOINT ["/usr/bin/MySQL-Laden-Entry.sh"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meadow",
3
- "version": "2.0.15",
3
+ "version": "2.0.17",
4
4
  "description": "A data access library.",
5
5
  "main": "source/Meadow.js",
6
6
  "scripts": {
@@ -49,7 +49,7 @@
49
49
  "alasql": "^4.1.10",
50
50
  "browserify": "^17.0.0",
51
51
  "chai": "4.3.10",
52
- "fable": "^3.0.96",
52
+ "fable": "^3.1.18",
53
53
  "gulp": "^4.0.2",
54
54
  "gulp-babel": "^8.0.0",
55
55
  "gulp-sourcemaps": "^3.0.0",
@@ -65,7 +65,7 @@
65
65
  },
66
66
  "dependencies": {
67
67
  "async": "3.2.5",
68
- "foxhound": "^2.0.10",
68
+ "foxhound": "^2.0.13",
69
69
  "is-my-json-valid": "2.20.6",
70
70
  "npm-check-updates": "^16.14.6",
71
71
  "simple-get": "^4.0.1"
@@ -47,8 +47,18 @@ var meadowBehaviorUpdate = function(pMeadow, pQuery, fCallBack)
47
47
  switch (pMeadow.schema[i].Type)
48
48
  {
49
49
  case 'UpdateIDUser':
50
+ // Don't obliterate these from the record if automagic is disabled
51
+ if (!pQuery.query.disableAutoUserStamp)
52
+ {
53
+ pQuery.query.records[0][pMeadow.schema[i].Column] = false;
54
+ }
55
+ break;
50
56
  case 'UpdateDate':
51
- pQuery.query.records[0][pMeadow.schema[i].Column] = false;
57
+ // Don't obliterate these from the record if automagic is disabled
58
+ if (!pQuery.query.disableAutoDateStamp)
59
+ {
60
+ pQuery.query.records[0][pMeadow.schema[i].Column] = false;
61
+ }
52
62
  break;
53
63
  }
54
64
  }
@@ -60,6 +60,12 @@ var MeadowProvider = function ()
60
60
  let tmpPreparedStatement = _Fable.MeadowMSSQLProvider.preparedStatement;
61
61
  // Map the Parameters to Types
62
62
  let tmpParameterTypeKeys = Object.keys(pQuery.query.parameterTypes)
63
+ const tmpColumns = pQuery.query.schema;
64
+ const tmpSchemaByColumn = {};
65
+ for (let i = 0; i < tmpColumns.length; i++)
66
+ {
67
+ tmpSchemaByColumn[tmpColumns[i].Column] = tmpColumns[i];
68
+ }
63
69
  for (let i = 0; i < tmpParameterTypeKeys.length; i++)
64
70
  {
65
71
  let tmpParameterType = pQuery.query.parameterTypes[tmpParameterTypeKeys[i]];
@@ -79,6 +85,21 @@ var MeadowProvider = function ()
79
85
  {
80
86
  tmpParameterEntry = _Fable.MeadowMSSQLProvider.MSSQL.VarChar(_Fable.MeadowMSSQLProvider.MSSQL.Max);
81
87
  }
88
+ else if (tmpParameterType === 'Decimal')
89
+ {
90
+ const tmpSize = tmpSchemaByColumn[tmpParameterTypeKeys[i]]?.Size;
91
+ if (tmpSize && typeof tmpSize === 'string')
92
+ {
93
+ let [ tmpDigitsStr, tmpDecimalDigitsStr ] = tmpSize.split(',');
94
+ const tmpDigits = parseInt(tmpDigitsStr.trim());
95
+ const tmpDecimalDigits = tmpDecimalDigitsStr ? parseInt(tmpDecimalDigitsStr.trim()) : 0;
96
+ tmpParameterEntry = _Fable.MeadowMSSQLProvider.MSSQL.Decimal(tmpDigits, tmpDecimalDigits);
97
+ }
98
+ else
99
+ {
100
+ tmpParameterEntry = _Fable.MeadowMSSQLProvider.MSSQL.Decimal(18, 8);
101
+ }
102
+ }
82
103
  else
83
104
  {
84
105
  tmpParameterEntry = _Fable.MeadowMSSQLProvider.MSSQL[tmpParameterType];
@@ -0,0 +1,296 @@
1
+ /**
2
+ * @license MIT
3
+ * @author <steven@velozo.com>
4
+ */
5
+ var MeadowProvider = function ()
6
+ {
7
+ function createNew(pFable)
8
+ {
9
+ // If a valid Fable object isn't passed in, return a constructor
10
+ if (typeof (pFable) !== 'object')
11
+ {
12
+ return { new: createNew };
13
+ }
14
+ var _Fable = pFable;
15
+
16
+ /**
17
+ * Build a connection pool, shared within this provider.
18
+ * This may be more performant as a shared object.
19
+ */
20
+ var getDB = function ()
21
+ {
22
+ if (typeof (_Fable.MeadowMySQLConnectionPool) == 'object')
23
+ {
24
+ // This is where the old-style SQL Connection pool is. Refactor doesn't even look for it anymore
25
+ return _Fable.MeadowMySQLConnectionPool;
26
+ }
27
+
28
+ // New-style default connection pool provider
29
+ if (typeof (_Fable.MeadowMySQLProvider) == 'object' && _Fable.MeadowMySQLProvider.connected)
30
+ {
31
+ return _Fable.MeadowMySQLProvider.pool;
32
+ }
33
+
34
+ return false;
35
+ };
36
+
37
+ var getProvider = function ()
38
+ {
39
+ if (typeof (_Fable.MeadowMySQLConnectionPool) == 'object')
40
+ {
41
+ // This is where the old-style SQL Connection pool is. Refactor doesn't even look for it anymore
42
+ return _Fable.MeadowMySQLConnectionPool;
43
+ }
44
+
45
+ // New-style default connection pool provider
46
+ if (typeof (_Fable.MeadowMySQLProvider) == 'object')
47
+ {
48
+ return _Fable.MeadowMySQLProvider;
49
+ }
50
+
51
+ return false;
52
+ }
53
+
54
+ // The Meadow marshaller also passes in the Schema as the third parameter, but this is a blunt function ATM.
55
+ var marshalRecordFromSourceToObject = function (pObject, pRecord)
56
+ {
57
+ // For now, crudely assign everything in pRecord to pObject
58
+ // This is safe in this context, and we don't want to slow down marshalling with millions of hasOwnProperty checks
59
+ for (var tmpColumn in pRecord)
60
+ {
61
+ pObject[tmpColumn] = pRecord[tmpColumn];
62
+ }
63
+ };
64
+
65
+ var Create = function (pQuery, fCallback)
66
+ {
67
+ var tmpResult = pQuery.parameters.result;
68
+
69
+ pQuery.setDialect('SQLite').buildCreateQuery();
70
+
71
+ // TODO: Test the query before executing
72
+ if (pQuery.logLevel > 0)
73
+ {
74
+ _Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
75
+ }
76
+
77
+ getDB().getConnection(function (pError, pDBConnection)
78
+ {
79
+ pDBConnection.query(
80
+ pQuery.query.body,
81
+ pQuery.query.parameters,
82
+ function (pError, pRows)
83
+ {
84
+ pDBConnection.release();
85
+ tmpResult.error = pError;
86
+ tmpResult.value = false;
87
+ try
88
+ {
89
+ tmpResult.value = pRows.insertId;
90
+ }
91
+ catch (pErrorGettingRowcount)
92
+ {
93
+ _Fable.log.warn('Error getting insert ID during create query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
94
+ }
95
+
96
+ tmpResult.executed = true;
97
+ return fCallback();
98
+ }
99
+ );
100
+ });
101
+ };
102
+
103
+ // This is a synchronous read, good for a few records.
104
+ // TODO: Add a pipe-able read for huge sets
105
+ var Read = function (pQuery, fCallback)
106
+ {
107
+ var tmpResult = pQuery.parameters.result;
108
+
109
+ pQuery.setDialect('MySQL').buildReadQuery();
110
+
111
+ if (pQuery.logLevel > 0)
112
+ {
113
+ _Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
114
+ }
115
+
116
+ getDB().getConnection(function (pError, pDBConnection)
117
+ {
118
+ pDBConnection.query(
119
+ pQuery.query.body,
120
+ pQuery.query.parameters,
121
+ function (pError, pRows)
122
+ {
123
+ pDBConnection.release();
124
+ tmpResult.error = pError;
125
+ tmpResult.value = pRows;
126
+ tmpResult.executed = true;
127
+ return fCallback();
128
+ }
129
+ );
130
+ });
131
+ };
132
+
133
+ var Update = function (pQuery, fCallback)
134
+ {
135
+ var tmpResult = pQuery.parameters.result;
136
+
137
+ pQuery.setDialect('MySQL').buildUpdateQuery();
138
+
139
+ if (pQuery.logLevel > 0)
140
+ {
141
+ _Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
142
+ }
143
+
144
+ getDB().getConnection(function (pError, pDBConnection)
145
+ {
146
+ pDBConnection.query(
147
+ pQuery.query.body,
148
+ pQuery.query.parameters,
149
+ function (pError, pRows)
150
+ {
151
+ pDBConnection.release();
152
+ tmpResult.error = pError;
153
+ tmpResult.value = pRows;
154
+ tmpResult.executed = true;
155
+ return fCallback();
156
+ }
157
+ );
158
+ });
159
+ }
160
+
161
+ var Delete = function (pQuery, fCallback)
162
+ {
163
+ var tmpResult = pQuery.parameters.result;
164
+
165
+ pQuery.setDialect('MySQL').buildDeleteQuery();
166
+
167
+ if (pQuery.logLevel > 0)
168
+ {
169
+ _Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
170
+ }
171
+
172
+ getDB().getConnection(function (pError, pDBConnection)
173
+ {
174
+ pDBConnection.query
175
+ (
176
+ pQuery.query.body,
177
+ pQuery.query.parameters,
178
+ function (pError, pRows)
179
+ {
180
+ pDBConnection.release();
181
+ tmpResult.error = pError;
182
+ tmpResult.value = false;
183
+ try
184
+ {
185
+ tmpResult.value = pRows.affectedRows;
186
+ }
187
+ catch (pErrorGettingRowcount)
188
+ {
189
+ _Fable.log.warn('Error getting affected rowcount during delete query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
190
+ }
191
+ tmpResult.executed = true;
192
+ return fCallback();
193
+ }
194
+ );
195
+ });
196
+ };
197
+
198
+ var Undelete = function (pQuery, fCallback)
199
+ {
200
+ var tmpResult = pQuery.parameters.result;
201
+
202
+ pQuery.setDialect('MySQL').buildUndeleteQuery();
203
+
204
+ if (pQuery.logLevel > 0)
205
+ {
206
+ _Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
207
+ }
208
+
209
+ getDB().getConnection(function (pError, pDBConnection)
210
+ {
211
+ pDBConnection.query
212
+ (
213
+ pQuery.query.body,
214
+ pQuery.query.parameters,
215
+ function (pError, pRows)
216
+ {
217
+ pDBConnection.release();
218
+ tmpResult.error = pError;
219
+ tmpResult.value = false;
220
+ try
221
+ {
222
+ tmpResult.value = pRows.affectedRows;
223
+ }
224
+ catch (pErrorGettingRowcount)
225
+ {
226
+ _Fable.log.warn('Error getting affected rowcount during delete query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
227
+ }
228
+ tmpResult.executed = true;
229
+ return fCallback();
230
+ }
231
+ );
232
+ });
233
+ };
234
+
235
+ var Count = function (pQuery, fCallback)
236
+ {
237
+ var tmpResult = pQuery.parameters.result;
238
+
239
+ pQuery.setDialect('MySQL').buildCountQuery();
240
+
241
+ if (pQuery.logLevel > 0)
242
+ {
243
+ _Fable.log.trace(pQuery.query.body, pQuery.query.parameters);
244
+ }
245
+
246
+ getDB().getConnection(function (pError, pDBConnection)
247
+ {
248
+ pDBConnection.query(
249
+ pQuery.query.body,
250
+ pQuery.query.parameters,
251
+ // The SQLite library also returns the Fields as the third parameter
252
+ function (pError, pRows)
253
+ {
254
+ pDBConnection.release();
255
+ tmpResult.executed = true;
256
+ tmpResult.error = pError;
257
+ tmpResult.value = false;
258
+ try
259
+ {
260
+ tmpResult.value = pRows[0].RowCount;
261
+ }
262
+ catch (pErrorGettingRowcount)
263
+ {
264
+ _Fable.log.warn('Error getting rowcount during count query', { Body: pQuery.query.body, Parameters: pQuery.query.parameters });
265
+ }
266
+ return fCallback();
267
+ }
268
+ );
269
+ });
270
+ };
271
+
272
+ var tmpNewProvider = (
273
+ {
274
+ marshalRecordFromSourceToObject: marshalRecordFromSourceToObject,
275
+
276
+ Create: Create,
277
+ Read: Read,
278
+ Update: Update,
279
+ Delete: Delete,
280
+ Undelete: Undelete,
281
+ Count: Count,
282
+
283
+ getProvider: getProvider,
284
+ providerCreatesSupported: true,
285
+
286
+ new: createNew
287
+ });
288
+
289
+
290
+ return tmpNewProvider;
291
+ }
292
+
293
+ return createNew();
294
+ };
295
+
296
+ module.exports = new MeadowProvider();