Skip to content
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

Merged
merged 4 commits into from
May 31, 2024
Merged

Add support for update by id #43

merged 4 commits into from
May 31, 2024

Conversation

t3t5u
Copy link
Contributor

@t3t5u t3t5u commented Apr 22, 2024

Changes

  • Refactoring as preparation

  • Add support for update by id

    • Added IdOrUpdateKey class and Id class
    • Added Skip enum for the skip policy if the record corresponding to the id or update key does not exist
      • auto: Default policy. Same as previous behavior if insert or update mode.
      • never: Never skip the record even if corresponds to the id or update key does not exist. Same as previous behavior if upsert mode.
      • always: Always skip the record if corresponds to the id or update key does not exist. update mode and upsert mode will the same behavior (only updated, never inserted).

@t3t5u t3t5u requested a review from d-hrs April 22, 2024 13:40
Copy link
Contributor

@d-hrs d-hrs left a 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) {
Copy link
Contributor

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?
image
https://cybozu.dev/ja/kintone/docs/overview/field-types/#field-type-update

Copy link
Contributor Author

@t3t5u t3t5u May 10, 2024

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) {}
Copy link
Contributor

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?

Copy link
Contributor Author

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`)
Copy link
Contributor

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.

@d-hrs d-hrs merged commit 473d439 into master May 31, 2024
1 check passed
@d-hrs d-hrs deleted the update_by_id branch May 31, 2024 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants