-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Full-text Search support #407
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #407 +/- ##
===========================================
+ Coverage 83.40% 83.63% +0.22%
===========================================
Files 68 69 +1
Lines 1687 1741 +54
===========================================
+ Hits 1407 1456 +49
- Misses 280 285 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
b608074
to
d541aad
Compare
resolve issue #397 |
Thanks for your contribution 🙏 I'll look into reviewing it ASAP. |
4aeea98
to
b210d2e
Compare
} else { | ||
final ftsType = fts.type ?? ''; | ||
final ftsTokenizer = fts.tokenizer ?? ''; | ||
return 'CREATE VIRTUAL TABLE IF NOT EXISTS `$name` USING $ftsType(${databaseDefinition.join(', ')}, tokenize=$ftsTokenizer)$withoutRowidClause'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Does FTS work without a rowid
?
return 'CREATE VIRTUAL TABLE IF NOT EXISTS `$name` USING $ftsType(${databaseDefinition.join(', ')}, tokenize=$ftsTokenizer)$withoutRowidClause'; | |
return 'CREATE VIRTUAL TABLE IF NOT EXISTS `$name` USING $ftsType(${databaseDefinition.join(', ')}, tokenize=$ftsTokenizer)'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ths,next commit will change
floor_annotation/lib/src/fts.dart
Outdated
@@ -0,0 +1,34 @@ | |||
class Fts { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 FTS4 has some additional features that FTS3 doesn't support. Such as setting an external content table to be used by the FTS table. It might make sense to create two separate types: FTS3
and FTS4
as it's done in Room (see links below). We don't have to support all of these additional features initially but having two classes might allow us to be more flexible in the future.
Having two FTS classes also requires some changes to Entity
because it would either need to understand both the FTS3
and FTS4
types or we list FTS out of the Entity
annotation as done in Room. What are your thoughts about this?
https://developer.android.com/reference/androidx/room/Fts3
https://developer.android.com/reference/androidx/room/Fts4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at last time ,i didn't known how to get a new annotation on classElement
i change to code like room now
floor_annotation/lib/src/fts.dart
Outdated
abstract class FtsType { | ||
///FTS3 table in the database | ||
static const fts3 = 'fts3'; | ||
|
||
///FTS4 table in the database | ||
static const fts4 = 'fts4'; | ||
} | ||
|
||
abstract class FtsTokenizer { | ||
///The name of the default | ||
|
||
///The name of the default tokenizer used on FTS tables | ||
static const simple = 'simple'; | ||
|
||
///The name of the tokenizer based on the Porter Stemming Algorithm | ||
static const porter = 'porter'; | ||
|
||
///The name of a tokenizer implemented by the ICU library. | ||
static const icu = 'icu'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 We could use enums here instead of strings to benefit from type safety. We've done this with OnConflictStrategy
as you can see here https://github.com/vitusortner/floor/blob/c5925af0f8ab319cd6e8436143bc4c7aace9b2d1/floor_annotation/lib/src/on_conflict_strategy.dart and here https://github.com/vitusortner/floor/blob/c5925af0f8ab319cd6e8436143bc4c7aace9b2d1/floor_generator/lib/processor/update_method_processor.dart#L72.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes,i will fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After thinking about it, I decided string instead of strings enum,
I don’t know if you will open the bottom-level implementation of database similar to room in the future,like this:
Room.databaseBuilder(...) .openHelperFactory(factory) .build();
in other openHelperFactory may be use custom tokenizer (in android room use wcdb factory can use mmicu tokenizer)
So I decided to use strings to give users better input and provide candidates on ftsTokenizer
why ci/floor-generator fail false but my local is success |
42a7aa7
to
9640a8f
Compare
i change commit for fix for support some you sugguest,now is ok? |
any update for review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was only able to partly review the PR for now. I'll review the rest ASAP.
alread check and fix,please review again |
any update for review again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late reply and thanks for your contribution. This is looking really good. I'll extend the project's documentation so that your contribution is easily discoverable.
Add Fts3 & Fts4 support