Commit 7714afc
Merge #652
652: Support structs as search result r=curquiza a=nikcio
# Pull Request
## What does this PR do?
This PR removes the class constraint on the `ISearchableJsonConverter` to allow using structs as the search result model (`T`).
The class constraint `where T : class` isn't present on anywhere else and therefore only breaks at runtime and as the JSON serializer can handle structs just fine this restriction isn't needed.
I've added some basic tests showing that the JSON converter works with structs.
## Current problem
To explain the current problem. When using a struct as the response model you'll get the following error when running a search query:
```stacktrace
System.ArgumentException : GenericArguments[0], 'Meilisearch.Tests.MovieStruct', on 'Meilisearch.ISearchableJsonConverter`1[T]' violates the constraint of type 'T'.
---- System.TypeLoadException : GenericArguments[0], 'Meilisearch.Tests.MovieStruct', on 'Meilisearch.ISearchableJsonConverter`1[T]' violates the constraint of type parameter 'T'.
```
Just removing the constraint on the converter removes the issue.
## PR checklist
Please check if your PR fulfills the following requirements:
- [X] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [X] Have you read the contributing guidelines?
- [X] Have you made sure that the title is accurate and descriptive of the changes?
Thank you so much for contributing to Meilisearch!
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
- **New Features**
- Added support for searching and handling value types (structs) in search functionality.
- **Tests**
- Introduced new tests to verify search operations using struct-based movie data, ensuring correct results and pagination with value types.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: Nikolaj Brask-Nielsen <[email protected]>File tree
3 files changed
+31
-1
lines changed- src/Meilisearch
- tests/Meilisearch.Tests
3 files changed
+31
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
15 | 23 | | |
16 | 24 | | |
17 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
48 | 70 | | |
49 | 71 | | |
50 | 72 | | |
| |||
0 commit comments