Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

bug: exportToJson: Error get tables 'Full' failed : Query result not well formatted

Đang mở
#654 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, sqlite, swift
Lĩnh vực
database, mobile

Hướng nghiên cứu

Bắt đầu với wrapper exportToJson của sqliteLoader.js và tái hiện lỗi trên iOS bằng schema users được cung cấp. Kiểm tra thiết lập createSyncTable và đường dẫn export iOS của plugin để tìm hiểu tại sao kết quả truy vấn Full bị từ chối; được xem là hoàn thành khi export các bảng sang JSON thành công đối với cơ sở dữ liệu này.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug/fix needs: triage

Plugin version:

7.0.1

Platform(s):

iOS

Current behavior:

exportToJson: Error get tables 'Full' failed : Query result not well formatted

Expected behavior:

Succeed in exporting tables to JSON

Steps to reproduce:

 async exportToJson(mode = 'full') {
        console.log('[ sqliteLoader.js ] Exporting database to JSON...');
        return await sqlite.exportToJson({
          database: DB_NAME,
          jsonexportmode: mode
        });
      },

Related code:

Sample table:

    CREATE TABLE IF NOT EXISTS users (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      name TEXT,
      lastName TEXT,
      phoneNumber TEXT,
      email TEXT,
      sobrietyDate TEXT,
      homeGroups TEXT,
      preferences TEXT,
      privacySettings TEXT,
      notificationSettings TEXT, -- JSON string for notification preferences
      createdAt TEXT DEFAULT CURRENT_TIMESTAMP,
      updatedAt TEXT DEFAULT CURRENT_TIMESTAMP,
      sql_deleted BOOLEAN DEFAULT 0 CHECK (sql_deleted IN (0, 1)),
      last_modified INTEGER DEFAULT (strftime('%s', 'now'))
    )
import { CapacitorSQLite } from '@capacitor-community/sqlite';

// Default database name for consistency
const DB_NAME = 'tracker.db';
/**
 * Initialize SQLite database
 * @returns {Promise<object>} Database connection object
 */
export default async function initSQLiteDatabase() {
  console.log('[ sqliteLoader.js:14 ] Initializing SQLite database via Capacitor...');

  try {
    const sqlite = CapacitorSQLite;

    if (!sqlite) {
      throw new Error('CapacitorSQLite plugin not found - this app requires SQLite for iOS');
    }

    console.log('[ sqliteLoader.js ]  Found CapacitorSQLite plugin:', !!sqlite);

    // Step 1: Create connection (check if already exists first)
    try {
      await sqlite.createConnection({
        database: DB_NAME,
        version: 1,
        encrypted: false,
        mode: 'no-encryption',
        readonly: false
      });
      console.log('[ sqliteLoader.js:50 ]  Database connection created');
    } catch (connectionError) {
      console.log('[ sqliteLoader.js:52 ]  Connection may already exist:', connectionError.message);
    }



    // Step 2: Open the database
    await sqlite.open({ database: DB_NAME, readonly: false });
    console.log('[ sqliteLoader.js:56 ]  Database opened successfully');

    // Step 3: Create sync table (required for CapacitorSQLite export/import operations)
    await sqlite.createSyncTable({ database: DB_NAME });
    console.log('[ sqliteLoader.js:58 ]  Sync table created successfully');
// Sync methods for iCloud integration
      async exportToJson(mode = 'full') {
        console.log('[ sqliteLoader.js ] Exporting database to JSON...');
        return await sqlite.exportToJson({
          database: DB_NAME,
          jsonexportmode: mode
        });
      },

      async importFromJson(jsonData) {
        console.log('[ sqliteLoader.js ] Importing database from JSON...');
        return await sqlite.importFromJson({
          jsonstring: JSON.stringify(jsonData)
        });
      },

      async setSyncDate(syncDate) {
        console.log('[ sqliteLoader.js ] Setting sync date...');
        return await sqlite.setSyncDate({
          database: DB_NAME,
          syncdate: syncDate
        });
      },

      async deleteExportedRows() {
        console.log('[ sqliteLoader.js ] Deleting exported rows...');
        return await sqlite.deleteExportedRows({
          database: DB_NAME
        });
      }
    };

  } catch (error) {
    console.error('[ sqliteLoader.js ] Database initialization failed:', error);
    throw error;
  }
}

Other information:

I have read through https://github.com/capacitor-community/sqlite/issues/59 and it is long-closed, but I am having this problem repeatedly and cannot find a fix for it.

Capacitor doctor:

% npx cap doctor
💊   Capacitor Doctor  💊 

Latest Dependencies:

  @capacitor/cli: 7.4.2
  @capacitor/core: 7.4.2
  @capacitor/android: 7.4.2
  @capacitor/ios: 7.4.2

Installed Dependencies:

  @capacitor/cli: 7.4.2
  @capacitor/core: 7.4.2
  @capacitor/android: 7.4.2
  @capacitor/ios: 7.4.2
  
[success] iOS looking great! 👌
[error] gradlew file is missing in android
        AndroidManifest.xml is missing in app/src/main

Expected, since I'm not currently working on Android.

Ngôn ngữ chính
Swift
Star
663
Fork
159
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của capacitor-community/sqlite

Tất cả issue của capacitor-community/sqlite

Issue tương tự

Thêm issue về Swift

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.