Skip to content

Add nested object query tests #352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Add nested object query tests #352

wants to merge 2 commits into from

Conversation

KyleAMathews
Copy link
Collaborator

Summary

Added comprehensive test coverage for querying nested objects in TanStack DB across WHERE, SELECT, GROUP BY, and ORDER BY operations.

Test Status

  • Test Files: 3 failed | 34 passed (37 total)
  • Individual Tests: 26 failed | 657 passed (683 total)

✅ Working

  • Basic nested object tests (32/32 passing)
  • Most query operations with nested properties (657 tests passing)
  • Proper query builder syntax for nested property access

❌ Known Issues

  • Query Compilation Errors: WHERE clauses filtering on nested object existence combined with direct property access cause "Unknown expression type: undefined" errors
  • Assertion Errors: Some ORDER BY tests expect 0 for missing nested properties but get undefined
  • TypeScript Errors: 216 type errors from accessing potentially undefined nested properties

Next Steps

The failing tests reveal areas where the query compiler needs better handling of nested object patterns. The working tests demonstrate the correct syntax patterns for nested object queries.

🤖 Generated with Claude Code

KyleAMathews and others added 2 commits July 31, 2025 15:31
Added extensive test coverage for querying nested objects across all major query operations:

## Test Coverage Added

### basic.test.ts (6 new tests)
- Querying nested object properties with WHERE clauses
- Selecting nested object properties
- Handling live updates to nested object properties
- Spread operator usage with nested objects
- Filtering based on deeply nested properties
- Computed fields with nested properties

### where.test.ts (6 new tests)
- Filtering by nested object properties and arrays
- Null checks in nested properties
- Combining nested and non-nested conditions
- Live updates to nested properties
- Computed expressions on nested properties
- OR conditions with nested properties

### select.test.ts (7 new tests)
- Selecting nested object properties
- Selecting deeply nested properties
- Spread operator with nested objects
- Combining nested and computed properties
- Nested arrays and objects with aliasing
- Optional chaining with nested properties
- Partial nested object selection

### order-by.test.ts (8 new tests)
- Ordering by nested object properties (asc/desc)
- Ordering by deeply nested properties
- Multiple nested properties ordering
- Ordering by coordinates (nested numeric)
- Handling null/undefined nested properties
- Live updates maintaining order
- String ordering on nested properties

### group-by.test.ts (7 new tests)
- Grouping by nested object properties
- Grouping by deeply nested properties
- Aggregation with nested properties
- Multiple nested properties grouping
- Boolean nested properties grouping
- Conditional nested properties grouping
- Live updates with nested group by

## Enhanced Data Models

Updated all test data models with comprehensive nested structures:
- User profiles with preferences and statistics
- Address information with coordinates
- Contact information with emergency contacts
- Customer tier information with preferences
- Shipping information with tracking details

## Current Test Status

Total: 34 new tests added (1,563+ lines)
Status: Tests currently fail due to incomplete nested object support in query compiler

### Known Issues Found
- "Unknown expression type: undefined" errors for nested property access
- Spread operators not supported on nested objects
- Null coalescing operators not working in nested contexts
- Optional chaining compilation issues

These tests serve as a comprehensive specification for nested object querying functionality that needs to be implemented in the query compiler.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Added comprehensive test coverage for querying nested objects across WHERE, SELECT,
GROUP BY, and ORDER BY operations. Fixed query builder syntax issues by removing
JavaScript expressions, null coalescing operators, and unnecessary optional chaining.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copy link

changeset-bot bot commented Jul 31, 2025

⚠️ No Changeset found

Latest commit: 7f1c98f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

pkg-pr-new bot commented Jul 31, 2025

More templates

@tanstack/db

npm i https://pkg.pr.new/@tanstack/db@352

@tanstack/db-ivm

npm i https://pkg.pr.new/@tanstack/db-ivm@352

@tanstack/electric-db-collection

npm i https://pkg.pr.new/@tanstack/electric-db-collection@352

@tanstack/query-db-collection

npm i https://pkg.pr.new/@tanstack/query-db-collection@352

@tanstack/react-db

npm i https://pkg.pr.new/@tanstack/react-db@352

@tanstack/solid-db

npm i https://pkg.pr.new/@tanstack/solid-db@352

@tanstack/svelte-db

npm i https://pkg.pr.new/@tanstack/svelte-db@352

@tanstack/trailbase-db-collection

npm i https://pkg.pr.new/@tanstack/trailbase-db-collection@352

@tanstack/vue-db

npm i https://pkg.pr.new/@tanstack/vue-db@352

commit: 7f1c98f

Copy link
Contributor

Size Change: 0 B

Total Size: 58.1 kB

ℹ️ View Unchanged
Filename Size
./packages/db/dist/esm/change-events.js 1.13 kB
./packages/db/dist/esm/collection.js 9.8 kB
./packages/db/dist/esm/deferred.js 230 B
./packages/db/dist/esm/errors.js 2.98 kB
./packages/db/dist/esm/index.js 1.51 kB
./packages/db/dist/esm/indexes/auto-index.js 689 B
./packages/db/dist/esm/indexes/base-index.js 605 B
./packages/db/dist/esm/indexes/btree-index.js 1.47 kB
./packages/db/dist/esm/indexes/lazy-index.js 1.25 kB
./packages/db/dist/esm/local-only.js 827 B
./packages/db/dist/esm/local-storage.js 2.03 kB
./packages/db/dist/esm/optimistic-action.js 294 B
./packages/db/dist/esm/proxy.js 4.19 kB
./packages/db/dist/esm/query/builder/functions.js 575 B
./packages/db/dist/esm/query/builder/index.js 3.67 kB
./packages/db/dist/esm/query/builder/ref-proxy.js 890 B
./packages/db/dist/esm/query/compiler/evaluators.js 1.48 kB
./packages/db/dist/esm/query/compiler/expressions.js 631 B
./packages/db/dist/esm/query/compiler/group-by.js 2.03 kB
./packages/db/dist/esm/query/compiler/index.js 1.74 kB
./packages/db/dist/esm/query/compiler/joins.js 1.56 kB
./packages/db/dist/esm/query/compiler/order-by.js 703 B
./packages/db/dist/esm/query/compiler/select.js 655 B
./packages/db/dist/esm/query/ir.js 318 B
./packages/db/dist/esm/query/live-query-collection.js 2.45 kB
./packages/db/dist/esm/query/optimizer.js 2.44 kB
./packages/db/dist/esm/SortedMap.js 1.24 kB
./packages/db/dist/esm/transactions.js 2.28 kB
./packages/db/dist/esm/utils.js 419 B
./packages/db/dist/esm/utils/btree.js 5.93 kB
./packages/db/dist/esm/utils/comparison.js 539 B
./packages/db/dist/esm/utils/index-optimization.js 1.62 kB

compressed-size-action::db-package-size

Copy link
Contributor

Size Change: 0 B

Total Size: 1.05 kB

ℹ️ View Unchanged
Filename Size
./packages/react-db/dist/esm/index.js 152 B
./packages/react-db/dist/esm/useLiveQuery.js 902 B

compressed-size-action::react-db-package-size

@samwillis
Copy link
Collaborator

Replaced by #386

@samwillis samwillis closed this Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants