Skip to content

feat(mapping): TupleMapper utility and CRUD metadata support#62

Merged
ArtDu merged 2 commits intomasterfrom
crud_metadata_passing
Mar 31, 2026
Merged

feat(mapping): TupleMapper utility and CRUD metadata support#62
ArtDu merged 2 commits intomasterfrom
crud_metadata_passing

Conversation

@ArtDu
Copy link
Copy Markdown
Contributor

@ArtDu ArtDu commented Mar 30, 2026

Summary

This PR adds syntactic sugar for key-based tuple-to-POJO mapping by:

  1. TupleMapper utility class - Provides static methods for easy mapping:

    • toMap(tuple, format) - Convert tuple to Map using field names
    • mapToPojo(tuple, format, targetClass) - Map tuple to POJO
    • mapToPojo(tuple, targetClass) - Map tuple with embedded format to POJO
    • mapToPojoList(tuples, format, targetClass) - Map list of tuples
  2. CRUD metadata propagation - Updated CRUD operations to pass format metadata:

    • select, insert, get now propagate format from CrudResponse.metadata
    • Added getFormats(response, crudMetadata) overload with fallback logic
  3. Integration tests - Added tests for:

    • testSelectWithFormatFromCrudMetadata
    • testInsertAndGetWithFormatFromCrudMetadata
    • testGetWithFieldsFilterAndFormat (using GetOptions.withFields())

Test plan

  • TupleMapper unit tests pass
  • CRUD integration tests with format metadata pass
  • Box client tests updated to use TupleMapper

🤖 Generated with Claude Code

@ArtDu ArtDu requested a review from nickkkccc March 30, 2026 15:28
@ArtDu ArtDu self-assigned this Mar 30, 2026
@ArtDu ArtDu force-pushed the crud_metadata_passing branch 2 times, most recently from a8b108a to 3af6a03 Compare March 31, 2026 08:12
@ArtDu ArtDu requested review from Alex-pvl and removed request for nickkkccc March 31, 2026 08:24
- Add TupleMapper utility class for easy tuple-to-POJO mapping using field format
- Update CRUD operations (select, insert, get) to propagate format metadata from CrudResponse
- Add getFormats() overload with CRUD metadata fallback
- Add integration tests for select, insert, get with format metadata
- Add test for fields filtering with GetOptions
- Update TarantoolBoxClientTest to use TupleMapper instead of manual IntStream mapping

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ArtDu ArtDu force-pushed the crud_metadata_passing branch from 3af6a03 to 03fb07c Compare March 31, 2026 08:34
if (!formats.isEmpty()) {
for (Tuple<?> tuple : resp.get()) {
Integer formatId = tuple.getFormatId();
List<Field> format = formats.get(formatId);
Copy link
Copy Markdown
Contributor

@Alex-pvl Alex-pvl Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут и в других методах не нужен fallback?

if (formatId == null && formats.size() == 1) {
    format = formats.values().stream().findFirst().get();
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хм, возможно стоит добавить

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ага, вроде везде добавил

Add fallback logic to injectFormatIntoTuples, getTuplesWithInjectedFormat,
and getBatchTuplesWithInjectedFormat methods. When formatId is null and
only one format is available, use that format instead of null.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ArtDu ArtDu force-pushed the crud_metadata_passing branch from bdfcf7c to 7bb23bc Compare March 31, 2026 11:42
@ArtDu ArtDu requested a review from Alex-pvl March 31, 2026 11:42
@ArtDu ArtDu merged commit c57f6a2 into master Mar 31, 2026
6 checks passed
@ArtDu ArtDu deleted the crud_metadata_passing branch March 31, 2026 13:22
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