-
Notifications
You must be signed in to change notification settings - Fork 192
Enum parameter to repository method not handled. #1837
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
Comments
@Pharisaeus I can't reproduce this. At line 508, the parameter is converted to a json type. Can you provide the definition of your Status? I tried:
|
Please reopen if you have additional information. |
Just use the converted value as-is (in case of boolean or Number) enum value. Closes #1837.
Just use the converted value as-is (in case of boolean or Number) enum value. Closes #1837.
Just use the converted value as-is (in case of boolean or Number) enum value. Closes #1837.
Just use the converted value as-is (in case of boolean or Number) enum value. Closes #1837.
@mikereiche see: https://github.com/Pharisaeus/couchbase-enum it's as much bare-bones as I could make it. There are 2 tests at https://github.com/Pharisaeus/couchbase-enum/blob/master/src/test/java/org/example/test/SomeTest.java#L20 and both crash with the enum issue. The tests are running via testcontainers so you should be able to simply clone the repo and run tests as long as you have docker daemon running. |
The issue is that the 'couchbaseConverter' does not have the. EnumToObject converter factory, so it just passes through the enum instead of converting it to a json-friendly object.
The EnumToObject converter is added in AbstractCouchbaseConfiguration.customConversions() and is usually obtained with a "config" class that extends it. But you don't have such a class. I need to figure out where the configuration comes from in your test.
|
@EnableCouchbaseRepositories(basePackageClasses = {MyCouchbaseRepository.class}) and nothing more, so the configuration has to be some default/coming from springboot |
Yes - I see where it comes from. I have to move the addition of converters into CouchbaseCustomConversions constructor. Edit: This won't work -> For a work-around you can add a class that extends AbstractCouchbaseConfiguration. |
You'll need back-ticks around
And make your BeansConfiguration.java like this:
|
I do plan on fixing this, but that should get you going for now. |
This is a little tidier
|
Uh oh!
There was an error while loading. Please reload this page.
TL;DR the issue is because the couchbaseCustomConversions created in CouchbaseDataConfiguration does not have the Enum converters.
From @Pharisaeus comment on #1069 .
@mikereiche I hit the same issue when using a custom @query and named @param as in:
@query("UPDATE #{#n1ql.collection} SET status = $newStatus")
Result changeStatus(@param("newStatus") Status newStatus);
gives:
com.couchbase.client.core.error.InvalidArgumentException: Unsupported type for JSON value: class a.b.c.Status
at com.couchbase.client.core.error.InvalidArgumentException.fromMessage(InvalidArgumentException.java:28) ~[core-io-2.4.10.jar:na]
at com.couchbase.client.java.json.JsonValue.coerce(JsonValue.java:94) ~[java-client-3.4.10.jar:na]
at com.couchbase.client.java.json.JsonObject.put(JsonObject.java:222) ~[java-client-3.4.10.jar:na]
at org.springframework.data.couchbase.repository.query.StringBasedN1qlQueryParser.putNamedValue(StringBasedN1qlQueryParser.java:575) ~[spring-data-couchbase-5.1.4.jar:5.1.4]
at org.springframework.data.couchbase.repository.query.StringBasedN1qlQueryParser.getNamedPlaceholderValues(StringBasedN1qlQueryParser.java:517) ~[spring-data-couchbase-5.1.4.jar:5.1.4]
at org.springframework.data.couchbase.repository.query.StringBasedN1qlQueryParser.getPlaceholderValues(StringBasedN1qlQueryParser.java:543) ~[spring-data-couchbase-5.1.4.jar:5.1.4]
at org.springframework.data.couchbase.core.query.StringQuery.toN1qlSelectString(StringQuery.java:83) ~[spring-data-couchbase-5.1.4.jar:5.1.4]
at org.springframework.data.couchbase.core.ReactiveFindByQueryOperationSupport$ReactiveFindByQuerySupport.assembleEntityQuery(ReactiveFindByQueryOperationSupport.java:281) ~[spring-data-couchbase-5.1.4.jar:5.1.4]
at org.springframework.data.couchbase.core.ReactiveFindByQueryOperationSupport$ReactiveFindByQuerySupport.all(ReactiveFindByQueryOperationSupport.java:182) ~[spring-data-couchbase-5.1.4.jar:5.1.4]
at org.springframework.data.couchbase.core.ExecutableFindByQueryOperationSupport$ExecutableFindByQuerySupport.all(ExecutableFindByQueryOperationSupport.java:95) ~[spring-data-couchbase-5.1.4.jar:5.1.4]
at org.springframework.data.couchbase.repository.query.AbstractCouchbaseQuery.lambda$getExecutionToWrap$1(AbstractCouchbaseQuery.java:124) ~[spring-data-couchbase-5.1.4.jar:5.1.4]
at org.springframework.data.couchbase.repository.query.CouchbaseQueryExecution$ResultProcessingExecution.execute(CouchbaseQueryExecution.java:84) ~[spring-data-couchbase-5.1.4.jar:5.1.4]
at org.springframework.data.couchbase.repository.query.AbstractCouchbaseQuery.doExecute(AbstractCouchbaseQuery.java:93) ~[spring-data-couchbase-5.1.4.jar:5.1.4]
at org.springframework.data.couchbase.repository.query.AbstractCouchbaseQueryBase.execute(AbstractCouchbaseQueryBase.java:132) ~[spring-data-couchbase-5.1.4.jar:5.1.4]
at org.springframework.data.couchbase.repository.query.AbstractCouchbaseQueryBase.execute(AbstractCouchbaseQueryBase.java:113) ~[spring-data-couchbase-5.1.4.jar:5.1.4]
I'm guessing it goes through a different code path in this scenario and the previous fix is not enough.
The text was updated successfully, but these errors were encountered: