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

wp8 converts to negative too big integers #195

Closed
jlegido opened this issue Mar 3, 2015 · 6 comments
Closed

wp8 converts to negative too big integers #195

jlegido opened this issue Mar 3, 2015 · 6 comments

Comments

@jlegido
Copy link

jlegido commented Mar 3, 2015

Issue
When I do a select of a too big integer value, wp8 converts it to a negative value, in this example "-1754182378_"

Sqlite table
CREATE TABLE INFO(last_sync_date INTEGER);
INSERT INTO "INFO" VALUES(1424174959894);

Software versions:
Cordova -> 3.6.3-0.2.13
wp8 -> Windows Phone 8.1 update
Sqlite plugin -> 1.0.4

Snippet of code:

// Gets Unix timestamp (in miliseconds) of last DB update in remote server
Location.prototype.getLastSyncDate = function(querySuccess, queryError) {
    this.db.transaction(queryDB, queryError, this.successDB("getLastSyncDate"));

    function queryDB(tx) {
        var sqlQuery = 'select * from INFO';
        tx.executeSql(sqlQuery, [], querySuccess, this.errorDB);
    }
}

Additional info
-Same code with same plugin works ok in Android and IOS
-If I trim the number to 9 digits (instead of 13) it works as expected. I didn't tried to find the maximum supported number.

PD: many thanks for your great work
@brodycj
Copy link
Contributor

brodycj commented Mar 4, 2015

Thanks for reporting this!

brodycj pushed a commit that referenced this issue Mar 6, 2015
…199)

Update test of big integer value bindings according to behavior of Web SQL vs. this plugin (ref: #195)
brodycj pushed a commit that referenced this issue Mar 10, 2015
Fixes:
- #193: workaround for Android db locking/closing issue
- #144: convert array parameters to string to match Web SQL
- #199: fix double-precision REAL values in result for iOS version
- #150/#153: close Android db before removing from map
- Fix truncation in iOS query result in case of UNICODE NULL (\0 or \u0000) (ref: PR #170)
- Some fixes for error handling to be consistent with Web SQL (ref: PR #170)

Testing ONLY:
- #147: testing with UNICODE line separator
- #195: Reproduce issue with double-precision REAL number on WP(8) ONLY
brodycj pushed a commit that referenced this issue Mar 10, 2015
Fixes:
- #193: workaround for Android db locking/closing issue
- #144: convert array parameters to string to match Web SQL
- #199: fix double-precision REAL values in result for iOS version
- #150/#153: close Android db before removing from map
- Fix truncation in iOS query result in case of UNICODE NULL (\0 or \u0000) (ref: PR #170)
- Some fixes for error handling to be consistent with Web SQL (ref: PR #170)

Testing ONLY:
- #147: testing with UNICODE line separator
- #195: Reproduce issue with double-precision REAL number on WP(8) ONLY
@martatw
Copy link

martatw commented Dec 14, 2015

Hi,

I have the same Issue, Do you know some workariund to fix it? When It will be fixed?

@jlegido
Copy link
Author

jlegido commented Dec 14, 2015

Hi there.

At the moment I have no solution, I just convert the numbers at app level.

Cheers.

Javier

On 14 December 2015 at 09:36, martatw notifications@github.com wrote:

Hi,

I have the same Issue, Do you know some workariund to fix it? When It will
be fixed?


Reply to this email directly or view it on GitHub
#195 (comment)
.

@martatw
Copy link

martatw commented Dec 15, 2015

Hi,

After deeper investigation, I have found out that plugin correnctly is adding int64 to DB. However the bug occured after getting data from BD. There is a code in wp\SQLite.cs : line: 1958; function ExecuteDeferredQuery():

                    switch (colType)
                    {
                        case SQLite3.ColType.Text:
                            targetType = typeof(string);
                            break;
                        case SQLite3.ColType.Integer:
                            targetType = typeof(int);
                            break;
                        case SQLite3.ColType.Float:
                            targetType = typeof(double);
                            break;
                        default:
                            targetType = typeof(object);
                            break;
                    }

Each Integer data is converted to int32. After changing to Int64 it works fine. Do You think that this change might have some negative inpact?

(I am speaking about windows Phone 8.1 app)

BR
Marta

@brodycj
Copy link
Contributor

brodycj commented Dec 23, 2015

There is a code in wp\SQLite.cs : line: 1958; function ExecuteDeferredQuery():

                switch (colType)
                {
                    case SQLite3.ColType.Text:
                        targetType = typeof(string);
                        break;
                    case SQLite3.ColType.Integer:
                        targetType = typeof(int);
                        break;
                    case SQLite3.ColType.Float:
                        targetType = typeof(double);
                        break;
                    default:
                        targetType = typeof(object);
                        break;
                }

Each Integer data is converted to int32. After changing to Int64 it works fine.

Thanks @martatw!

A pull request for this would be really helpful (I cannot try this change until I return from vacation in January).

@brodycj
Copy link
Contributor

brodycj commented Feb 9, 2016

When I tried typeof(long) and typeof(Int64) it would return number values as strings. The following change does the trick:

diff --git a/src/wp/SQLite.cs b/src/wp/SQLite.cs
index f1b96c2..268d569 100644
--- a/src/wp/SQLite.cs
+++ b/src/wp/SQLite.cs
@@ -1958,8 +1958,6 @@ namespace SQLite
                                 targetType = typeof(string);
                                 break;
                             case SQLite3.ColType.Integer:
-                                targetType = typeof(int);
-                                break;
                             case SQLite3.ColType.Float:
                                 targetType = typeof(double);
                                 break;

brodycj pushed a commit to brodycj/Cordova-sqlite-storage-common-dev that referenced this issue Feb 9, 2016
@brodycj brodycj closed this as completed Aug 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants