-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add support for update by id #43
Conversation
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.
please check my comments.
@@ -284,4 +330,8 @@ private boolean isIgnoreNull(Column column) { | |||
private boolean isPreferNull(Column column) { | |||
return preferNulls && reader.isNull(column); | |||
} | |||
|
|||
private static boolean isBuiltin(String fieldCode) { |
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.
This is for to skip columns that can neither insert nor update?
Why is the レコード番号
not included?
https://cybozu.dev/ja/kintone/docs/overview/field-types/#field-type-update
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.
This is for to skip columns that can neither insert nor update?
That's right.
Why is the レコード番号 not included?
The field codes for Created by
, Created datetime
, Updated by
, Updated datetime
and Record number
can be changed, but the field codes $id
for Record ID
and $revision
for Revision
can not be changed.
https://kintone.dev/en/docs/kintone/overview/field-types/
https://kintone.dev/en/docs/kintone/rest-api/apps/update-form-fields/#request-parameters
https://cybozu.dev/ja/kintone/docs/rest-api/apps/form/update-form-fields/#request
Therefore, for Record number
, etc., unable to determine whether a field is a builtin field by the field codes only (also need to refer to the field types, but these field types are not supported).
In fact, Record ID
and Revision
are like pseudo fields, so these fields are handled specially in the kintone client.
https://github.com/kintone/kintone-java-client/blob/master/src/main/java/com/kintone/client/RecordDeserializer.java#L70-L79
https://github.com/kintone/kintone-java-client/blob/master/src/main/java/com/kintone/client/RecordSerializer.java#L49-L51
@@ -189,15 +144,14 @@ public void onRetry( | |||
} | |||
|
|||
@Override | |||
public void onGiveup(Exception firstException, Exception lastException) | |||
throws RetryGiveupException {} | |||
public void onGiveup(Exception firstException, Exception lastException) {} |
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.
Why did you remove throwing exception?
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.
Because IntelliJ IDEA gives the following warning.
Exception 'org.embulk.spi.util.RetryExecutor.RetryGiveupException' is never thrown in the method
README.md
Outdated
@@ -26,6 +26,7 @@ kintone output plugin for Embulk stores app records from kintone. | |||
- **max_sort_memory**: Maximum memory usage for sorting input records (bytes in long, default is the estimated available memory, which is the approximate value of the JVM's current free memory) | |||
- **prefer_nulls**: Whether to set fields to null instead of default value of type when column is null (boolean, default is `false`) | |||
- **ignore_nulls**: Whether to completely ignore fields when column is null (boolean, default is `false`) | |||
- **skip_if_non_existing_id_or_update_key**: Skip policy if id or update key of record does not exist (string `auto`, `never` or `always`, default is `auto`) |
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.
I think it would be helpful to have a bit more explanation about the auto
.
Changes
Refactoring as preparation
KintoneClient
classMockClient
class for testAdd support for update by id
IdOrUpdateKey
class andId
classSkip
enum for the skip policy if the record corresponding to the id or update key does not existauto
: Default policy. Same as previous behavior ifinsert
orupdate
mode.never
: Never skip the record even if corresponds to the id or update key does not exist. Same as previous behavior ifupsert
mode.always
: Always skip the record if corresponds to the id or update key does not exist.update
mode andupsert
mode will the same behavior (only updated, never inserted).