Skip to content

Database fails to open in production #4561

@MorganTrudeau

Description

@MorganTrudeau

Issue type:

[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[x] react-native
[ ] expo

TypeORM version:

[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

OPEN database fails in production. Database is working as expected in debug mode.

Expected Behavior

Database should open and initialize tables successfully in production and debug modes.

Current Behavior

Database is opening in debug mode and failing in production

Steps to Reproduce (for bugs)

Using typeorm I have created entities in the following form:

import { EntitySchema } from 'typeorm';
import { StorageModel } from '../models/StorageModel';

export default new EntitySchema({
  name: 'Storage',
  target: StorageModel,
  columns: {
    key: { type: 'text', primary: true },
    value: { type: 'text' },
  },
});

Then I am opening database with the following config:

createConnection({
      name: 'db.sqlite',
      type: 'react-native',
      database: 'react-native',
      location: 'default',
      // logging: ['error', 'query', 'schema'],
      synchronize: true,
      entities: [
        Translation,
        User,
        Post,
        Download,
        Asset,
        Option,
        QueuedRequest,
        Storage,
        HelpItem,
      ],
    });

In debug the database opens correctly and I have used it to create many features. It was going very well until I tried building the release apk. I get the following error in adb logcat...

08-08 19:04:52.174 19954 20022 I ReactNativeJS: OPEN database: react-native
08-08 19:04:52.340 19954 20032 E SQLiteLog: (1) near ")": syntax error
08-08 19:04:52.340 19954 20032 E unknown:SQLitePlugin: SQLitePlugin.executeSql[Batch]() failed
08-08 19:04:52.340 19954 20032 E unknown:SQLitePlugin: android.database.sqlite.SQLiteException: near ")": syntax error (code 1): , while compiling: CREATE TABLE "temporary_t" ()
08-08 19:04:52.340 19954 20032 E unknown:SQLitePlugin: 	at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
08-08 19:04:52.340 19954 20032 E unknown:SQLitePlugin: 	at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:895)
08-08 19:04:52.340 19954 20032 E unknown:SQLitePlugin: 	at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:506)
08-08 19:04:52.340 19954 20032 E unknown:SQLitePlugin: 	at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:726)
08-08 19:04:52.340 19954 20032 E unknown:SQLitePlugin: 	at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
08-08 19:04:52.340 19954 20032 E unknown:SQLitePlugin: 	at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
08-08 19:04:52.340 19954 20032 E unknown:SQLitePlugin: 	at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
08-08 19:04:52.340 19954 20032 E unknown:SQLitePlugin: 	at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1428)
08-08 19:04:52.340 19954 20032 E unknown:SQLitePlugin: 	at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1367)
08-08 19:04:52.340 19954 20032 E unknown:SQLitePlugin: 	at org.pgsqlite.SQLitePlugin.executeSqlStatementQuery(SQLitePlugin.java:805)
08-08 19:04:52.340 19954 20032 E unknown:SQLitePlugin: 	at org.pgsqlite.SQLitePlugin.executeSqlBatch(SQLitePlugin.java:712)
08-08 19:04:52.340 19954 20032 E unknown:SQLitePlugin: 	at org.pgsqlite.SQLitePlugin.access$100(SQLitePlugin.java:49)
08-08 19:04:52.340 19954 20032 E unknown:SQLitePlugin: 	at org.pgsqlite.SQLitePlugin$DBRunner.run(SQLitePlugin.java:927)
08-08 19:04:52.340 19954 20032 E unknown:SQLitePlugin: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
08-08 19:04:52.340 19954 20032 E unknown:SQLitePlugin: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
08-08 19:04:52.340 19954 20032 E unknown:SQLitePlugin: 	at java.lang.Thread.run(Thread.java:764)

Context

Using react-native-sqlite-storage with typeorm to build offline support for a react-native app.

Your Environment

  • typeorm: ^0.2.18
  • React Native SQLite Storage Version used: 3.3.10 and also on 3.2.0
  • React Native version used: 0.60.0
  • Operating System and version (simulator or device): LG G6 Android 8.0.0
  • IDE used: Android Studio
  • Link to your project: Private client project SRY

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions