Browse Source

All integer types should accept null in json. (#3869)

Paul Yang 7 years ago
parent
commit
188f18044f
2 changed files with 22 additions and 5 deletions
  1. 16 0
      conformance/conformance_test.cc
  2. 6 5
      php/src/Google/Protobuf/Internal/Message.php

+ 16 - 0
conformance/conformance_test.cc

@@ -1842,6 +1842,14 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
         "optionalInt64": null,
         "optionalInt64": null,
         "optionalUint32": null,
         "optionalUint32": null,
         "optionalUint64": null,
         "optionalUint64": null,
+        "optionalSint32": null,
+        "optionalSint64": null,
+        "optionalFixed32": null,
+        "optionalFixed64": null,
+        "optionalSfixed32": null,
+        "optionalSfixed64": null,
+        "optionalFloat": null,
+        "optionalDouble": null,
         "optionalBool": null,
         "optionalBool": null,
         "optionalString": null,
         "optionalString": null,
         "optionalBytes": null,
         "optionalBytes": null,
@@ -1851,6 +1859,14 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
         "repeatedInt64": null,
         "repeatedInt64": null,
         "repeatedUint32": null,
         "repeatedUint32": null,
         "repeatedUint64": null,
         "repeatedUint64": null,
+        "repeatedSint32": null,
+        "repeatedSint64": null,
+        "repeatedFixed32": null,
+        "repeatedFixed64": null,
+        "repeatedSfixed32": null,
+        "repeatedSfixed64": null,
+        "repeatedFloat": null,
+        "repeatedDouble": null,
         "repeatedBool": null,
         "repeatedBool": null,
         "repeatedString": null,
         "repeatedString": null,
         "repeatedBytes": null,
         "repeatedBytes": null,

+ 6 - 5
php/src/Google/Protobuf/Internal/Message.php

@@ -833,6 +833,8 @@ class Message
                 }
                 }
                 return $value;
                 return $value;
             case GPBType::INT32:
             case GPBType::INT32:
+            case GPBType::SINT32:
+            case GPBType::SFIXED32:
                 if (is_null($value)) {
                 if (is_null($value)) {
                     return $this->defaultValue($field);
                     return $this->defaultValue($field);
                 }
                 }
@@ -850,6 +852,7 @@ class Message
                 }
                 }
                 return $value;
                 return $value;
             case GPBType::UINT32:
             case GPBType::UINT32:
+            case GPBType::FIXED32:
                 if (is_null($value)) {
                 if (is_null($value)) {
                     return $this->defaultValue($field);
                     return $this->defaultValue($field);
                 }
                 }
@@ -863,6 +866,8 @@ class Message
                 }
                 }
                 return $value;
                 return $value;
             case GPBType::INT64:
             case GPBType::INT64:
+            case GPBType::SINT64:
+            case GPBType::SFIXED64:
                 if (is_null($value)) {
                 if (is_null($value)) {
                     return $this->defaultValue($field);
                     return $this->defaultValue($field);
                 }
                 }
@@ -880,6 +885,7 @@ class Message
                 }
                 }
                 return $value;
                 return $value;
             case GPBType::UINT64:
             case GPBType::UINT64:
+            case GPBType::FIXED64:
                 if (is_null($value)) {
                 if (is_null($value)) {
                     return $this->defaultValue($field);
                     return $this->defaultValue($field);
                 }
                 }
@@ -895,11 +901,6 @@ class Message
                     $value = bcsub($value, "18446744073709551616");
                     $value = bcsub($value, "18446744073709551616");
                 }
                 }
                 return $value;
                 return $value;
-            case GPBType::FIXED64:
-                if (is_null($value)) {
-                    return $this->defaultValue($field);
-                }
-                return $value;
             default:
             default:
                 return $value;
                 return $value;
         }
         }