Releases: agrosner/DBFlow
Releases · agrosner/DBFlow
5.0.0-alpha2
Many updates!
- NEW
livedata
artifact (consider it experimental). Call.toLiveData
on your wrapper queries when included in the project. - Docs have been revamped, lots of fixes and improvements. Removed all java examples in favor of Kotlin usage
- Gradle files now use kotlin
- Respect order of Primary Key definition in insert statement
- Optimize more code generation
- RX support is bumped to RX3
- Breaking:
Index
wrapperenable
anddisable
have been replaced with their SQL accurate counterpartscreateIfNotExists
anddrop
. - New: DBFLow configure DSL
FlowManager.init(context) {
// this is FlowConfig.Builder
database<AppDatabase> {
// this is DatabaseConfig.Builder
table<MyTable> {
// this is TableConfig.Builder
}
}
// other module dbs
databaseHolder<MyGeneratedDatabaseHolder>()
}
- SQL: adds
random
orderby method - Migrations: support default values in
ALTER
table statement - Migrations: Restore pre 5.0.0-alpha1 migration order where they run after table creation in upgrade of DB.
- Foreign Key Constraints: fix issue where foreign key constraint support not always enabled or done properly. Now we perform it in
onConfigure
of the DB. - NEW:
FTS4
andFTS3
support. - Breaking: Require
DatabaseWrapper
in any db operation, removing model extension methods that are parameterless in most places. to grab DB, usedatabase<MyDatabase> { db ->
orval db = database<MyDatabase>()
- Breaking: Breaking change: String "?" no longer are unescaped and treated as blank INSERT value args. Use Property.WILDCARD instead.
- Model queries that do not run in a transaction now will log as warnings to encourage you to place them in transactions.
- NEW:
TableObserver
provides a way to observe table changes in an efficient way for observable queries. - NEW:
match
operator for queries - NEW: tables can be represented without actually being created in the DB. use
createWithDatabase
in the@Table
or@ModelView
annotations. - Breaking:
IMultiKeyCacheConverter
->MultiKeyCacheConverter
- NEW: create
TEMP
tables support using@Table(temporary = true)
- Breaking: async queries from RX
asFlowable
or others, instead of passingDatabaseWrapper
andModelQueriable
like:
.asFlowable { d, modelQueriable -> modelQueriable.queryList(d) }
Now its the receiver parameter of the function:
.asFlowable { db -> queryList(db) }
- OneToMany: fix issue where cache and one to many would not work when using the all operators.
- FlowQueryList/FlowCursorList: allow passing own
Handler
to be used rather than the thread its created on. - Breaking: its an error to have multiple converters on the same model type. Error message describes how to fix.
- allow overwriting built-ins without error
- better error messaging in general with less noise
- BaseProviderModel: fix potential leaking cursor when no results found.
- SQLCipher: Latest version is now 4.4.2, Write ahead logging support!
- Breaking: prepackaged dbs now can run migrations to get to current version when db version is 0 but we set our db version to something higher. This reduces errors by allowing you to keep an older version of DB as prepackaged but will run through migrations to get to current app version's DB.
Also many bug fixes!
https://github.com/agrosner/DBFlow/milestone/51?closed=1
5.0.0-alpha1
- Rename package name for project to
com.dbflow5
. Some significant package reorganization that makes much more sense going forward. - Project is back under my account! To include, please replace uses of "com.github.raizlabs.dbflow:" to "com.github.agrosner.dbflow:" in project dependencies.
- Added new
paging
,coroutines
,contentprovider
(splits out use into separate module). Expect alivedata
module in next couple releases. Removed RXJava 1 support. - Library is now 100% KOTLIN! (except generated java code, which can't quite yet be Kotlin). All kotlin-extensions modules have rolled into their java counterpart as a single Kotlin unit.
- Simplifications in API for Transactions to eliminate redundancies. Also, now Transaction require a type parameter R which is return value. They now return a value, and have a completion() callback. All interfaces have rolled into Kotlin Typealias to methods.
- All sqlite query language infix (LINQ-style) methods rolled into the query language!
- Attempted to keep java compatibility and nice API. If anything is missing, please file a bug.
save()
now use ainsert or replace
statement rather than a load of the model from the db and then inserting / saving based on that, resulting in significant performance increase.- no more
ContentValues
used at all in any CRUD operations under the hood, and by default these don't get generated:bindToInsertValues
,bindToContentValues
. if you need them, set@Table(generateContentValues = true)
. - Breaking Change: By default
@Table(allFields = true)
, meaning you dont have to explicitly mark each property as part of DB. Previously you had to use@Column
everywhere.
4.2.4
dropTrigger
fromSqlUtils
takes in aDatabaseWrapper
.- Fix broken annotation processor code output tests. #1437
- Fix issues where
DatabaseStatement
in library in wrapper statements were not closed properly. #1497 - Fix issue where single reference (non table object) used wrong name for property in the primary condition clause, causing compile issue. #1504
4.2.3
- update Issue template
- fix pom file generation on jitpack #1487
- fix issue where
save(DatabaseWrapper)
would leave open insert or update statment. #1496 - Allow (but still warn) about autoincrementing ids being null. if null, they are treated as if they are 0 meaning that they will get inserted rather than updated in the DB during a save operation. #1490
- Update warning on wrong type passed in operator class for value #1488
4.2.2
4.2.1
4.2.0
Support for Android O Content Providers.
Simply add this line to your AndroidManifest.xml
:
<provider
android:name="com.raizlabs.android.dbflow.runtime.StubContentProvider"
android:authorities="com.dbflow.authority"/>
Which will allow normal content observing to continue.
It is highly recommended to supply your own authority
: use your own package name. so for com.grosner.example
app I would add:
<provider
android:name="com.raizlabs.android.dbflow.runtime.StubContentProvider"
android:authorities="com.grosner.example"/>
FlowManager.init(FlowConfig.Builder(context)
.addDatabaseConfig(DatabaseConfig.Builder(MyDatabase.class)
.modelNotifier(new ContentResolverNotifier("com.grosner.example"))
.build()).build());
4.1.2
- Autoincrement model saver does not call
saveForeignKeys()
#1454 - Ability to reopen DB without deleting #1449
AutoIncrementModelSaver
causesIllegalArgumentException
since it uses wrong insert statement #1447- Disallow nullable autoincrementing fields. (kotlin nullable (?) and @nullable annotations)
- Can close all DBs at runtime. #1418
- fix support for
byte[]
, class was incorrectly treated as invalid array type. #1463 - Compiled with Kotlin 1.1.51, 26.0.2 of Android build-tools, and 3.0.0-rc2 of Android Gradle plugin.
4.1.1
4.1.0
@ModelView
are now created after migrations are run so latest DB data is respected.- New annotation
@ColumnMap
! It enables embedding other object's exposed properties into the current table as@Column
so that object hierarchy is respected without excessive DB complication.
class Location(var latitude: Double = 0.0, var longitude: Double = 0.0)
@Table(database = TestDatabase::class)
class Position(@PrimaryKey var id: Int = 0, @ColumnMap var location: Location? = null)
creates a table with the following columns:
public static final Property<Integer> id = new Property<Integer>(Position.class, "id");
public static final Property<Double> latitude = new Property<Double>(Position.class, "latitude");
public static final Property<Double> longitude = new Property<Double>(Position.class, "longitude");
- @database(name = , extension = ) are deprecated. Specify the name now in the
DatabaseConfig.databaseName()
whenFlowManager
is initialized. This means that DBFlow supports dynamic database names and instances.
FlowManager.init(FlowConfig.builder()
.addDatabaseConfig(DatabaseConfig.builder(AppDatabase.class)
.databaseName("AppDatabase")
.databaseExtension(".txt")
.build())
.build())
To dynamically swap database out, replace the FlowConfig
:
FlowManager.getDatabase(AppDatabase.class)
.reset(DatabaseConfig.builder(AppDatabase.class)
.databaseName("AppDatabase-2")
.build())
Note that this will overwrite all existing database properties for a database. Any TableConfig
properties missing will get ignored. Also it will delete existing db and reopen with new instance specified.
- @database(inMemory = ) is deprecated. Use the new builder method:
FlowManager.init(FlowConfig.builder()
.addDatabaseConfig(DatabaseConfig.inMemoryBuilder(AppDatabase.class)
.databaseName("AppDatabase")
.build())
.build())
- Support
javax.annotation.Generated
if it's on the classpath. - @database(generatedClassSeparator = ) is now deprecated. It will be standardized to the default
_
in a future breaking release. @OneToMany
now auto-detect visibility of the reference field soisVariablePrivate()
is deprecated.- Can specify
@ForeignKeyReference(notNull = @NotNull())
annotation for individual references. Required to specify allreferences
on a@ForeignKey
if you need to specify for one. - Some better error messaging in the annotation processor so its easier to find solutions to common issues.
- Rename
count()
(deprecated) tolongValue()
so its more clear exactly what is happening. - fix #1401 which enables custom
TypeConverters
to carry into anas()
alias of aProperty
. - Add new
TransactionWrapper
which allows grouping ofITransaction
into one to get executed at same point in db time. - Lib now compiles with SDK 26 with latest build tools including
api
/implementation
of 3.0.0+ gradle plugin. - RXJava2 is now updated to
2.1.3
- Update some methods of
dbflow-kotlin-extensions
to accept nullable values for objects where it makes sense. See commit - Automatic creation of tables can be turned off on a table-by-table basis with
createWithDatabase()
. Useful for preserving scrapped table in previous migrations. - Using Kotlin we can drastically reduce the
@OneToMany
code implementation:
@OneToMany(methods = {OneToMany.Method.ALL}, variableName = "ants")
public List<Ant> getMyAnts() {
if (ants == null || ants.isEmpty()) {
ants = SQLite.select()
.from(Ant.class)
.where(Ant_Table.queen_id.eq(id))
.queryList();
}
return ants;
}
to:
@get:OneToMany(methods = arrayOf(OneToMany.Method.ALL))
var ants by oneToMany { select from Ant::class where (Ant_Table.queen_id.eq(id)) }