Skip to content

Commit 525863d

Browse files
committed
remove debug test code
1 parent cc60198 commit 525863d

2 files changed

Lines changed: 12 additions & 80 deletions

File tree

packages/lib/tests/integration/nested-fields.integration.test.ts

Lines changed: 10 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { ObjectId } from 'mongodb';
2-
import { testSetup, createLogger } from './test-setup';
3-
4-
const log = createLogger('nested-fields');
2+
import { testSetup } from './test-setup';
53

64
describe('Nested Fields Integration Tests', () => {
75
beforeAll(async () => {
@@ -62,8 +60,7 @@ describe('Nested Fields Integration Tests', () => {
6260
`;
6361

6462
const results = await queryLeaf.execute(sql);
65-
log('Nested fields results:', JSON.stringify(results, null, 2));
66-
63+
6764
// Assert: Verify we can access the data
6865
expect(results).toHaveLength(1);
6966
expect(results[0].name).toBe('John Smith');
@@ -113,17 +110,8 @@ describe('Nested Fields Integration Tests', () => {
113110
FROM contact_profiles
114111
WHERE contact.address.city = 'Boston'
115112
`;
116-
117-
log('Running nested field query:', sql);
118-
119-
// Try direct MongoDB query to verify data exists
120-
const directQueryResults = await testSetup.getDb().collection('contact_profiles')
121-
.find({'contact.address.city': 'Boston'})
122-
.toArray();
123-
log('Direct MongoDB query results:', JSON.stringify(directQueryResults, null, 2));
124-
113+
125114
const results = await queryLeaf.execute(sql);
126-
log('Nested filter results:', JSON.stringify(results, null, 2));
127115

128116
// Assert: Verify only Bostonians are returned
129117
expect(results).toHaveLength(2);
@@ -176,7 +164,6 @@ describe('Nested Fields Integration Tests', () => {
176164
`;
177165

178166
const results = await queryLeaf.execute(sql);
179-
log('Nested comparison results:', JSON.stringify(results, null, 2));
180167

181168
// Assert: Verify only products matching nested criteria are returned
182169
expect(results).toHaveLength(2);
@@ -227,11 +214,7 @@ describe('Nested Fields Integration Tests', () => {
227214
}
228215
}
229216
]);
230-
231-
// Act - first check with direct MongoDB query to confirm data
232-
const directLaptopQuery = await db.collection('products').findOne({ name: 'Laptop' });
233-
log('Direct laptop query result:', JSON.stringify(directLaptopQuery, null, 2));
234-
217+
235218
// Use QueryLeaf to query the data
236219
const queryLeaf = testSetup.getQueryLeaf();
237220
const sql = `
@@ -243,13 +226,7 @@ describe('Nested Fields Integration Tests', () => {
243226
`;
244227

245228
const results = await queryLeaf.execute(sql);
246-
log('Nested fields query results:', JSON.stringify(results, null, 2));
247-
248-
// Helper function to safely access nested properties
249-
const getNestedProp = (obj: any, path: string[]) => {
250-
return path.reduce((o, key) => (o && typeof o === 'object') ? o[key] : undefined, obj);
251-
};
252-
229+
253230
// Assert: Verify results count and basic structure
254231
expect(results).toHaveLength(2);
255232

@@ -361,11 +338,7 @@ describe('Nested Fields Integration Tests', () => {
361338
zip: '98101'
362339
}
363340
});
364-
365-
// Verify the data with a direct MongoDB query
366-
const directQuery = await db.collection('products').findOne({ name: 'Tablet' });
367-
log('Direct query result:', JSON.stringify(directQuery, null, 2));
368-
341+
369342
// Act: Execute a query selecting a nested field
370343
const queryLeaf = testSetup.getQueryLeaf();
371344
const sql = `
@@ -375,31 +348,13 @@ describe('Nested Fields Integration Tests', () => {
375348
FROM products
376349
WHERE name = 'Tablet'
377350
`;
378-
379-
log('Running nested field selection query:', sql);
380-
381-
// Use a direct MongoDB aggregate query to test our approach
382-
const directAggregateResult = await db.collection('products').aggregate([
383-
{ $match: { name: 'Tablet' } },
384-
{ $project: {
385-
name: 1,
386-
address_city: '$address.city'
387-
}
388-
}
389-
]).toArray();
390-
log('Direct aggregate result:', JSON.stringify(directAggregateResult, null, 2));
391-
392-
// Use the direct MongoDB aggregation to verify the approach works
351+
393352
const results = await queryLeaf.execute(sql);
394-
log('Nested field selection results:', JSON.stringify(results, null, 2));
395353

396354
// Assert: Verify we can access the nested field data
397355
expect(results).toHaveLength(1);
398356
expect(results[0].name).toBe('Tablet');
399357

400-
// Log the structure of the results for debugging
401-
log('Result structure:', JSON.stringify(results[0], null, 2));
402-
403358
// With the updated implementation, the nested field should be "pulled up" to the top level
404359
// The field should be directly accessible using the field name without the parent part
405360
expect(results[0].name).toBe('Tablet');
@@ -438,31 +393,12 @@ describe('Nested Fields Integration Tests', () => {
438393
WHERE name = 'Monitor'
439394
`;
440395

441-
log('Running multiple nested field selection query:', sql);
442396
const results = await queryLeaf.execute(sql);
443-
log('Multiple nested field selection results:', JSON.stringify(results, null, 2));
444-
397+
445398
// Assert: Verify we can access the nested field data at the top level
446399
expect(results).toHaveLength(1);
447400
expect(results[0].name).toBe('Monitor');
448-
449-
// Log the full results for debugging
450-
console.log('FULL RESULTS:', JSON.stringify(results[0], null, 2));
451-
console.log('AVAILABLE KEYS:', Object.keys(results[0]));
452-
453-
// For debugging, execute a direct MongoDB aggregation
454-
const directAggResult = await db.collection('products').aggregate([
455-
{ $match: { name: 'Monitor' } },
456-
{ $project: {
457-
name: 1,
458-
specs_resolution: '$specs.resolution',
459-
specs_refreshRate: '$specs.refreshRate',
460-
specs_size_diagonal: '$specs.size.diagonal'
461-
}
462-
}
463-
]).toArray();
464-
console.log('DIRECT AGGREGATE:', JSON.stringify(directAggResult[0], null, 2));
465-
401+
466402
// All nested fields should be flattened to the top level with underscore notation
467403
expect(results[0].specs_resolution).toBe('4K');
468404
expect(results[0].specs_refreshRate).toBe(144);
@@ -471,4 +407,4 @@ describe('Nested Fields Integration Tests', () => {
471407
// The original nested structure should not be present
472408
expect(results[0].specs).toBeUndefined();
473409
});
474-
});
410+
});

packages/lib/tests/integration/nested-update-issue.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { testSetup, createLogger } from './test-setup';
2-
3-
const log = createLogger('nested-update-issue');
1+
import { testSetup } from './test-setup';
42

53
describe('Nested Fields Update Issue', () => {
64
beforeAll(async () => {
@@ -89,14 +87,12 @@ describe('Nested Fields Update Issue', () => {
8987
SET shipping.address.country.name = 'Canada'
9088
WHERE name = 'Bob Johnson'
9189
`;
92-
console.log('Deeply nested UPDATE SQL:', updateSql);
9390

9491
// Execute the SQL via QueryLeaf
9592
await queryLeaf.execute(updateSql);
9693

9794
// Get the result after the update
9895
const updatedCustomer = await db.collection('customers').findOne({ name: 'Bob Johnson' });
99-
console.log('Deeply nested update result:', JSON.stringify(updatedCustomer, null, 2));
10096

10197
// Assert - the deeply nested field should be updated
10298
expect(updatedCustomer?.shipping?.address?.country?.name).toBe('Canada');
@@ -159,4 +155,4 @@ describe('Nested Fields Update Issue', () => {
159155
// Make sure no top-level fields were created by mistake
160156
expect(updatedCustomer).not.toHaveProperty('postalCode');
161157
});
162-
});
158+
});

0 commit comments

Comments
 (0)