Azure SDK for Java 0.4.6 long値のfilter BUG
Azure SDK for Java 0.4.6 では、Azure TableのプロパティをLong値で$filterした場合に、URL展開で数字の末尾の’L’が付かないという不備があります。その結果、MAX_INTより大きな値を条件にするとサーバーの処理がエラーになってしまいます。
この問題に気が付いたのは、0.4.4で、0.4.6でもまだ修正されていません。
修正して、Pull Requestを投げています。(2013/10/13)
#413 Long value filtering has error when value more than MAX_INT

修正内容
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -380,10 +380,12 @@ public static String generateFilterCondition(String propertyName, String operati | |
public static String generateFilterCondition(String propertyName, String operation, String value, EdmType edmType) { | |
String valueOperand = null; | |
- if (edmType == EdmType.BOOLEAN || edmType == EdmType.DOUBLE || edmType == EdmType.INT32 | |
- || edmType == EdmType.INT64) { | |
+ if (edmType == EdmType.BOOLEAN || edmType == EdmType.DOUBLE || edmType == EdmType.INT32) { | |
valueOperand = value; | |
} | |
+ else if (edmType == EdmType.INT64) { | |
+ valueOperand = String.format("%sL", value); | |
+ } | |
else if (edmType == EdmType.DATE_TIME) { | |
valueOperand = String.format("datetime'%s'", value); | |
} |
edmType が、EdmType.INT64の場合に、値のpostfixに’L’を付けるように変更しました。
元の仕様
どこからこの’L’が出てきたかという話をチョットします。Azure Table REST APIは、OData の仕様に準拠しているのでリテラルの書式などはそれを見ると書いてあるはずです。ODataのPrimitive Data Typesでは、64bit整数は下記のように定義されていました。’L’ですね。
Primitive Types Literal Form Example | |||
---|---|---|---|
Edm.Int64 Represents a signed 64-bit | integer value | [-] [0-9]+L | Example 1: 64L Example 2: -64L |
odata.org 6. Primitive Data Typesより
念のため他のデータ型の実装も確認すると、Azure Tableでサポートされているデータ型でリテラル表記に癖があるEdm.Guid, Edm.DateTimeのあたりですは問題なさそうです。