Add MongoPostgresWriteConsistencyTest#280
Conversation
| } | ||
| break; | ||
|
|
||
| case "float4": |
There was a problem hiding this comment.
Currently for PG, this returns the value as a string. This is not the behaviour in Mongo, so added a fix here. Validated this in the compatibility test.
|
|
||
| @Override | ||
| public String parseNonJsonbField(final UpdateParserInput input) { | ||
| if (!input.isArray()) { |
There was a problem hiding this comment.
Added this check to make this compatible with Mongo.
…setSubDocOp # Conflicts: # document-store/src/integrationTest/java/org/hypertrace/core/documentstore/MongoPostgresWriteConsistencyTest.java # document-store/src/main/java/org/hypertrace/core/documentstore/postgres/update/parser/PostgresSetValueParser.java
| if (isTopLevel && colMeta.isArray() && paramValue != null) { | ||
| Object[] arrayValues = (Object[]) paramValue; | ||
| Array sqlArray = | ||
| connection.createArrayOf(colMeta.getPostgresType().getSqlType(), arrayValues); |
There was a problem hiding this comment.
JDBC can't bind Object[] directly to array columns like TEXT[]. It requires java.sql.Array. So convert the Java array to JDBC Array.
|
@suddendust This is such a big chunk of change in tests, how are you ensuring that you are not changing tests behaviour? |
|
@puneet-traceable So this PR contains changes in two tests:
So you'll find the I now do an At no place any Mongo write tests have been touched. |
| input.getParamsBuilder().addObjectParam(values); | ||
| } else { | ||
| // For scalar columns, use standard value parser (ignore returned JSONB expression) | ||
| input |
There was a problem hiding this comment.
Bit confused here. If the result/return value is ignored, then, why call this in the first place?
There was a problem hiding this comment.
Yes, this is fixed.
This PR adds exhaustive
MongoPostgresWriteConsistencyTestto ensure functional parity b/w Mongo and Postgres write implementations. In addition to this, it also:PostgresResultIteratorWithBasicTypesin whichfloat4/realvalues were cast to strings. So say we have a fieldratingswith is arealfield - It would appear as"4.3"inDocumentinstead of4.3(Mongo behaves correctly so this fix is added for functional compatibility).SETupdate parsers to parse them as a single value.Collection#upsertfor PG. Till now, it returnstrueif a new doc is created,falseif it's updated. This is not inline with the contract or Mongo's behaviour - So now, it returnstrueif it succeeds.SETon entire JSONB columns properly.CommonUpdateValidatorfor flat PG collections.