brodybits / cordova-sqlite-ext

A Cordova/PhoneGap plugin to open and use sqlite databases on Android/iOS/macOS/Windows with REGEXP (Android/macOS/iOS) and pre-populated databases (Android/iOS/macOS/Windows)
Other
71 stars 55 forks source link

Cordova IOS insert/select out of column order. #82

Open dustinshackley opened 5 years ago

dustinshackley commented 5 years ago

When selecting data from a db (successfully loaded and writable/readable with no errors) the select * statement returns the data in the wrong order. I believe this to be because the insert statement prior, inserted it out of order somehow.

The android version works just fine, inserts and selects with no issue, it's in the correct column order.

Here's a snippet of the code in question, as you can see I am specifying the columns to insert and the columns to select. I'm not sure what I'm doing wrong.

db.executeSql("INSERT INTO table_name (Col1, Col2) VALUES (?1, ?2)"),values,function.......

And the select statement: db.executeSql('SELECT Col1, Col2 from table_name')

Where values is equal to an array of data with the exact number of elements as columns being inserted. No deviance here, no insert errors.

The data is in the correct order prior to being inserted.

Prior to being inserted: ["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30"]

After being inserted and selected from db: ["2","23","16","19","17","15","21","22","25","13","20","27","28","No","8","6","18","5","3","11","10","26","9","1","12","29","24","7","14","4"]

You can see how jumbled it gets. Again, doesn't happen on Android with same code.

Any suggestions would be greatly appreciated!

dustinshackley commented 5 years ago

Switched to SQLite2 plugin for iOS and it works fine for anyone running into this issue.