fsprojects / DynamoDb.SQL

SQL-like external DSL for querying and scanning Amazon DynamoDB
http://fsprojects.github.io/DynamoDb.SQL
MIT License
54 stars 9 forks source link

Long numbers are not working #28

Closed zairnamlas closed 9 years ago

zairnamlas commented 9 years ago

Hi there again, I have just noticed that the long numbers are not working in sql. Consider the following two examples

// Not working even the data is present SELECT * FROM pd_cs_chatroomuser WHERE UserId = 10205471065416056 WITH(Index(UserIdIndex, false), NoConsistentRead)

// Working SELECT * FROM pd_cs_chatroomuser WHERE UserId = 10205471065 WITH(Index(UserIdIndex, false), NoConsistentRead)

theburningmonk commented 9 years ago

Do you get any exceptions? or just not get any results back when you run the query?

On Fri, Aug 28, 2015 at 1:00 PM, zairnamlas notifications@github.com wrote:

Hi there again, I have just noticed that the long numbers are not working in sql. Consider the following two examples

// Not working even the data is present SELECT * FROM pd_cs_chatroomuser WHERE UserId = 10205471065416056 WITH(Index(UserIdIndex, false), NoConsistentRead)

// Working SELECT * FROM pd_cs_chatroomuser WHERE UserId = 10205471065 WITH(Index(UserIdIndex, false), NoConsistentRead)

— Reply to this email directly or view it on GitHub https://github.com/fsprojects/DynamoDb.SQL/issues/28.

theburningmonk commented 9 years ago

I think what's happening is that, the integer value gets converted to int32 which overflows in this case so by the time it's converted to a request to DynamoDB it's sending through a negative number instead.

On Fri, Aug 28, 2015 at 1:23 PM, Yan Cui theburningmonk@gmail.com wrote:

Do you get any exceptions? or just not get any results back when you run the query?

On Fri, Aug 28, 2015 at 1:00 PM, zairnamlas notifications@github.com wrote:

Hi there again, I have just noticed that the long numbers are not working in sql. Consider the following two examples

// Not working even the data is present SELECT * FROM pd_cs_chatroomuser WHERE UserId = 10205471065416056 WITH(Index(UserIdIndex, false), NoConsistentRead)

// Working SELECT * FROM pd_cs_chatroomuser WHERE UserId = 10205471065 WITH(Index(UserIdIndex, false), NoConsistentRead)

— Reply to this email directly or view it on GitHub https://github.com/fsprojects/DynamoDb.SQL/issues/28.

zairnamlas commented 9 years ago

Yeah, looks like that is the case. No exception and no results coming back. Is it a quick fix?

theburningmonk commented 9 years ago

Yup, should be straight forward, will fix it tonight

On Fri, Aug 28, 2015 at 3:38 PM, zairnamlas notifications@github.com wrote:

Yeah, looks like that is the case. No exception and no results coming back. Is it a quick fix?

— Reply to this email directly or view it on GitHub https://github.com/fsprojects/DynamoDb.SQL/issues/28#issuecomment-135792129 .

zairnamlas commented 9 years ago

Thanks, let me know the changes as I'm using inline project of yours with latest AWS SDK. I can apply those changes in my version of the code.

theburningmonk commented 9 years ago

@zairnamlas took a little longer than I had before a bank holiday weekend trip but turns out the parser was fine, it was a problem when the float was translated to a DynamoDB request because the default behaviour of ToString is to use scientific notation on large floating point numbers.

In the end it was a very simple fix though, which was to use the r formatting string https://msdn.microsoft.com/en-us/library/dwhawy9k.aspx

theburningmonk commented 9 years ago

I've published a hotfix version 2.1.1 with this fix

zairnamlas commented 9 years ago

Thanks Yan. I'm on holidays and I'll check that next week. Could you please share the changed loc? On 1 Sep 2015 6:18 pm, "Yan Cui" notifications@github.com wrote:

@zairnamlas https://github.com/zairnamlas took a little longer than I had before a bank holiday weekend trip but turns out the parser was fine, it was a problem when the float was translated to a DynamoDB request because the default behaviour of ToString is to use scientific notation on large floating point numbers.

In the end it was a very simple fix though, which was to use the r formatting string https://msdn.microsoft.com/en-us/library/dwhawy9k.aspx

— Reply to this email directly or view it on GitHub https://github.com/fsprojects/DynamoDb.SQL/issues/28#issuecomment-136801172 .

theburningmonk commented 9 years ago

Here you go : https://github.com/fsprojects/DynamoDb.SQL/commit/21b5fa49d560b25181ff4f81598defab0bbc3625