googleapis / googleapis/google-cloud-java

[java-firestore] Inconsistent behaviour between Java SDK and other SDKs when saving/reading properties that start with "is"

オープン
#13,140 コメント 3 件 リアクション 1 件 担当者 0 名 GitHub で見る
api: firestore type: question
主要言語
Java
スター
2.1k
フォーク
1.2k
平均マージ
1日 23時間
マージ済み PR(30日)
154

説明

#### Environment details

1. OS type and version: MacOS 10.15.5
2. Java version: 8
3. firestore version(s): 6.12.2

#### Problem

Hi, I'm seeing inconsistent behaviour when saving and reading from Firestore using the Java SDK (using Kotlin).
I'm saving a document that looks like this:

```kotlin
data class Whatever(
val result: Result? = null
)

data class Result(
val isSuccess: Boolean = false
)
```

When I save this to Firestore like this:

```kotlin
val whatever = Whatever(result = Result(isSuccess = true))

collection.document(docId).set(whatever).get()
```

then the `isSuccess` property is saved as a `success` field in Firestore (I verified this by checking the field on the Firebase Console).

However, when I want to read this same document from Firestore like this:

```
collection.document(docId).get().get().toObject(Whatever::class.java)
then the isSuccess property is not populated with true and the default false is returned.
```

then the `isSuccess` property is not populated with `true` and the default `false` is returned.

#### Steps to reproduce

1. Create a document from the JS SDK using an object with a property that starts with is (e.g., `{ "isSuccess": true }`).

2. Read the document from the Java SDK and convert it to an object using the `toObject()` method.

When I try to read the object on step 2 the app fails to convert the document to a Java object because the JS SDK saved the name of the field as `isSuccess` and there is no way for the Java SDK to convert that apparently. I tried naming the property in the Kotlin class both `isSuccess` and `success` and they both failed to get the proper value from the underlying document field.

These are the results I get when I print the document field vs the Kotlin object:

```
// Printing the document
{isSuccess=true}

// Printing the Kotlin class
TestClass(success=null)
TestClass(isSuccess=null)
```

#### Other details

This was first reported here: https://github.com/firebase/firebase-admin-java/issues/472 and I moved it to this repository as indicated by someone in the Google team.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。