masterrecord 0.3.68 → 1.0.0

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.
Files changed (97) hide show
  1. package/.claude/settings.local.json +3 -1
  2. package/CHANGES.md +31 -2
  3. package/Cache/QueryCache.js +10 -4
  4. package/Cache/RedisQueryCache.js +3 -2
  5. package/Entity/entityModel.js +1 -1
  6. package/Entity/entityModelBuilder.js +2 -2
  7. package/Entity/entityTrackerModel.js +3 -3
  8. package/Entity/fieldTransformer.js +1 -1
  9. package/FOREIGN_KEY_STRING_FIX.md +2 -2
  10. package/MasterRecord.js +6 -43
  11. package/Migrations/cli.js +44 -113
  12. package/Migrations/dependencyGraph.js +1 -1
  13. package/Migrations/migrationMySQLQuery.js +1 -1
  14. package/Migrations/migrationPostgresQuery.js +1 -1
  15. package/Migrations/migrationSQLiteQuery.js +1 -1
  16. package/Migrations/migrationTemplate.js +8 -39
  17. package/Migrations/migrations.js +16 -14
  18. package/Migrations/pathUtils.js +2 -5
  19. package/Migrations/pathUtils.test.js +33 -49
  20. package/Migrations/schema.js +52 -89
  21. package/QueryLanguage/queryMethods.js +4 -4
  22. package/QueryLanguage/queryParameters.js +1 -1
  23. package/QueryLanguage/queryScript.js +4 -3
  24. package/SQLLiteEngine.js +26 -7
  25. package/Tools.js +10 -8
  26. package/context.js +43 -42
  27. package/deleteManager.js +2 -2
  28. package/docs/MIGRATIONS_GUIDE.md +237 -532
  29. package/docs/POSTGRESQL_SETUP.md +4 -4
  30. package/docs/QUERY_CACHING_GUIDE.md +8 -7
  31. package/eslint.config.js +40 -0
  32. package/insertManager.js +28 -20
  33. package/mySQLConnect.js +2 -2
  34. package/mySQLEngine.js +26 -6
  35. package/package.json +34 -5
  36. package/postgresEngine.js +29 -8
  37. package/postgresSyncConnect.js +5 -3
  38. package/prettier.config.js +22 -0
  39. package/readme.md +35 -27
  40. package/test/context-errors.test.js +43 -0
  41. package/test/esm-imports.test.js +110 -0
  42. package/test/fixtures/new-setter-large-string/config/environments/env.newsetter.json +1 -0
  43. package/test/fixtures/new-setter-large-string/db/newsettercontext.sqlite +0 -0
  44. package/test/fixtures/sqlite-lifecycle/config/environments/env.test.json +1 -0
  45. package/test/fixtures/sqlite-lifecycle/db/lifecyclecontext.sqlite +0 -0
  46. package/test/migration-template.test.js +47 -0
  47. package/test/new-setter-large-string.test.js +191 -0
  48. package/test/pool-key.test.js +43 -0
  49. package/test/sqlite-lifecycle.test.js +76 -0
  50. package/.eslintrc.js +0 -290
  51. package/.prettierrc.js +0 -109
  52. package/test/anyCommaStringTest.js +0 -237
  53. package/test/anyMethodTest.js +0 -176
  54. package/test/attachDetached.test.js +0 -303
  55. package/test/bulk-operations-test.js +0 -235
  56. package/test/cache-toObject-test.js +0 -105
  57. package/test/cacheIntegration.test.js +0 -319
  58. package/test/config-glob-pattern-test.js +0 -232
  59. package/test/double-where-bug-test.js +0 -71
  60. package/test/ensure-ready-test.js +0 -251
  61. package/test/entity-deduplication-test.js +0 -174
  62. package/test/entity-methods-test.js +0 -269
  63. package/test/findByIdTest.js +0 -227
  64. package/test/foreign-key-string-value-test.js +0 -406
  65. package/test/global-model-registry-test.js +0 -538
  66. package/test/id-setting-validation.js +0 -202
  67. package/test/includesFeatureTest.js +0 -183
  68. package/test/includesTransformTest.js +0 -110
  69. package/test/index-bug-fix-test.js +0 -188
  70. package/test/insert-return-test.js +0 -39
  71. package/test/lifecycle-hooks-test.js +0 -258
  72. package/test/multiContextCache.test.js +0 -230
  73. package/test/new-entity-migration-test.js +0 -162
  74. package/test/newMethodTest.js +0 -330
  75. package/test/newMethodUnitTest.js +0 -320
  76. package/test/optInCache.test.js +0 -221
  77. package/test/parameterizedPlaceholderTest.js +0 -159
  78. package/test/pool-registry-test.js +0 -303
  79. package/test/post-insert-tracking-test.js +0 -258
  80. package/test/postgresEngineTest.js +0 -463
  81. package/test/postgresIntegrationTest.js +0 -381
  82. package/test/promise-detection-test.js +0 -290
  83. package/test/qa-context-pattern-test.js +0 -319
  84. package/test/query-helpers-test.js +0 -258
  85. package/test/query-isolation-test.js +0 -59
  86. package/test/queryCache.test.js +0 -148
  87. package/test/securityTest.js +0 -268
  88. package/test/seed-data-test.js +0 -212
  89. package/test/seed-deduplication-test.js +0 -313
  90. package/test/seed-features-integration-test.js +0 -418
  91. package/test/seed-migration-template-test.js +0 -220
  92. package/test/singleDollarPlaceholderTest.js +0 -238
  93. package/test/tablePrefixTest.js +0 -100
  94. package/test/transformerTest.js +0 -287
  95. package/test/v0.3.34-bug-fixes-test.js +0 -428
  96. package/test/validation-test.js +0 -302
  97. package/test/whereChainingTest.js +0 -88
package/.eslintrc.js DELETED
@@ -1,290 +0,0 @@
1
- /**
2
- * ESLint Configuration - FAANG Standards
3
- * Based on Google/Airbnb/Meta style guides
4
- */
5
-
6
- module.exports = {
7
- env: {
8
- node: true,
9
- es2021: true,
10
- jest: true
11
- },
12
-
13
- extends: [
14
- 'eslint:recommended',
15
- ],
16
-
17
- parserOptions: {
18
- ecmaVersion: 2021,
19
- sourceType: 'module'
20
- },
21
-
22
- rules: {
23
- // ====================================================================
24
- // CRITICAL RULES (Would fail Google/Meta code review)
25
- // ====================================================================
26
-
27
- // No var - use const/let only
28
- 'no-var': 'error',
29
-
30
- // Prefer const over let when possible
31
- 'prefer-const': 'error',
32
-
33
- // No unused variables (production bloat)
34
- 'no-unused-vars': ['error', {
35
- vars: 'all',
36
- args: 'after-used',
37
- ignoreRestSiblings: true,
38
- argsIgnorePattern: '^_' // Allow _unused
39
- }],
40
-
41
- // No console.log in production (use logger)
42
- 'no-console': ['warn', {
43
- allow: ['warn', 'error']
44
- }],
45
-
46
- // Require === instead of ==
47
- 'eqeqeq': ['error', 'always'],
48
-
49
- // No eval() - security risk
50
- 'no-eval': 'error',
51
-
52
- // No implied eval
53
- 'no-implied-eval': 'error',
54
-
55
- // Async functions must have await
56
- 'require-await': 'error',
57
-
58
- // No async without await
59
- 'no-async-promise-executor': 'error',
60
-
61
- // No floating promises
62
- 'no-floating-decimal': 'error',
63
-
64
- // ====================================================================
65
- // ERROR HANDLING (Amazon principle: Be resilient)
66
- // ====================================================================
67
-
68
- // Require error handling in callbacks
69
- 'handle-callback-err': ['error', '^(err|error)$'],
70
-
71
- // No empty catch blocks
72
- 'no-empty': ['error', {
73
- allowEmptyCatch: false
74
- }],
75
-
76
- // Don't throw literals
77
- 'no-throw-literal': 'error',
78
-
79
- // ====================================================================
80
- // CODE QUALITY (Google principle: Readability)
81
- // ====================================================================
82
-
83
- // Max function complexity (cyclomatic)
84
- 'complexity': ['warn', 10],
85
-
86
- // Max function length
87
- 'max-lines-per-function': ['warn', {
88
- max: 50,
89
- skipBlankLines: true,
90
- skipComments: true
91
- }],
92
-
93
- // Max parameters
94
- 'max-params': ['warn', 5],
95
-
96
- // Max nested callbacks
97
- 'max-nested-callbacks': ['warn', 3],
98
-
99
- // Max depth
100
- 'max-depth': ['warn', 4],
101
-
102
- // Consistent return
103
- 'consistent-return': 'error',
104
-
105
- // No duplicate imports
106
- 'no-duplicate-imports': 'error',
107
-
108
- // ====================================================================
109
- // NAMING CONVENTIONS (Google/Meta standard)
110
- // ====================================================================
111
-
112
- // camelCase for variables
113
- 'camelcase': ['error', {
114
- properties: 'never',
115
- ignoreDestructuring: true,
116
- allow: ['^__'] // Allow __private
117
- }],
118
-
119
- // No underscore dangle (except for __private)
120
- 'no-underscore-dangle': ['error', {
121
- allow: ['__', '__name', '__state', '__entity', '__ID', '__dirtyFields', '__context', '__trackedEntities', '__entities', '__builderEntities', '__relationshipModels', '__environment', '__trackedEntitiesMap'],
122
- allowAfterThis: true,
123
- allowAfterSuper: true
124
- }],
125
-
126
- // ====================================================================
127
- // SPACING & FORMATTING (Prettier will handle most of this)
128
- // ====================================================================
129
-
130
- // Indent: 4 spaces (Google standard)
131
- 'indent': ['error', 4, {
132
- SwitchCase: 1
133
- }],
134
-
135
- // Single quotes
136
- 'quotes': ['error', 'single', {
137
- avoidEscape: true,
138
- allowTemplateLiterals: true
139
- }],
140
-
141
- // Semicolons required
142
- 'semi': ['error', 'always'],
143
-
144
- // Space before function paren
145
- 'space-before-function-paren': ['error', {
146
- anonymous: 'never',
147
- named: 'never',
148
- asyncArrow: 'always'
149
- }],
150
-
151
- // Arrow function spacing
152
- 'arrow-spacing': 'error',
153
-
154
- // Object curly spacing
155
- 'object-curly-spacing': ['error', 'always'],
156
-
157
- // Array bracket spacing
158
- 'array-bracket-spacing': ['error', 'never'],
159
-
160
- // Comma spacing
161
- 'comma-spacing': ['error', {
162
- before: false,
163
- after: true
164
- }],
165
-
166
- // Key spacing
167
- 'key-spacing': ['error', {
168
- beforeColon: false,
169
- afterColon: true
170
- }],
171
-
172
- // ====================================================================
173
- // BEST PRACTICES (Meta/Amazon standards)
174
- // ====================================================================
175
-
176
- // No magic numbers
177
- 'no-magic-numbers': ['warn', {
178
- ignore: [-1, 0, 1, 2],
179
- ignoreArrayIndexes: true,
180
- ignoreDefaultValues: true,
181
- enforceConst: true
182
- }],
183
-
184
- // Require JSDoc for public methods
185
- 'require-jsdoc': ['warn', {
186
- require: {
187
- FunctionDeclaration: true,
188
- MethodDefinition: true,
189
- ClassDeclaration: true
190
- }
191
- }],
192
-
193
- // Valid JSDoc
194
- 'valid-jsdoc': ['warn', {
195
- requireReturn: false,
196
- requireReturnType: false,
197
- requireParamType: false,
198
- prefer: {
199
- return: 'returns',
200
- arg: 'param',
201
- argument: 'param'
202
- }
203
- }],
204
-
205
- // No param reassign
206
- 'no-param-reassign': ['error', {
207
- props: false
208
- }],
209
-
210
- // Prefer arrow callbacks
211
- 'prefer-arrow-callback': 'warn',
212
-
213
- // Prefer template literals
214
- 'prefer-template': 'warn',
215
-
216
- // Prefer destructuring
217
- 'prefer-destructuring': ['warn', {
218
- array: false,
219
- object: true
220
- }],
221
-
222
- // Prefer rest params
223
- 'prefer-rest-params': 'error',
224
-
225
- // Prefer spread
226
- 'prefer-spread': 'error',
227
-
228
- // ====================================================================
229
- // SECURITY (Amazon principle: Security by default)
230
- // ====================================================================
231
-
232
- // No unsafe regex
233
- 'no-unsafe-regex': 'error',
234
-
235
- // No buffer constructor
236
- 'no-buffer-constructor': 'error',
237
-
238
- // No process.exit()
239
- 'no-process-exit': 'warn',
240
-
241
- // ====================================================================
242
- // NODE.JS SPECIFIC
243
- // ====================================================================
244
-
245
- // Callback return
246
- 'callback-return': ['error', ['callback', 'cb', 'next', 'done']],
247
-
248
- // No sync methods (prefer async)
249
- 'no-sync': 'warn',
250
-
251
- // Handle errors in promise callbacks
252
- 'promise/always-return': 'off', // Too strict for ORM
253
- 'promise/catch-or-return': 'off' // Too strict for ORM
254
- },
255
-
256
- // ========================================================================
257
- // OVERRIDES FOR SPECIFIC FILES
258
- // ========================================================================
259
-
260
- overrides: [
261
- // Test files - relax some rules
262
- {
263
- files: ['**/*.test.js', '**/*.spec.js', '**/tests/**/*.js'],
264
- env: {
265
- jest: true
266
- },
267
- rules: {
268
- 'no-magic-numbers': 'off',
269
- 'max-lines-per-function': 'off',
270
- 'no-console': 'off'
271
- }
272
- },
273
-
274
- // Migration scripts - allow console
275
- {
276
- files: ['**/migrations/**/*.js'],
277
- rules: {
278
- 'no-console': 'off'
279
- }
280
- },
281
-
282
- // Config files - relax rules
283
- {
284
- files: ['*.config.js', '.*.js'],
285
- rules: {
286
- 'no-magic-numbers': 'off'
287
- }
288
- }
289
- ]
290
- };
package/.prettierrc.js DELETED
@@ -1,109 +0,0 @@
1
- /**
2
- * Prettier Configuration - FAANG Standards
3
- * Based on Meta/Google style guides
4
- */
5
-
6
- module.exports = {
7
- // ========================================================================
8
- // BASIC FORMATTING
9
- // ========================================================================
10
-
11
- // Line width (Google: 80-120, Meta: 80)
12
- printWidth: 100,
13
-
14
- // Tab width (Google standard: 4 spaces for JS, Meta uses 2)
15
- // Using 4 for consistency with Google
16
- tabWidth: 4,
17
-
18
- // Use spaces, not tabs
19
- useTabs: false,
20
-
21
- // Semicolons required (Google/Meta standard)
22
- semi: true,
23
-
24
- // Single quotes (Google/Meta standard)
25
- singleQuote: true,
26
-
27
- // Quote object properties only when needed
28
- quoteProps: 'as-needed',
29
-
30
- // ========================================================================
31
- // TRAILING COMMAS (Meta standard)
32
- // ========================================================================
33
-
34
- // Trailing commas where valid in ES5 (objects, arrays, etc.)
35
- // Meta uses 'all', Google uses 'es5'
36
- trailingComma: 'es5',
37
-
38
- // ========================================================================
39
- // SPACING
40
- // ========================================================================
41
-
42
- // Spaces inside object braces
43
- bracketSpacing: true,
44
-
45
- // Spaces inside array brackets
46
- bracketSameLine: false,
47
-
48
- // Arrow function parens (Google: avoid when possible)
49
- arrowParens: 'avoid',
50
-
51
- // ========================================================================
52
- // LINE BREAKS
53
- // ========================================================================
54
-
55
- // End of line (Unix standard)
56
- endOfLine: 'lf',
57
-
58
- // Wrap prose (for markdown files)
59
- proseWrap: 'preserve',
60
-
61
- // ========================================================================
62
- // HTML/JSX (if used)
63
- // ========================================================================
64
-
65
- // HTML whitespace sensitivity
66
- htmlWhitespaceSensitivity: 'css',
67
-
68
- // Self-closing tags
69
- singleAttributePerLine: false,
70
-
71
- // ========================================================================
72
- // FILE-SPECIFIC OVERRIDES
73
- // ========================================================================
74
-
75
- overrides: [
76
- // Markdown files - wrap at 80
77
- {
78
- files: '*.md',
79
- options: {
80
- printWidth: 80,
81
- proseWrap: 'always',
82
- },
83
- },
84
-
85
- // JSON files - 2 space indent
86
- {
87
- files: '*.json',
88
- options: {
89
- tabWidth: 2,
90
- },
91
- },
92
-
93
- // YAML files - 2 space indent
94
- {
95
- files: ['*.yml', '*.yaml'],
96
- options: {
97
- tabWidth: 2,
98
- },
99
- },
100
-
101
- // Package.json - 2 space indent (npm standard)
102
- {
103
- files: 'package.json',
104
- options: {
105
- tabWidth: 2,
106
- },
107
- },
108
- ],
109
- };
@@ -1,237 +0,0 @@
1
- /**
2
- * Test: .any() with Comma-Separated Strings
3
- *
4
- * Bug: .any() only worked with arrays, not comma-separated strings
5
- *
6
- * Broken query:
7
- * .where(j => j.id.any($$), "1,2,3")
8
- * Generated: WHERE id IN (?) with params: ["1,2,3"] ❌
9
- *
10
- * Expected:
11
- * WHERE id IN (?, ?, ?) with params: [1, 2, 3] ✅
12
- *
13
- * Fix: Split comma-separated strings into arrays before processing
14
- */
15
-
16
- const QueryParameters = require('../QueryLanguage/queryParameters');
17
-
18
- console.log("╔════════════════════════════════════════════════════════════════╗");
19
- console.log("║ .any() Comma-Separated String Support Test ║");
20
- console.log("╚════════════════════════════════════════════════════════════════╝\n");
21
-
22
- let passed = 0;
23
- let failed = 0;
24
-
25
- // Mock the parameter replacement logic
26
- function processParameter(item, dbType = 'mysql') {
27
- const params = new QueryParameters();
28
-
29
- // Check if this is an array (for IN clauses / .includes() / .any())
30
- let itemArray = null;
31
- if(Array.isArray(item)){
32
- itemArray = item;
33
- }
34
- // Also handle comma-separated strings for .any() method
35
- else if(typeof item === 'string' && item.includes(',')){
36
- // Split comma-separated string into array
37
- itemArray = item.split(',').map(v => v.trim());
38
- }
39
-
40
- if(itemArray){
41
- // Add array parameters and get comma-separated placeholders
42
- const placeholders = params.addParams(itemArray, dbType);
43
- const paramValues = params.getParams();
44
- return { placeholders, paramValues, count: itemArray.length };
45
- }
46
- else{
47
- // Single value
48
- const placeholder = params.addParam(item, dbType);
49
- const paramValues = params.getParams();
50
- return { placeholders: placeholder, paramValues, count: 1 };
51
- }
52
- }
53
-
54
- // Test 1: Array (already worked)
55
- console.log("📝 Test 1: .any() with array (existing behavior)");
56
- console.log("──────────────────────────────────────────────────");
57
-
58
- try {
59
- const result = processParameter([1, 2, 3]);
60
-
61
- if(result.count === 3 && result.placeholders === '?, ?, ?' && result.paramValues.length === 3){
62
- console.log(" ✓ Array processed correctly");
63
- console.log(` ✓ Input: [1, 2, 3]`);
64
- console.log(` ✓ Placeholders: ${result.placeholders}`);
65
- console.log(` ✓ Params: [${result.paramValues.join(', ')}]`);
66
- passed++;
67
- } else {
68
- console.log(` ✗ Array processing failed`);
69
- console.log(` ✗ Got: ${result.placeholders}`);
70
- failed++;
71
- }
72
- } catch(err) {
73
- console.log(` ✗ Error: ${err.message}`);
74
- failed++;
75
- }
76
-
77
- // Test 2: Comma-separated string (THE BUG FIX)
78
- console.log("\n📝 Test 2: .any() with comma-separated string (BUG FIX)");
79
- console.log("──────────────────────────────────────────────────");
80
-
81
- try {
82
- const result = processParameter("1,2,3");
83
-
84
- if(result.count === 3 && result.placeholders === '?, ?, ?' && result.paramValues.length === 3){
85
- console.log(" ✓ Comma-separated string processed correctly");
86
- console.log(` ✓ Input: "1,2,3"`);
87
- console.log(` ✓ Placeholders: ${result.placeholders}`);
88
- console.log(` ✓ Params: [${result.paramValues.join(', ')}]`);
89
- console.log(" ✅ This was the broken case - now fixed!");
90
- passed++;
91
- } else {
92
- console.log(` ✗ Comma-separated string processing failed`);
93
- console.log(` ✗ Got: ${result.placeholders}`);
94
- console.log(` ✗ Expected: ?, ?, ?`);
95
- failed++;
96
- }
97
- } catch(err) {
98
- console.log(` ✗ Error: ${err.message}`);
99
- failed++;
100
- }
101
-
102
- // Test 3: Comma-separated string with spaces
103
- console.log("\n📝 Test 3: .any() with spaces in comma-separated string");
104
- console.log("──────────────────────────────────────────────────");
105
-
106
- try {
107
- const result = processParameter("Alice, Bob, Charlie");
108
-
109
- if(result.count === 3 && result.placeholders === '?, ?, ?'){
110
- console.log(" ✓ String with spaces processed correctly");
111
- console.log(` ✓ Input: "Alice, Bob, Charlie"`);
112
- console.log(` ✓ Placeholders: ${result.placeholders}`);
113
- console.log(` ✓ Params: [${result.paramValues.join(', ')}]`);
114
- console.log(` ✓ Values trimmed: ["${result.paramValues.join('", "')}"]`);
115
- passed++;
116
- } else {
117
- console.log(` ✗ String with spaces processing failed`);
118
- failed++;
119
- }
120
- } catch(err) {
121
- console.log(` ✗ Error: ${err.message}`);
122
- failed++;
123
- }
124
-
125
- // Test 4: Single value (no comma)
126
- console.log("\n📝 Test 4: Single value without comma");
127
- console.log("──────────────────────────────────────────────────");
128
-
129
- try {
130
- const result = processParameter("Alice");
131
-
132
- if(result.count === 1 && result.placeholders === '?' && result.paramValues.length === 1){
133
- console.log(" ✓ Single value processed correctly");
134
- console.log(` ✓ Input: "Alice"`);
135
- console.log(` ✓ Placeholders: ${result.placeholders}`);
136
- console.log(` ✓ Params: [${result.paramValues.join(', ')}]`);
137
- passed++;
138
- } else {
139
- console.log(` ✗ Single value processing failed`);
140
- failed++;
141
- }
142
- } catch(err) {
143
- console.log(` ✗ Error: ${err.message}`);
144
- failed++;
145
- }
146
-
147
- // Test 5: Numeric string values
148
- console.log("\n📝 Test 5: Numeric comma-separated string");
149
- console.log("──────────────────────────────────────────────────");
150
-
151
- try {
152
- const result = processParameter("10,20,30,40,50");
153
-
154
- if(result.count === 5 && result.placeholders === '?, ?, ?, ?, ?'){
155
- console.log(" ✓ Numeric string processed correctly");
156
- console.log(` ✓ Input: "10,20,30,40,50"`);
157
- console.log(` ✓ Placeholders: ${result.placeholders}`);
158
- console.log(` ✓ Params: [${result.paramValues.join(', ')}]`);
159
- passed++;
160
- } else {
161
- console.log(` ✗ Numeric string processing failed`);
162
- failed++;
163
- }
164
- } catch(err) {
165
- console.log(` ✗ Error: ${err.message}`);
166
- failed++;
167
- }
168
-
169
- // Test 6: Postgres placeholders
170
- console.log("\n📝 Test 6: Postgres placeholder format");
171
- console.log("──────────────────────────────────────────────────");
172
-
173
- try {
174
- const result = processParameter("1,2,3", 'postgres');
175
-
176
- if(result.count === 3 && result.placeholders === '$1, $2, $3'){
177
- console.log(" ✓ Postgres placeholders generated correctly");
178
- console.log(` ✓ Input: "1,2,3"`);
179
- console.log(` ✓ Placeholders: ${result.placeholders}`);
180
- console.log(` ✓ Params: [${result.paramValues.join(', ')}]`);
181
- passed++;
182
- } else {
183
- console.log(` ✗ Postgres format failed`);
184
- console.log(` ✗ Expected: $1, $2, $3`);
185
- console.log(` ✗ Got: ${result.placeholders}`);
186
- failed++;
187
- }
188
- } catch(err) {
189
- console.log(` ✗ Error: ${err.message}`);
190
- failed++;
191
- }
192
-
193
- // Summary
194
- console.log("\n\n╔════════════════════════════════════════════════════════════════╗");
195
- console.log("║ Test Summary ║");
196
- console.log("╚════════════════════════════════════════════════════════════════╝");
197
-
198
- const total = passed + failed;
199
- const successRate = total > 0 ? Math.round((passed/total)*100) : 0;
200
-
201
- console.log(`\n Total Tests: ${total}`);
202
- console.log(` ✅ Passed: ${passed}`);
203
- console.log(` ❌ Failed: ${failed}`);
204
- console.log(` Success Rate: ${successRate}%\n`);
205
-
206
- if(failed === 0){
207
- console.log("🎉 All comma-separated string tests passed!");
208
- console.log("\n✨ Bug Fixed: .any() Now Supports Comma-Separated Strings!");
209
- console.log("\n📖 What Was Fixed:");
210
- console.log(" - .any() now splits comma-separated strings into arrays");
211
- console.log(" - Each value becomes a separate parameter");
212
- console.log(" - Generates correct IN (?, ?, ?) SQL");
213
- console.log(" - Trims whitespace from values");
214
- console.log("\n📖 Original Bug:");
215
- console.log(" Query: .where(j => j.id.any($$), '1,2,3')");
216
- console.log(" Generated (WRONG): WHERE id IN (?)");
217
- console.log(" Params (WRONG): ['1,2,3']");
218
- console.log("\n📖 After Fix:");
219
- console.log(" Query: .where(j => j.id.any($$), '1,2,3')");
220
- console.log(" Generated (CORRECT): WHERE id IN (?, ?, ?)");
221
- console.log(" Params (CORRECT): [1, 2, 3]");
222
- console.log("\n📖 Supported Formats:");
223
- console.log(" ✅ Array: .where(j => j.id.any($$), [1, 2, 3])");
224
- console.log(" ✅ Comma string: .where(j => j.id.any($$), '1,2,3')");
225
- console.log(" ✅ With spaces: .where(j => j.id.any($$), '1, 2, 3')");
226
- console.log(" ✅ .includes() syntax: .where(j => $$.includes(j.id), [1, 2, 3])");
227
- console.log("\n📖 Your Original Query Will Now Work:");
228
- console.log(" failureJobs = this._qaContext.QaIntelligenceJob");
229
- console.log(" .where(j => j.annotation_id.any($$) && j.job_type == $$ && j.status == $$,");
230
- console.log(" annotationIds.join(','), 'failure_classification', 'succeeded')");
231
- console.log(" .toList();");
232
- console.log("\n✅ No more memory filtering needed!\n");
233
- process.exit(0);
234
- } else {
235
- console.log("⚠️ Some tests failed. Review implementation.");
236
- process.exit(1);
237
- }