plugins icon indicating copy to clipboard operation
plugins copied to clipboard

[sqflite] The FFI implementation of sqflite_tizen

Open swift-kim opened this issue 3 years ago • 2 comments

Source code

https://github.com/swift-kim/plugins/tree/sqflite/packages/sqflite

Usage

Add sqflite_tizen as a git package dependency in your pubspec.yaml.

dependencies:
  sqflite:
  sqflite_tizen:
    git: https://github.com/swift-kim/plugins
    ref: sqflite
    path: packages/sqflite

Current status

The following tests (from the sqflite example app) are currently failing. No critical error found. None of the errors are Tizen-specific.

  • Raw tests
    • Options: Not implemented by sqflite_common_ffi.
    • Debug mode (log): Partially implemented by sqflite_common_ffi.
    • without rowid: Bad test case (0 is returned on Tizen).
  • Open tests
    • open in transaction: A bug in sqflite_common_ffi.
    • Open non sqlite file: Bad test case (succeeds only on Android).
  • Type tests
    • blob: Not implemented by sqflite_common_ffi (see getSqlArguments in sqflite_ffi_impl.dart).
    • bool: Not implemented by sqflite_common_ffi.
  • Exp tests
    • sql dump file
  • Exception tests
    • Sqlite Exception
    • Sqlite batch Exception
    • Bind no argument (no iOS)
    • crash ios (no iOS)
    • Bind no parameter
    • Thread dead lock

https://github.com/flutter-tizen/plugins/pull/276#issuecomment-970168882

swift-kim avatar Nov 23 '21 06:11 swift-kim

We can even use sqlite3 directly without needing to extend sqflite.

import 'dart:ffi';
import 'package:sqlite3/open.dart';
import 'package:sqlite3/sqlite3.dart';

open.overrideFor(OperatingSystem.linux, () {
  return DynamicLibrary.open('libsqlite3.so.0');
});

Database db = sqlite3.openInMemory();
db.execute('...');

Basic operations (such as CREATE and INSERT) just worked but more testing is needed.

swift-kim avatar Dec 13 '21 05:12 swift-kim

Comparisons:

  • sqflite_tizen (current): An implementation of sqflite based on Tizen's sqlite3 API.
  • sqflite_tizen (FFI-based): An implementation of sqflite based on sqflite_common_ffi.
  • sqflite_common_ffi: An async wrapper around sqlite3 based on isolates.
  • sqlite3: The core binding library that has no built-in async support.
  • drift: An alternative relational database for Dart built on top of sqlite3 (written by the author of sqlite3).

swift-kim avatar Dec 13 '21 06:12 swift-kim