-
-
Notifications
You must be signed in to change notification settings - Fork 260
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
SqlUpdate.setParameter
does not support ArrayNode
#3297
Comments
Also question: @DbJsonB
JsonNode conditions;
public ObjectNode getConditions() {
return (ObjectNode) conditions;
}
...
Quest quest = finder.query().select("conditions").setId(id).findOne();
quest.getConditions().put("timeUntil", timeUntil);
quest.update(); Will be |
This is a good use case for stateless update. var bean = new Quest();
bean.setId(1);
bean.setProgress(...);
bean.update(); // stateless update |
@rob-bygrave thanks, I already changed to "setProgress" |
Like: String rawJson = ...;// convert progress to String JSON
PGobject pgo = new PGobject();
pgo.setType("jsonb");
pgo.setValue(rawJson);
DB.sqlUpdate(sql).setParameter(pgo).execute(); |
Thanks, but question was about POJO modification of |
Also, I think that issue is still actual, because ebean/ebean-core-type/src/main/java/io/ebean/core/type/PostgresHelper.java Lines 30 to 34 in 8ed3b76
So why is it not used for ArrayNode ?
|
@rob-bygrave your solution causes exception:
Ebean version 13.23.0 |
With: update quest set progress = to_jsob(?) where id = 1;
``
or using cast:
```sql
update quest set progress = ?::jsonb where id = 1; then the bind value should be a String, so ArrayNode arrayNode = ...; //[1, 1, 1] // if call toString() DB.sqlUpdate(sql).setParameter(arrayNodeAsJsonString).execute();
That depends on the MutationDetection mode. Did you debug that and see that? |
I tried sb.append("progress = '").append(arrayNode.toString()).append("'::jsonb"); Note about single quotes around json. What about mutation, I switched to raw SQL: sb.append("conditions['timeUntil'] = to_jsonb(").append(node.longValue()).append(')'); |
Expected behavior
Model field:
Here is example raw SQL:
Sets
progress
to new JSONActual behavior
Maybe I does not know right syntax for set json array, which Ebean can understand?
I need to replace the whole column value
Please help
The text was updated successfully, but these errors were encountered: