Coder Social home page Coder Social logo

sqflite_web's People

Contributors

deakjahn avatar jamespet77 avatar quentincg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sqflite_web's Issues

Installation

Hello,

I'm not sure how to install this plugin in my flutter web project.

Sorry for the dumb question.

Strange behavior if not using transaction

Hello,

I found strange behavior in your library that makes it not compatible with current sqflite implementation (without speaking of other issues since it is a POC).
If we don't use transaction, the queries are not working correctly:

Source code:

//import 'package:sqflite_common/sqlite_api.dart';
//import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:sqflite/sqflite.dart';
import 'package:sqflite_web/sqflite_web.dart';

Future main() async {
  var databaseFactory = databaseFactoryWeb;
  var db = await databaseFactory.openDatabase(inMemoryDatabasePath);
  await db.setVersion(10);
  await db.execute('''
  CREATE TABLE Product (
      id INTEGER PRIMARY KEY,
      title TEXT
  )
  ''');

  int id = await db.insert('Product', <String, dynamic>{'title': 'Product 1'});
  print("Inserted ID: "+id.toString());

  int updateRes = await db.update('Product', <String, dynamic>{'title': 'Product RENAMED 1'}, where: 'id = ?', whereArgs: [id]);
  print("Update result: "+updateRes.toString());

  var result = await db.query('Product');
  print("Product results: "+result.toString());

  await db.transaction<bool>((txn) async {
    int updateRes = await txn.update('Product', <String, dynamic>{'title': 'Product RENAMED 2'}, where: 'id = ?', whereArgs: [id]);
    print("Update result: "+updateRes.toString());
    return true;
  });

  var result2 = await db.query('Product');
  print("Product results: "+result2.toString());

  await db.close();
}

Output with comments:

Inserted ID: 1
Update result: 0 <-- Update didn't work with "simple update" (should be "1")
Product results: [{id: 1, title: Product 1}] <-- Since the update didn't work, we don't see the "RENAMED"
Update result: 1 <-- Now it worked with a transaction
Product results: [{id: 1, title: Product RENAMED 2}] <-- And so we can see the value is correct after a transaction

Do you have some ideas about why there is this behavior?

OnCreate optional callback seems to be missing in openDatabase() method

Hi,

I really like this plugin. It's a nice way to quickly test the mobile app on the web during its development.

One thing that seems to be missing is the OnCreate callback on openDatabase() method as a nice way to create required tables in the database if database does not exist yet.

Are there any plans to include this feature in the near future?

[!] No podspec found for `sqflite_web` in `.symlinks/plugins/sqflite_web/ios`

I'll get that error when I compile my app for iOS by Codemagic.

Any idea? I couldn't find a reference to iOS anywhere in the code.

Full log:

Running pod install...                                              4.3s
CocoaPods' output:
↳
      Preparing

    Analyzing dependencies

    Inspecting targets to integrate
      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)

    Fetching external sources
    -> Fetching podspec for `Flutter` from `Flutter`
    -> Fetching podspec for `barcode_scan` from `.symlinks/plugins/barcode_scan/ios`
    -> Fetching podspec for `device_info` from `.symlinks/plugins/device_info/ios`
    -> Fetching podspec for `firebase_messaging` from `.symlinks/plugins/firebase_messaging/ios`
    -> Fetching podspec for `flutter_device_locale` from `.symlinks/plugins/flutter_device_locale/ios`
    -> Fetching podspec for `flutter_keyboard_visibility` from `.symlinks/plugins/flutter_keyboard_visibility/ios`
    -> Fetching podspec for `flutter_local_notifications` from `.symlinks/plugins/flutter_local_notifications/ios`
    -> Fetching podspec for `flutter_plugin_android_lifecycle` from `.symlinks/plugins/flutter_plugin_android_lifecycle/ios`
    -> Fetching podspec for `flutter_splash_screen` from `.symlinks/plugins/flutter_splash_screen/ios`
    -> Fetching podspec for `flutter_user_agent` from `.symlinks/plugins/flutter_user_agent/ios`
    -> Fetching podspec for `google_maps_flutter` from `.symlinks/plugins/google_maps_flutter/ios`
    -> Fetching podspec for `location` from `.symlinks/plugins/location/ios`
    -> Fetching podspec for `location_web` from `.symlinks/plugins/location_web/ios`
    -> Fetching podspec for `multi_image_picker` from `.symlinks/plugins/multi_image_picker/ios`
    -> Fetching podspec for `open_file` from `.symlinks/plugins/open_file/ios`
    -> Fetching podspec for `package_info` from `.symlinks/plugins/package_info/ios`
    -> Fetching podspec for `path_provider` from `.symlinks/plugins/path_provider/ios`
    -> Fetching podspec for `path_provider_linux` from `.symlinks/plugins/path_provider_linux/ios`
    -> Fetching podspec for `path_provider_macos` from `.symlinks/plugins/path_provider_macos/ios`
    -> Fetching podspec for `share` from `.symlinks/plugins/share/ios`
    -> Fetching podspec for `shared_preferences` from `.symlinks/plugins/shared_preferences/ios`
    -> Fetching podspec for `shared_preferences_macos` from `.symlinks/plugins/shared_preferences_macos/ios`
    -> Fetching podspec for `shared_preferences_web` from `.symlinks/plugins/shared_preferences_web/ios`
    -> Fetching podspec for `sqflite` from `.symlinks/plugins/sqflite/ios`
    -> Fetching podspec for `sqflite_web` from `.symlinks/plugins/sqflite_web/ios`
    [!] No podspec found for `sqflite_web` in `.symlinks/plugins/sqflite_web/ios`

    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/external_sources/path_source.rb:14:in `block in fetch'
    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/user_interface.rb:64:in `section'
    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/external_sources/path_source.rb:11:in `fetch'
    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/analyzer.rb:980:in `fetch_external_source'
    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/analyzer.rb:959:in `block (2 levels) in fetch_external_sources'
    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/analyzer.rb:958:in `each'
    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/analyzer.rb:958:in `block in fetch_external_sources'
    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/user_interface.rb:64:in `section'
    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/analyzer.rb:957:in `fetch_external_sources'
    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer/analyzer.rb:117:in `analyze'
    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:410:in `analyze'
    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:235:in `block in resolve_dependencies'
    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/user_interface.rb:64:in `section'
    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:234:in `resolve_dependencies'
    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/installer.rb:156:in `install!'
    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/command/install.rb:52:in `run'
    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.3/lib/cocoapods/command.rb:52:in `run'
    /Users/builder/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/cocoapods-1.9.3/bin/pod:55:in `<top (required)>'
    /Users/builder/.rbenv/versions/2.6.5/bin/pod:23:in `load'
    /Users/builder/.rbenv/versions/2.6.5/bin/pod:23:in `<main>'

Error running pod install


Build failed :|
Failed to build for iOS

Discussion

Initial thoughts

We have a very simple example/main opening the database, creating a table, inserting two records then reading those back, finally closing the database. This already runs fine, leaving notes in the console log.

The implementation is rather simple, basing on the ffi example and leaving out unnecessary items (including the env_utils.dart that's completely unnecessary since it can be queried from the system :-) ).

The implementation implements most of the DatabaseExecutor functions except for the transaction/batch handling.

JavaScript

As to the JS side, the plugin registers its own JS file (no need to manually edit the Index.html) and uses RequireJS to load the sql-js library.

Then we load both the main JS and the WASM files from the CDN, and simply use them with the help of the js package. The documentation can be found at https://sql-js.github.io/sql.js/documentation/class/Database.html .

The OpenDatabaseOptions not works

Also in the generated_plugin_registrant.dart generated file.

I got this error:

Undefined name 'SqflitePluginWeb'.
//
// Generated file. Do not edit.
//

// ignore_for_file: lines_longer_than_80_chars

import 'package:sqflite_web/sqflite_web.dart';
// ignore: public_member_api_docs
void registerPlugins(Registrar registrar) {
...
  SqflitePluginWeb.registerWith(registrar);
...
}

Pubspec.yaml

environment:
  sdk: '>=2.12.0 <3.0.0'

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter

  sqflite: ^2.0.0+3
  sqflite_common_ffi: ^2.0.0+1
  sqlite3_flutter_libs: ^0.5.0
  sqflite_web:
    git:
      url: https://github.com/deakjahn/sqflite_web.git
      ref: master

main.dart

import 'dart:async';
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:sqflite_web/sqflite_web.dart';


Future onConfigure(Database db) async {
  await db.execute('PRAGMA foreign_keys = ON');
}

Future<Database> database() async {
  var databaseFactory;
  if (kIsWeb) {
    databaseFactory = databaseFactoryWeb;
  } else if (Platform.isWindows || Platform.isLinux) {
    sqfliteFfiInit();
    databaseFactory = databaseFactoryFfi;
  }
  final Future<Database> database = databaseFactory.openDatabase(
    kIsWeb
        ? inMemoryDatabasePath
        : join(await getDatabasesPath(), 'database.db'),
    options: OpenDatabaseOptions(
      onConfigure: onConfigure,
      onCreate: (db, version) async {
        print(' ******** Never run  ********');
        Batch batch = db.batch();
        createTables(batch);
        createIndexes(batch);
        await batch.commit(continueOnError: false);
      },
      version: 1,
    ),
  );
  return database;
}

Traceback

Error: no such table: user

It seems the OpenDatabaseOptions' or onCreateofOpenDatabaseOptions' not works.

And Also it seems batch commit is not works:

    await db.setVersion(1);
    Batch batch = db.batch();
    batch.execute("CREATE TABLE User");
    await batch.commit();

Traceback:

Error: Expected a value of type 'List<dynamic>', but got one of type 'Null'

Browser's console logging

Hello,

This plugin is working as expected, no problem on that but I see it is leaving prints in the browser console:

For example:
INSERT OR REPLACE INTO gender (id, name, icon) VALUES (?, ?, ?) [2, Femenino, venus]

Is there a way to stop logging the "database" transactions in the browser console?

Thanks.

Open from existing database

Is it possible to open an existing database?

I made some changes to the project to test, exposing the method below it works, but I was unable to access it from outside the library.

/// Open web database from byte data.
SqfliteWebDatabase.fromData(
{@required this.path,
@required this.readOnly,
@required this.logLevel,
Uint8List data}) {
_dbOpen(data);
_isOpen = true;
}

unable to install package

Hi guys
I have got a problem in install packages. can you help me?

Because url_launcher_platform_interface 1.0.9 depends on plugin_platform_interface ^1.0.1 and no versions of url_launcher_platform_interface match >1.0.9 <2.0.0, url_launcher_platform_interface ^1.0.9 requires plugin_platform_interface ^1.0.1. And because every version of sqflite_web from git depends on plugin_platform_interface ^2.0.0, sqflite_web from git is incompatible with url_launcher_platform_interface ^1.0.9. And because url_launcher 5.7.10 depends on url_launcher_platform_interface ^1.0.9 and no versions of url_launcher match >5.7.10 <6.0.0, sqflite_web from git is incompatible with url_launcher ^5.7.10. So, because app depends on both url_launcher ^5.7.10 and sqflite_web from git, version solving failed. pub get failed (1; So, because app depends on both url_launcher ^5.7.10 and sqflite_web from git, version solving failed.) exit code 1

pubspec.yaml :


name: app
description: A new Flutter project.
version: 1.0.0+1

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.0
  page_transition: ^1.1.4
  argon_buttons_flutter: ^1.0.6
  pin_code_fields: ^7.0.0
  introduction_screen: ^1.0.9
  retrofit: ^1.3.4+1
  loading: ^1.0.2
  dio: ^3.0.10
  json_serializable: ^3.5.1
  json_annotation: any
  equatable: ^1.2.5
  bloc: ^6.1.1
  flutter_launcher_icons: ^0.7.3
  flutter_bloc: ^6.1.1
  shared_preferences: any
  persistent_bottom_nav_bar: any
  carousel_slider: ^3.0.0
  tree_view: ^0.0.5
  video_player: any
  # connectivity_plus: ^0.8.1
  top_snackbar_flutter: ^1.0.0
  shamsi_date: ^0.15.0
  sqflite: ^1.3.2+2
  icon_badge: ^0.0.1+5
  path_provider: any
  # permission_handler: ^4.4.0+hotfix.2
  webview_flutter: ^2.0.10
  intl: ^0.16.1
  image_pickers: ^1.1.0
  page_slider: ^0.0.2
  # firebase_messaging: ^7.0.3
  # firebase_core: any
  timeline_tile: ^2.0.0
  audioplayerui: ^0.0.7
  flutter_html: ^0.8.2
  url_launcher: ^5.7.10
  chewie: any
  pdf_viewer_jk: any
  uuid: ^2.2.2
  
dev_dependencies:
  sqflite_web:
    git:
      url: https://github.com/deakjahn/sqflite_web.git
      ref: master
  flutter_test:
    sdk: flutter
  retrofit_generator: any
  build_runner: any


flutter_icons:
  image_path_android: "images/logoo.png"
  image_path_ios: "images/logoo.png"
  android: true
  ios: true

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  # assets:
  #   - images/a_dot_burr.jpeg
  #   - images/a_dot_ham.jpeg
  assets:
    - images/
  #   - images/a_dot_ham.jpeg

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  fonts:
     - family: dana
       fonts:
          - asset: assets/dana.ttf 
  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

`rawInsert` generates error -> `preparedStatement.executeWith` is not a function.

Hey deakjahn,

I appreciate your work on bringing sqflite to web. I know this is still new and experimental, despite I would like to report a bug that I can't fix myself.

When inserting a new row (and I think also for rawUpdate and rawQuery it produces this error:

image

Example code:

import 'package:sqflite_common/sqlite_api.dart';
import 'package:sqflite_web/sqflite_web.dart';

Future main() async {
  var databaseFactory = databaseFactoryWeb;
  var db = await databaseFactory.openDatabase(inMemoryDatabasePath);
  await db.setVersion(10);
  await db.execute('''
  CREATE TABLE Product (
      id INTEGER PRIMARY KEY,
      title TEXT
  )
  ''');
  await db.insert('Product', <String, dynamic>{'title': 'Product 1'});
  await db.insert('Product', <String, dynamic>{'title': 'Product 2'});
  await db.insert('Product', <String, dynamic>{'title': 'Product 2'});
  await db.rawInsert('INSERT INTO Product(title) VALUES(?)', ['Product 3']);
  
  var result = await db.query('Product');
  print(result);
  // prints [{id: 1, title: Product 1}, {id: 2, title: Product 2}]
  print(await db.getVersion());
  // prints 10
  await db.close();
}

Could you check this out?

Unable to install

When I try to install sqflite_web, I get this error:

[myapp] flutter pub get
Running "flutter pub get" in myapp...                          967ms
exit code 0

--

[myapp] flutter pub get
Running "flutter pub get" in myapp...                       
Because every version of sqflite_web from git depends on sqflite_common ^1.0.3 and sqflite_common_ffi 2.0.0+1 depends on sqflite_common >=2.0.0 <4.0.0, sqflite_web from git is incompatible with sqflite_common_ffi 2.0.0+1.
And because no versions of sqflite_common_ffi match >2.0.0+1 <3.0.0, sqflite_web from git is incompatible with sqflite_common_ffi ^2.0.0+1.
So, because myapp depends on both sqflite_common_ffi ^2.0.0+1 and sqflite_web from git, version solving failed.
pub get failed (1; So, because myapp depends on both sqflite_common_ffi ^2.0.0+1 and sqflite_web from git, version solving failed.)
exit code 1

Has anyone faced this issue?
Any pointers would be appreciated. Thanks.

passing parameters to rawQuery doesn't work

When passing any parameter it doesn't seem to bind to the query.

Example:

import 'package:sqflite_common/sqlite_api.dart';
import 'package:sqflite_web/sqflite_web.dart';

Future main() async {
  var databaseFactory = databaseFactoryWeb;
  var db = await databaseFactory.openDatabase(inMemoryDatabasePath);

  await db.execute('''
  CREATE TABLE Product (
      id INTEGER PRIMARY KEY,
      title TEXT
  )
  ''');

  await db.insert('Product', <String, dynamic>{'title': 'Product 1'});

  // Does work
  var result = await db.query('Product');
  print(result);

  // Does work
  result = await db.rawQuery('SELECT * FROM Product', []);
  print(result);

  // Does work
  result = await db.query('Product WHERE title = "Product 1"');
  print(result);

  // Does not work
  result = await db.rawQuery('SELECT * FROM Product WHERE title = ?', ['Product 1']);
  print(result);

  await db.close();
}

Result:
image

Error: The non-abstract class 'SqfliteWebDatabase' is missing implementations for these members:

Launching lib/salus_prod_main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
../../.pub-cache/hosted/pub.dev/sqflite-2.2.4+1/lib/src/factory_impl.dart:15:1: Error: Type 'DatabaseFactory' not found.
DatabaseFactory get databaseFactory => sqfliteDatabaseFactory;
^^^^^^^^^^^^^^^
../../.pub-cache/hosted/pub.dev/sqflite-2.2.4+1/lib/src/factory_impl.dart:23:21: Error: Type 'DatabaseFactory' not found.
set databaseFactory(DatabaseFactory? databaseFactory) {
^^^^^^^^^^^^^^^
../../.pub-cache/git/sqflite_web-433b0511fa56c65694f312255dd44661dcbe471a/lib/src/sqflite_web_impl.dart:80:7: Error: The non-abstract class 'SqfliteWebDatabase' is missing implementations for these members:

  • DatabaseExecutor.database
  • DatabaseExecutor.queryCursor
  • DatabaseExecutor.rawQueryCursor
  • SqfliteDatabase.invokeMethod
  • SqfliteDatabase.txnQueryCursorClose
  • SqfliteDatabase.txnQueryCursorGetCurrent
  • SqfliteDatabase.txnQueryCursorMoveNext
  • SqfliteDatabase.txnRawDelete
  • SqfliteDatabase.txnRawQueryCursor
    Try to either
  • provide an implementation,
  • inherit an implementation from a superclass or mixin,
  • mark the class as abstract, or
  • provide a 'noSuchMethod' implementation.

class SqfliteWebDatabase extends SqfliteDatabase {
^^^^^^^^^^^^^^^^^^
../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/sqlite_api.dart:260:16: Context: 'DatabaseExecutor.database' is defined here.
Database get database;
^^^^^^^^
../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/sqlite_api.dart:174:23: Context: 'DatabaseExecutor.queryCursor' is defined here.
Future queryCursor(String table,
^^^^^^^^^^^
../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/sqlite_api.dart:169:23: Context: 'DatabaseExecutor.rawQueryCursor' is defined here.
Future rawQueryCursor(String sql, List<Object?>? arguments,
^^^^^^^^^^^^^^
../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/src/database.dart:131:13: Context: 'SqfliteDatabase.invokeMethod' is defined here.
Future invokeMethod(String method, [Object? arguments]);
^^^^^^^^^^^^
../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/src/database.dart:114:16: Context: 'SqfliteDatabase.txnQueryCursorClose' is defined here.
Future txnQueryCursorClose(
^^^^^^^^^^^^^^^^^^^
../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/src/database.dart:110:24: Context: 'SqfliteDatabase.txnQueryCursorGetCurrent' is defined here.
Map<String, Object?> txnQueryCursorGetCurrent(
^^^^^^^^^^^^^^^^^^^^^^^^
../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/src/database.dart:106:16: Context: 'SqfliteDatabase.txnQueryCursorMoveNext' is defined here.
Future txnQueryCursorMoveNext(
^^^^^^^^^^^^^^^^^^^^^^
../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/src/database.dart:122:15: Context: 'SqfliteDatabase.txnRawDelete' is defined here.
Future txnRawDelete(
^^^^^^^^^^^^
../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/src/database.dart:102:30: Context: 'SqfliteDatabase.txnRawQueryCursor' is defined here.
Future txnRawQueryCursor(SqfliteTransaction? txn,
^^^^^^^^^^^^^^^^^
../../.pub-cache/git/sqflite_web-433b0511fa56c65694f312255dd44661dcbe471a/lib/src/sqflite_web_impl.dart:500:13: Error: The method 'SqfliteWebDatabase.txnExecute' has fewer named arguments than those of overridden method 'SqfliteDatabase.txnExecute'.
Future txnExecute(SqfliteTransaction? txn, String sql, [List? arguments]) {
^
../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/src/database.dart:89:13: Context: This is the overridden method ('txnExecute').
Future txnExecute(
^
../../.pub-cache/git/sqflite_web-433b0511fa56c65694f312255dd44661dcbe471a/lib/src/sqflite_web_impl.dart:449:36: Error: The argument type 'SqfliteWebDatabase' can't be assigned to the parameter type 'SqfliteDatabaseMixin'.

  • 'SqfliteWebDatabase' is from 'package:sqflite_web/src/sqflite_web_impl.dart' ('../../.pub-cache/git/sqflite_web-433b0511fa56c65694f312255dd44661dcbe471a/lib/src/sqflite_web_impl.dart').
  • 'SqfliteDatabaseMixin' is from 'package:sqflite_common/src/database_mixin.dart' ('../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/src/database_mixin.dart').
    final txn = SqfliteTransaction(this);
    ^
    ../../.pub-cache/git/sqflite_web-433b0511fa56c65694f312255dd44661dcbe471a/lib/src/sqflite_web_impl.dart:474:19: Error: The operator '[]' isn't defined for the class 'SqfliteBatchOperation'.
  • 'SqfliteBatchOperation' is from 'package:sqflite_common/src/batch.dart' ('../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/src/batch.dart').
    Try correcting the operator to an existing operator, or defining a '[]' operator.
    switch (op['method'] as String) {
    ^
    ../../.pub-cache/git/sqflite_web-433b0511fa56c65694f312255dd44661dcbe471a/lib/src/sqflite_web_impl.dart:476:34: Error: The operator '[]' isn't defined for the class 'SqfliteBatchOperation'.
  • 'SqfliteBatchOperation' is from 'package:sqflite_common/src/batch.dart' ('../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/src/batch.dart').
    Try correcting the operator to an existing operator, or defining a '[]' operator.
    await txn!.execute(op['sql'] as String, op['arguments'] as List);
    ^
    ../../.pub-cache/git/sqflite_web-433b0511fa56c65694f312255dd44661dcbe471a/lib/src/sqflite_web_impl.dart:476:55: Error: The operator '[]' isn't defined for the class 'SqfliteBatchOperation'.
  • 'SqfliteBatchOperation' is from 'package:sqflite_common/src/batch.dart' ('../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/src/batch.dart').
    Try correcting the operator to an existing operator, or defining a '[]' operator.
    await txn!.execute(op['sql'] as String, op['arguments'] as List);
    ^
    ../../.pub-cache/git/sqflite_web-433b0511fa56c65694f312255dd44661dcbe471a/lib/src/sqflite_web_impl.dart:479:48: Error: The operator '[]' isn't defined for the class 'SqfliteBatchOperation'.
  • 'SqfliteBatchOperation' is from 'package:sqflite_common/src/batch.dart' ('../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/src/batch.dart').
    Try correcting the operator to an existing operator, or defining a '[]' operator.
    final row = await txn!.rawInsert(op['sql'] as String, op['arguments'] as List);
    ^
    ../../.pub-cache/git/sqflite_web-433b0511fa56c65694f312255dd44661dcbe471a/lib/src/sqflite_web_impl.dart:479:69: Error: The operator '[]' isn't defined for the class 'SqfliteBatchOperation'.
  • 'SqfliteBatchOperation' is from 'package:sqflite_common/src/batch.dart' ('../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/src/batch.dart').
    Try correcting the operator to an existing operator, or defining a '[]' operator.
    final row = await txn!.rawInsert(op['sql'] as String, op['arguments'] as List);
    ^
    ../../.pub-cache/git/sqflite_web-433b0511fa56c65694f312255dd44661dcbe471a/lib/src/sqflite_web_impl.dart:483:50: Error: The operator '[]' isn't defined for the class 'SqfliteBatchOperation'.
  • 'SqfliteBatchOperation' is from 'package:sqflite_common/src/batch.dart' ('../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/src/batch.dart').
    Try correcting the operator to an existing operator, or defining a '[]' operator.
    final result = await txn!.rawQuery(op['sql'] as String, op['arguments'] as List);
    ^
    ../../.pub-cache/git/sqflite_web-433b0511fa56c65694f312255dd44661dcbe471a/lib/src/sqflite_web_impl.dart:483:71: Error: The operator '[]' isn't defined for the class 'SqfliteBatchOperation'.
  • 'SqfliteBatchOperation' is from 'package:sqflite_common/src/batch.dart' ('../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/src/batch.dart').
    Try correcting the operator to an existing operator, or defining a '[]' operator.
    final result = await txn!.rawQuery(op['sql'] as String, op['arguments'] as List);
    ^
    ../../.pub-cache/git/sqflite_web-433b0511fa56c65694f312255dd44661dcbe471a/lib/src/sqflite_web_impl.dart:487:48: Error: The operator '[]' isn't defined for the class 'SqfliteBatchOperation'.
  • 'SqfliteBatchOperation' is from 'package:sqflite_common/src/batch.dart' ('../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/src/batch.dart').
    Try correcting the operator to an existing operator, or defining a '[]' operator.
    final row = await txn!.rawUpdate(op['sql'] as String, op['arguments'] as List);
    ^
    ../../.pub-cache/git/sqflite_web-433b0511fa56c65694f312255dd44661dcbe471a/lib/src/sqflite_web_impl.dart:487:69: Error: The operator '[]' isn't defined for the class 'SqfliteBatchOperation'.
  • 'SqfliteBatchOperation' is from 'package:sqflite_common/src/batch.dart' ('../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/src/batch.dart').
    Try correcting the operator to an existing operator, or defining a '[]' operator.
    final row = await txn!.rawUpdate(op['sql'] as String, op['arguments'] as List);
    ^
    ../../.pub-cache/git/sqflite_web-433b0511fa56c65694f312255dd44661dcbe471a/lib/src/sqflite_web_impl.dart:491:37: Error: The operator '[]' isn't defined for the class 'SqfliteBatchOperation'.
  • 'SqfliteBatchOperation' is from 'package:sqflite_common/src/batch.dart' ('../../.pub-cache/hosted/pub.dev/sqflite_common-2.4.2+2/lib/src/batch.dart').
    Try correcting the operator to an existing operator, or defining a '[]' operator.
    throw "Batch method ${op['method']} not supported";
    ^
    ../../.pub-cache/hosted/pub.dev/sqflite-2.2.4+1/lib/src/factory_impl.dart:23:21: Error: 'DatabaseFactory' isn't a type.
    set databaseFactory(DatabaseFactory? databaseFactory) {

No transaction support

Currently my application crashes due to no transaction support:
image

Any plans to support this? sql-js seems to support it. Anything preventing it?

Perhaps a PR with support would be okay if possible?

Undefined name 'SqflitePluginWeb'

I'm not really sure this is a bug or an issue with this library. But asking still...

When I add the dependency to a project the generated_plugin_registrant.dart has some errors:

% flutter analyze 
Running "flutter pub get" in web...                              1,354ms
Analyzing web...                                                        

   info • Unused import: 'package:sqflite_web/sqflite_web.dart' • lib/generated_plugin_registrant.dart:7:8 • unused_import
  error • Undefined name 'SqflitePluginWeb' • lib/generated_plugin_registrant.dart:13:3 • undefined_identifier

A minimal error producing pubspec.yaml:

name: web
description: A new Flutter project.
version: 1.0.0+1
environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.2

dev_dependencies:
  flutter_test:
    sdk: flutter
  sqflite_web:
    git:
      url: https://github.com/deakjahn/sqflite_web.git
      ref: 16350eaeaeee949db3c073cbc95a5e3f2880f096

flutter:
  uses-material-design: true

I'm asking because the project runs and works in web but tooling seems to be confused about it...

I'm running Flutter stable 2.2.2

Not able to add dependency.

../../Library/Android/flutter/.pub-cache/git/sqflite_web-5e394d2664e88cc9249b4f64da93e6dd2b715048/lib/src/sqflite_web_impl.dart:5:8: Error: Not found: 'dart:js'

../../Library/Android/flutter/.pub-cache/git/sqflite_web-5e394d2664e88cc9249b4f64da93e6dd2b715048/lib/src/sqflite_web.dart:2:8: Error: Not found: 'dart:html'
import 'dart:html' as html;
^
Screenshot 2022-01-31 at 10 23 57 PM

Is the database persisted on disk among visits to my website?

Hi, will this plugin allow me to persist session data in the disk that can be accessed each time the user accesses my website? This is not clear to me as sql.js states the following: It uses a virtual database file stored in memory, and thus doesn't persist the changes made to the database.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.