Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Andrea Antonello
    @moovida
    @doppio , are you sure sqlite allows this kind of delete with inner join? I think it might not.
    Simon Binder
    @simolus3
    Right, sqlite doesn't support joins on delete statements. You can rewrite that query to use EXISTS and a subquery though.
    ttttttttttttooooo
    @tomatologistik_twitter
    How do i get stream query result without flutter framework? in flutter they use streambuilder and inside they use dao.watchAllTasks(), how do i just get the result in my dart script?
    ttttttttttttooooo
    @tomatologistik_twitter
    i can't seem to apply standart stream listen methods
    Simon Binder
    @simolus3
    @tomatologistik_twitter Moor streams behave like regular streams, so the standard listen method should work. Can you share a snippet that doesn't work so that I can take a look?
    Britannio Jarrett
    @britannio
    image.png
    Hey @simolus3, I'm getting this issue on quite a few devices and it's resulting in users not being able to view their data. Above is an image of the app bundle content, it looks fine to me.
    Non-fatal Exception: java.lang.Exception: Invalid argument(s): Failed to load dynamic library (dlopen failed: library "/data/data/app.cheon.app/lib/libsqlite3.so" not found)
           at ._defaultOpen(load_library.dart:49)
           at OpenDynamicLibrary.openSqlite(load_library.dart:99)
           at .new(bindings.dart:122)
           at .bindings(bindings.dart:266)
           at .new(database.dart:52)
           at .new(database.dart:37)
           at _VmDelegate.open(vm_database.dart:39)
           at DelegatedDatabase.ensureOpen.<fn>(engines.dart:244)
           at BasicLock.synchronized(basic_lock.dart:34)
    I'm only detecting this through Firebase Crashlytics, so far it's happened on OPPO, Lenovo, Vivo, Xiaomi and Huawei devices.
    Ignore the isolate stuff
    Britannio Jarrett
    @britannio
    It seems like the app will work on the first launch then users will come back later and encounter this issue.
    Simon Binder
    @simolus3
    Very weird that this can happen on subsequent launches. Do you know more about affected Android versions or abis?
    Britannio Jarrett
    @britannio
    It's only happened on Android 5 and 6 so far
    I have the exact device models it's occurred on from Crashlytics
    Britannio Jarrett
    @britannio
    Would it be best if I create an issue on github? @simolus3
    Simon Binder
    @simolus3
    Yes :+1: Although so far I have no idea what could be causing this. I'll try to do some research and and check if other projects have the same problem.
    10 replies
    Andrea Antonello
    @moovida
    Hi, can anyone please paste me a link to the migration quite from moor_ffi to sqlite3? I can't find it anymore and I am having a hard time to understand where the functions are ( FunctionContext ). Thank you. 🙏
    Andrea Antonello
    @moovida
    Uff, sorry for the noise, just saw that the example also features a custom function creation... and it is way simpler than before. Thank you! 😊
    Andrea Antonello
    @moovida

    Hi again, I am having issues running a function creation test on Macos. Taken from the example, my testcase is:

        final db = sqlite3.openInMemory();
        db.createFunction(
          functionName: 'dart_version',
          argumentCount: const AllowedArgumentCount(0),
          function: (args) => Platform.version,
          deterministic: true,
          directOnly: false,
        );
        var version = db.select('SELECT dart_version()');
        print(version.first);
        db.dispose();

    When it reaches the select statement, it just exits. I get no exception.
    According to the docs, on macos it should work out of the box, right?
    Thanks for any hint.

    Andrea Antonello
    @moovida
    Hmmm, fiddling a bit around, I am finally getting a hit: ArgumentError (Invalid argument(s): Failed to lookup symbol (dlsym(0x11968e598, sqlite3_open_v3): symbol not found))
    So it looks to me it is not loading the native library?
    Simon Binder
    @simolus3

    @moovida I hit the function problem too, but unfortunately I couldn't find out the exact cause. I think it's some security measure, but I don't get why it worked before. You can view the exact crash in the Console app, but so far I couldn't find out what causes it to crash now (and not before).

    It complaining about open_v3 not existing sounds like you have an older version. If you use version 0.1.4 of the sqlite3 package, it should fallback to open_v2 if needed.

    Andrea Antonello
    @moovida
    @simolus3 thanks for the reply. You mean older version of the sqlite3 dart package? I am using sqlite3: ^0.1.4, so it should be the last.
    Is the sqlite version that ships with it the same that shipped in moor_ffi? Could there be different compilation flags that induce this behaviour?
    Simon Binder
    @simolus3

    The only place where we try to use open_v3 is here, and we should catch that error. The open_v3 is actually a typo and it should be prepare_v3, but that shouldn't have an impact.

    Neither moor_ffi nor sqlite3 ship a custom sqlite version on mac. If you're using Flutter, you can try to change your mac podspec to build sqlite and change the open behavior on mac to using DynamicLibrary.executable().

    Andrea Antonello
    @moovida

    There is also an issue with using moor_ffi 0.7.0 (the last I was able to create functions in and the last not needing a flutter sdk). The dependency now pulls a never moor and sqlite3 anyways:

    |-- moor_ffi 0.7.0
    |   |-- collection 1.14.13
    |   |-- ffi 0.1.3
    |   |-- meta 1.2.2
    |   '-- moor 3.3.1
    |       |-- convert 2.1.1
    |       |   |-- charcode...
    |       |   '-- typed_data...
    |       |-- sqlite3 0.1.4
    |       |   |-- collection...
    |       |   |-- ffi...
    |       |   '-- meta...

    In the meanwhile your message arrived. So the macos issue might be due to my local native sqlite3 libs?

    Andrea Antonello
    @moovida
    Anyways, I can confirm that it now also happens with moor_ffi 0.7.0 and moor 3.2.0. So this seems to be platform dependent. are you experiencing this issue also on Android/IOS?
    Simon Binder
    @simolus3

    For moor I want users to migrate from the moor_ffi package to the moor/ffilibrary in the main moor package. This simplifies development since the parts unrelated to moor can work in the sqlite3 package and everything else lives in the main moor package. The reason moor_ffi now depends on Flutter is because we can no longer include native buildscripts in a package without depending on Flutter, so that was necessary to not break the majority of moor users. I don't like this either, but I think the current approach should work well for non-Flutter apps as well.

    I can confirm that it now also happens with moor_ffi 0.7.0 and moor 3.2.0

    Sorry, what exactly? The open_v3 issue or not being able to call custom functions? Custom functions work on Linux, I think they should work on Android too. I've opened simolus3/sqlite3.dart#6 to track this for mac.

    Andrea Antonello
    @moovida
    Alright, I did some more tests. And I am even more puzzeled :-) Context: I have a library that depends on sqlite3 (prev. on moor__ffi), which is pure dart. Then I use that one in a different dart lib and flutter app. On pure dart projects the testcases related to the functions fail on macos. But if I run the flutter app on macos, everything works as expected (also without the sqlite_flutter_libs). It also works properly on Android.
    Simon Binder
    @simolus3
    Interesting. I think the security check might be because the dart binary is signed? Does it work if you run the app through dart2native?
    Andrea Antonello
    @moovida
    Ehhhm, what do you mean? I do not have a pure dart app. Only testcases. Should I make a small app out of that and run it through dart2native (which I never used, but I guess it is just running it).
    Simon Binder
    @simolus3
    Ah ok, tests probably won't work. You could try to skip the tests using custom functions on macOS, but I'll try to figure out what causes this in the first place.
    Andrea Antonello
    @moovida
    Thanks @simolus3 , yes right now I moved to the new packages and am just skipping at dart level what does not work.
    Stas
    @stasvo
    I have question about counting, mytable.id.count() returning Expression<int>, is there way how possible to get int from it?
    Simon Binder
    @simolus3
    @stasvo An Expression is something that will evaluate to an int when run on the database. If you add it to a select, you can read the int value from a row. There's an example here.
    Stas
    @stasvo
    @simolus3 But I see that select as argument take table. You mean that need add Expression as column to table? var amount = await myTable.id.count();
    select(mytable).addColumns([amount]); Is there way to use something as temporary table where only 1 column with result?
    Simon Binder
    @simolus3
    I see what you mean. But since your expression needs a table, so does the select. You can use selectOnly(mytable)..addColumns([amount]). The selectOnly will only return the columns you add explicitly.
    Stas
    @stasvo
    @simolus3 Thanks!
    Michael Lee
    @leecommamichael
    Is it possible to have a DataClass constructor with optional named parameters, with a default? (So the underlying column is not nullable, but the DataClass property is optional.)
    Simon Binder
    @simolus3
    No, that's not possible. A data class always represents a full row, so default values for inserts would still result in required parameters.
    PointSource
    @point-source
    I am using a moor file with sql to generate my dart code. This works pretty well but I also want the uuid as default pk functionality described here: https://moor.simonbinder.eu/docs/getting-started/advanced_dart_tables/#default-values Any way to describe this in sql and have moor generate it? Or do I just need to write that table class myself?
    Simon Binder
    @simolus3
    @point-source You can use the regular DEFAULT of course, but unfortunately there's no way to use clientDefault in moor files. So you'd have to use the Dart table DSL for that table.
    Michael Lee
    @leecommamichael
    It appears that using intEnum<T> columns will break the default toJson on the emitted DataClass. This will attempt to invoke toJson on an Enum instance.
    Michael Lee
    @leecommamichael
    I'm using a custom serializer and have implemented a typecheck for my enum in that serializer.
    This solved my issue.
    Simon Binder
    @simolus3
    Yeah, type converters only apply on the conversion between Dart and SQL, not on the conversion between Dart and JSON. So you'd have to use a custom serializer.
    Ruben Vereecken
    @rubenvereecken
    I've already learnt a few things from reading some previous answers on here
    I was just trying to answer this question for myself: I've got this BehaviorSubject. When I get results from an API, they go straight into the BehaviorSubject. If I now decide to persist the results through Moor first and then have db.items().watch() stream to the BehaviorSubject instead, how much slower would that be?
    Trying to figure out whether it's worth optimising and have two streams feeding into the BehaviorSubject: a db.items().watch() and one coming from the API
    Ruben Vereecken
    @rubenvereecken
    Thought I'd share my findings. For 50 objects that I wanted to upsert (delete all + batch insert), it took about 40-50ms, meaning I probably do want to display the API results straight away rather than waiting for Moor
    Michael Lee
    @leecommamichael
    Nitpick: "upsert" refers to insert-or-replace, not delete and insert. So your performance metric may not be what people expect of an upsert.
    Also which device was this measured on? Was it a simulator?