-
Notifications
You must be signed in to change notification settings - Fork 11
FlatPostgresCollection Create Doc Impl #266
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
Conversation
| private final DataType canonicalType; | ||
| @Getter private final PostgresDataType postgresType; | ||
| private final boolean nullable; | ||
| private final boolean array; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: isArray since array is a slightly confusing without looking at this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #266 +/- ##
============================================
+ Coverage 80.51% 80.52% +0.01%
- Complexity 1385 1392 +7
============================================
Files 234 237 +3
Lines 6194 6379 +185
Branches 554 584 +30
============================================
+ Hits 4987 5137 +150
- Misses 831 854 +23
- Partials 376 388 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@suresh-prakash Can you take a look at the following:
|
Best-effort makes sense. But, most of the times such log messages are ignored though we may be setting them in the CreateResult. Rather I'd prefer we fail it so that the client can take a necessary action (they may choose to retry with the column ignored, if we throw a custom exception with meaningful info.).
This is fine, I guess, because that's the way the Mongo impl. works today. If I give an invalid selection, it doesn't throw. Rather avoids it in the JSON, which in turn results in a
100% makes sense. 🙂 |
Why retry on DATATYPE_MISMATCH? This can be a bad situation to be in. If client data type mismatches the db column type then retries won't help. DB Column data type change should never be the case in postgres. |
Well theoretically speaking, the rationale behind the retry is: Maybe the data type changed and the schema is stale, so refresh it and try again. |
|
@suresh-prakash I am not throwing an exception because it won't throw an exception in Mongo as well. So to keep the interface behaviour consistent, shall we stick to it? |
True. But silently neglecting seems dangerous. Most clients would be unware of it. While it may give the immediate compatibility, it could create far more issues later. Since this write path anyways require code changes in the clients, I still think it would be better to let the clients handle it rather than the library doing it behind the scenes. @kotharironak Thoughts here? |
|
@suresh-prakash How about a config to control this (in |
|
@suresh-prakash Have add a
Wdyt? |
This is a nice middle-ground. 🙂 Just a small suggestion though. Instead of a boolean, can we make it as an enum (say, |
| this.succeed = succeed; | ||
| private final CreateStatus status; | ||
| private final boolean onRetry; | ||
| private final List<String> skippedFields; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Can be a set.
| * a field doesn't match the schema. The write operation will fail. | ||
| */ | ||
| THROW, | ||
| IGNORE_DOCUMENT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Can also come in later when the need arises.
| * | ||
| * <p>This enum defines how the system should behave when encountering fields that either don't | ||
| * exist in the schema or have incompatible types. | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also mention what is the default (in case not specified)? Or, is it a mandatory field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default can go in @implSpec annotated documentation comment so that every implementor would agree to this specification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better would be to expose a static method called MissingColumnStrategy.default() so that it is self-documented (and gives an opportunity to later change the default across all implementations in a single go).
Description
This PR implements
Collection#create(Key key, Document document)forFlatPostgresCollection.Testing
Checklist: