Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1617] SQL: Error on Android when using SQL data-binding without declaring columns

GitHub Issuen/a
TypeBug
PriorityNone
StatusResolved
ResolutionWon't Fix
Resolution Date2018-05-09T14:19:14.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsandroid
ReporterJoe Kniesek
AssigneeHans Knöchel
Created2018-05-03T20:35:27.000+0000
Updated2018-05-09T19:59:59.000+0000

Description

When using databinding with collectionmodel then i get sql.js error on ANDROID when columns are not declared. IOS works fine - with or without declaration of columns in model-js file. (attached) If i declare columns - Android-app doesn't show sql.js error (attached - screenshot from GenyMotion and Huawei 9 pro device

Attachments

FileDateSize
genymotion.png2018-05-03T20:13:52.000+0000314218
huawei.png2018-05-03T20:13:35.000+0000329077
Oplevelser.js2018-05-03T20:08:46.000+0000784

Comments

  1. Hans Knöchel 2018-05-04

    Hey there, thanks for reporting this! Before checking the issue: - Is there are reason a developer would create a table without any columns? I don't see any real world use cases for this right now. Thats probably why this did not pop up earlier. - Which Titanium SDK version, Alloy version and Android version do you use? - What is the actual error log?
  2. Joe Kniesek 2018-05-04

    Hey reason for creating a table without columns - when filling collection with data from XML-feed. Only thing necessary was the idattribute. Did follow guide her: https://medium.com/all-titanium/enhancing-titanium-how-to-set-up-collections-with-databinding-39573cd30911 Works like a charm on ios - but took some time to find the right brick (adding of a columns) to make it work right on android. And the column i added has nothing to do with my data, so you can write anything you want. - as long as it its there :) Regards Joe
  3. Joe Kniesek 2018-05-04

    *SDK:* 7.1.0. GA *ALLOY* .. hmm console: alloy --version doesnt work atm :) *ANDROID:* 8.0.0 (Device) 7.0 (GenyMotion) *Showstopper:* [ERROR]  SQLiteLog: (1) near ")": syntax error [ERROR]  TiDB: (main) [363,363] Error executing sql: near ")": syntax error (code 1): , while compiling: CREATE TABLE IF NOT EXISTS Oplevelser ( ) [ERROR]  TiDB: android.database.sqlite.SQLiteException: near ")": syntax error (code 1): , while compiling: CREATE TABLE IF NOT EXISTS Oplevelser ( ) [ERROR]  TiDB: at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) [ERROR]  TiDB: at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889) [ERROR]  TiDB: at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500) [ERROR]  TiDB: at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) aso. aso..
  4. Hans Knöchel 2018-05-04

    Okay, this looks indeed like an Android SDK issue then. Probably it needs to be CREATE TABLE IF NOT EXISTS Oplevelser instead of CREATE TABLE IF NOT EXISTS Oplevelser ( ). We will have an engineer looking into this, but cannot promise any time frame right now. As the SDK is open source, you can also take a look and submit a pull request. P.S.: It's alloy -v
  5. Hans Knöchel 2018-05-04

    PR: https://github.com/appcelerator/alloy/pull/895 Although the error is on Android, I think we should fix this in Alloy, since we are using empty column parenthesis ( ) when no columns are specified. iOS may filter this out, but Android complains for a good reason. I did not validate the fix so far, so feedback is welcome! You can replace the file from Github in your local Alloy installation. Please make a backup before and try it out!
  6. Hans Knöchel 2018-05-09

    [~jkniesek] Can you please validate that using alloy@master resolves the issue? [~fmiao] Is there a way to install alloy@master from npm instead of manually patching the local files? And can you do the version bump? Thanks everyone!
  7. Ewan Harris 2018-05-09

    [~hknoechel] \[sudo\] npm install -g git://github.com/appcelerator/alloy.git works to pull from master branch
  8. Hans Knöchel 2018-05-09

    Although the PR is merged, it still crashes - and that for a good reason. It is technically invalid to create an SQL table without columns. Read more here: - https://www.w3schools.com/sql/sql_create_table.asp - https://stackoverflow.com/questions/32961327/create-a-blank-table-with-no-column - http://sqlfiddle.com/#!9/edd78f (Demo) The only reason iOS does not fail is because the underlaying API is able to ignore that, although it shouldn't. So we would likely change iOS in the future to reject it as well.
  9. Joe Kniesek 2018-05-09

    Good idea. Thanks for all those great answers :) Code Strong !

JSON Source