Skip to content

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

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

Open
dustinshackley opened this issue Dec 27, 2018 · 1 comment
Open

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

dustinshackley opened this issue Dec 27, 2018 · 1 comment

Comments

@dustinshackley
Copy link

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant