Skip to content
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

4.1.0 #1416

Merged
merged 45 commits into from
Aug 27, 2017
Merged

4.1.0 #1416

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c4bc810
Split view and table creation in order to run migration after table c…
dwayne-roadhouse Oct 3, 2016
9b39dd9
Update KotlinSupport.md
agrosner Jul 2, 2016
c20d8b5
Split view and table creation in order to run migration after table c…
dwayne-roadhouse Oct 3, 2016
ba284e8
Merged to latest develop
dwayne-roadhouse Oct 17, 2016
fb16c3b
Merge
dwayne-roadhouse Oct 17, 2016
fe52267
Fix broken IndexMigration
saschpe Nov 20, 2016
441aa08
[models] add ColumnMap annotation to embed objects into current table…
Jul 17, 2017
926115d
[models] add ability to arbitrarily add model classes as @ColumnMap o…
Jul 17, 2017
9bb2602
[database] move in memory to the databasebuilder so it can be dynamic.
Jul 17, 2017
3cde1ba
[database] move database name to builder instead of annotation, so dy…
Jul 17, 2017
aee3fc7
[database] deprecate use of generatedClass separator.
Jul 17, 2017
6315844
[database] simplify and consolidate methods for closing + reopening d…
Jul 17, 2017
3d66aca
[usage] update usage to newest.
Jul 17, 2017
8b46b3a
[tests] format tests and optimize imports. fix all warnings.
Jul 17, 2017
23ffad0
[models] add non null clause for foreign key references.
Jul 17, 2017
745e68d
[processor] if generated annotation is on classpath, put it into gene…
Jul 17, 2017
032923d
Merge pull request #1086 from saschpe/indexmigration
agrosner Jul 17, 2017
d6e52e3
Merge branch 'develop' into feature/split_view_and_table_creation
agrosner Jul 17, 2017
fa2fee7
Merge pull request #1017 from dwaynehoy/feature/split_view_and_table_…
agrosner Jul 17, 2017
624652b
[modelviews] sort by priority here.
Jul 17, 2017
97b6f7e
Merge branch 'develop' of https://github.com/agrosner/DBFlow into dev…
Jul 17, 2017
c54d0cd
[database] restore and deprecate old mechanisms for specifying name a…
Jul 19, 2017
dfdf87e
[processor] remove autoservice competely, replace guava calls with ko…
Jul 19, 2017
d25d217
[warnings] fix two warnings.
Jul 19, 2017
5bb3405
[one to many] auto detect visibility of field and throw compile time …
Jul 19, 2017
b75ba4a
[one to many] better detection of private variable if setter exists, …
Jul 19, 2017
1cb15aa
[builder] add static factory methods to table and flow config for uni…
Jul 20, 2017
7fefc64
[database] better error messages for tables pointing to not registere…
Jul 20, 2017
6c42bf6
[models] add ability for using @ColumnMap inside Views and query models.
Jul 20, 2017
345fa30
[usage] update linked usage version.
Jul 20, 2017
a3f1f77
[models] provide autoincrement model saver for autoincrementing ids t…
Jul 21, 2017
6c75d29
[tests] fix broken instrumentated tests.
Jul 21, 2017
c794f36
[columnmap] add references so you can specify custom names for column…
Jul 21, 2017
5faed0d
[column map] map columns by default to referenced field names. differ…
agrosner Jul 22, 2017
55b462a
[query] rename count() to longValue() to show that long results is ca…
Jul 25, 2017
16a2c04
Merge remote-tracking branch 'origin/develop' into develop
Jul 25, 2017
0865adf
fix to #1401: withTable now works for TypeConvertedProperty
danvwells Aug 12, 2017
8b5337b
[transactions] add transaction wrapper to wrap multiple together.
agrosner Aug 17, 2017
ff84b04
Merge pull request #1402 from danvwells/bugfix/converter-withtable
agrosner Aug 18, 2017
8e693fd
[tools] update tools to latest, building with api 26, new gradle plugin.
agrosner Aug 26, 2017
2ca1a17
[tools] update compile statements into implementation/api dependencies.
agrosner Aug 26, 2017
45b9762
[rx2] update to latest dependency.
agrosner Aug 26, 2017
32dd5e1
[table] turn off automatic creation of tables with a flag. write test…
agrosner Aug 26, 2017
d624e8f
[properties] update property extensions to accept nullable values on …
agrosner Aug 26, 2017
d1be504
[database] restore in memory compatability, but show it as deprecated.
agrosner Aug 27, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![Image](https://github.com/agrosner/DBFlow/blob/develop/dbflow_banner.png?raw=true)

[![JitPack.io](https://img.shields.io/badge/JitPack.io-4.0.5-red.svg?style=flat)](https://jitpack.io/#Raizlabs/DBFlow) [![Android Weekly](http://img.shields.io/badge/Android%20Weekly-%23129-2CB3E5.svg?style=flat)](http://androidweekly.net/issues/issue-129) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-DBFlow-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1134)
[![JitPack.io](https://img.shields.io/badge/JitPack.io-4.1.0-red.svg?style=flat)](https://jitpack.io/#Raizlabs/DBFlow) [![Android Weekly](http://img.shields.io/badge/Android%20Weekly-%23129-2CB3E5.svg?style=flat)](http://androidweekly.net/issues/issue-129) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-DBFlow-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1134)

A robust, powerful, and very simple ORM android database library with **annotation processing**.

Expand Down Expand Up @@ -41,14 +41,18 @@ Add the library to the project-level build.gradle, using the apt plugin to enabl

```groovy

def dbflow_version = "4.0.5"
apply plugin: 'kotlin-kapt' // required for kotlin.

def dbflow_version = "4.1.0"
// or dbflow_version = "develop-SNAPSHOT" for grabbing latest dependency in your project on the develop branch
// or 10-digit short-hash of a specific commit. (Useful for bugs fixed in develop, but not in a release yet)

dependencies {

// if Java use this. If using Kotlin do NOT use this.
annotationProcessor "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}"

// use kapt for kotlin apt if you're a Kotlin user
// Use if Kotlin user.
kapt "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}"

compile "com.github.Raizlabs.DBFlow:dbflow-core:${dbflow_version}"
Expand All @@ -75,10 +79,6 @@ Add the library to the project-level build.gradle, using the apt plugin to enabl

}

// if you're building with Kotlin
kapt {
generateStubs = true
}
```

# Pull Requests
Expand Down
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
buildscript {
ext.kotlin_version = '1.1.3-2'
ext.kotlin_version = '1.1.4-2'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.0.0-beta2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.2'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.7.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
jcenter()
google()
maven { url "https://www.jitpack.io" }
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.raizlabs.android.dbflow.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Description: Maps an arbitrary object and its corresponding fields into a set of columns. It is similar
* to {@link ForeignKey} except it's not represented in the DB hierarchy.
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.FIELD)
public @interface ColumnMap {

/**
* Defines explicit references for a composite {@link ColumnMap} definition.
*
* @return override explicit usage of all fields and provide custom references.
*/
ColumnMapReference[] references() default {};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.raizlabs.android.dbflow.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Description: Allows a {@link ColumnMap} to specify a reference override for its fields. Anything not
* defined here will not be used.
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.FIELD)
public @interface ColumnMapReference {

/**
* @return The local column name that will be referenced in the DB
*/
String columnName();

/**
* @return The column name in the referenced table
*/
String columnMapFieldName();

/**
* @return Specify the {@link NotNull} annotation here and it will get pasted into the reference definition.
*/
NotNull notNull() default @NotNull(onNullConflict = ConflictAction.NONE);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,23 @@
int version();

/**
* @return The name of the DB. Optional as it will default to the class name.
* @deprecated use DatabaseConfig.databaseName() to change the name.
*/
@Deprecated
String name() default "";

/**
* @return Specify the extension of the file name : {fileName}.{extension}. Default is ".db"
* @deprecated use DatabaseConfig.extension() to change the extension.
*/
@Deprecated
String databaseExtension() default "";

/**
* @deprecated use DatabaseConfig.inMemoryBuilder() instead.
*/
@Deprecated
boolean inMemory() default false;

/**
* @return If true, SQLite will throw exceptions when {@link ForeignKey} constraints are not respected.
* Default is false and will not throw exceptions.
Expand All @@ -52,11 +60,6 @@
*/
boolean backupEnabled() default false;

/**
* @return true if you want it to be in-memory, false if not.
*/
boolean inMemory() default false;

/**
* @return Global default insert conflict that can be applied to any table when it leaves
* its {@link ConflictAction} as NONE.
Expand All @@ -72,6 +75,8 @@
/**
* @return Marks all generated classes within this database with this character. For example
* "TestTable" becomes "TestTable$Table" for a "$" separator.
* @deprecated Generated class files will become '_' only in next major release.
*/
@Deprecated
String generatedClassSeparator() default "_";
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@
*/
String foreignKeyColumnName();

/**
* @return Specify the {@link NotNull} annotation here and it will get pasted into the reference definition.
*/
NotNull notNull() default @NotNull(onNullConflict = ConflictAction.NONE);
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ enum Method {
/**
* @return If true, the underlying variable that we use is private, requiring us to provide
* a setter for it.
* @deprecated has no effect on the visibility of the call since we now autodetect visibility.
*/
@Deprecated
boolean isVariablePrivate() default false;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@
*/
boolean assignDefaultValuesFromCursor() default true;

/**
* @return When false, this table gets generated and associated with database, however it will not immediately
* get created upon startup. This is useful for keeping around legacy tables for migrations.
*/
boolean createWithDatabase() default true;

/**
* @return The cache size for this Table.
*/
Expand Down
9 changes: 3 additions & 6 deletions dbflow-kotlinextensions/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,9 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

compile project("${dbflow_project_prefix}dbflow-core")
compile project("${dbflow_project_prefix}dbflow")
api "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
api project("${dbflow_project_prefix}dbflow-core")
api project("${dbflow_project_prefix}dbflow")
}

apply from: '../kotlin-artifacts.gradle'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.raizlabs.android.dbflow.kotlinextensions

import com.raizlabs.android.dbflow.sql.queriable.ModelQueriable
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty


fun <T : Any> oneToMany(query: () -> ModelQueriable<T>) = OneToMany(query)

/**
* Description: Wraps a [OneToMany] annotation getter into a concise property setter.
*/
class OneToMany<T : Any>(private val query: () -> ModelQueriable<T>) : ReadWriteProperty<Any, List<T>?> {

private var list: List<T>? = null

override fun getValue(thisRef: Any, property: KProperty<*>): List<T>? {
if (list?.isEmpty() ?: true) {
list = query().list
}
return list
}

override fun setValue(thisRef: Any, property: KProperty<*>, value: List<T>?) {
list = value
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import com.raizlabs.android.dbflow.sql.language.property.Property
* Description: Provides property methods in via infix functions.
*/

infix fun <T : Any> Property<T>.eq(value: T) = this.eq(value)
infix fun <T : Any> Property<T>.eq(value: T?) = this.eq(value)

infix fun <T : Any> Property<T>.`is`(value: T) = this.`is`(value)
infix fun <T : Any> Property<T>.`is`(value: T?) = this.`is`(value)

infix fun <T : Any> Property<T>.isNot(value: T) = this.isNot(value)
infix fun <T : Any> Property<T>.isNot(value: T?) = this.isNot(value)

infix fun <T : Any> Property<T>.notEq(value: T) = this.notEq(value)
infix fun <T : Any> Property<T>.notEq(value: T?) = this.notEq(value)

infix fun <T : Any> Property<T>.like(value: String) = this.like(value)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,26 @@ package com.raizlabs.android.dbflow.kotlinextensions

import com.raizlabs.android.dbflow.annotation.Collate
import com.raizlabs.android.dbflow.sql.Query
import com.raizlabs.android.dbflow.sql.language.*
import com.raizlabs.android.dbflow.sql.language.BaseModelQueriable
import com.raizlabs.android.dbflow.sql.language.Case
import com.raizlabs.android.dbflow.sql.language.CaseCondition
import com.raizlabs.android.dbflow.sql.language.CompletedTrigger
import com.raizlabs.android.dbflow.sql.language.CursorResult
import com.raizlabs.android.dbflow.sql.language.From
import com.raizlabs.android.dbflow.sql.language.Index
import com.raizlabs.android.dbflow.sql.language.Insert
import com.raizlabs.android.dbflow.sql.language.Join
import com.raizlabs.android.dbflow.sql.language.NameAlias
import com.raizlabs.android.dbflow.sql.language.OrderBy
import com.raizlabs.android.dbflow.sql.language.SQLOperator
import com.raizlabs.android.dbflow.sql.language.SQLite
import com.raizlabs.android.dbflow.sql.language.Select
import com.raizlabs.android.dbflow.sql.language.Set
import com.raizlabs.android.dbflow.sql.language.Transformable
import com.raizlabs.android.dbflow.sql.language.Trigger
import com.raizlabs.android.dbflow.sql.language.TriggerMethod
import com.raizlabs.android.dbflow.sql.language.Update
import com.raizlabs.android.dbflow.sql.language.Where
import com.raizlabs.android.dbflow.sql.language.property.IProperty
import com.raizlabs.android.dbflow.sql.queriable.AsyncQuery
import com.raizlabs.android.dbflow.sql.queriable.ModelQueriable
Expand Down Expand Up @@ -85,6 +103,12 @@ inline val <T : Any> ModelQueriable<T>.result
inline val <T : Any> ModelQueriable<T>.cursorResult
get() = queryResults()

inline val <T : Any> ModelQueriable<T>.flowQueryList
get() = flowQueryList()

inline val <T : Any> ModelQueriable<T>.cursorList
get() = cursorList()

// cursor result extensions
inline fun <reified T : Any> CursorResult<*>.toCustomList() = toCustomList(T::class.java)

Expand All @@ -100,16 +124,16 @@ inline val <T : Any> ModelQueriable<T>.async
get() = async()

infix inline fun <T : Any> AsyncQuery<T>.list(crossinline callback: (QueryTransaction<*>, MutableList<T>) -> Unit)
= queryListResultCallback { queryTransaction, mutableList -> callback(queryTransaction, mutableList) }
.execute()
= queryListResultCallback { queryTransaction, mutableList -> callback(queryTransaction, mutableList) }
.execute()

infix inline fun <T : Any> AsyncQuery<T>.result(crossinline callback: (QueryTransaction<*>, T?) -> Unit)
= querySingleResultCallback { queryTransaction, model -> callback(queryTransaction, model) }
.execute()
= querySingleResultCallback { queryTransaction, model -> callback(queryTransaction, model) }
.execute()

infix inline fun <T : Any> AsyncQuery<T>.cursorResult(crossinline callback: (QueryTransaction<*>, CursorResult<T>) -> Unit)
= queryResultCallback { queryTransaction, cursorResult -> callback(queryTransaction, cursorResult) }
.execute()
= queryResultCallback { queryTransaction, cursorResult -> callback(queryTransaction, cursorResult) }
.execute()

inline val Model.async
get() = async()
Expand Down Expand Up @@ -163,7 +187,7 @@ infix fun <T : Any> Update<T>.set(sqlOperator: SQLOperator) = set(sqlOperator)
inline fun <reified T : Any> delete() = SQLite.delete(T::class.java)

inline fun <reified T : Any> delete(deleteClause: From<T>.() -> BaseModelQueriable<T>)
= deleteClause(SQLite.delete(T::class.java))
= deleteClause(SQLite.delete(T::class.java))

// insert methods

Expand Down
13 changes: 7 additions & 6 deletions dbflow-processor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_1_8

dependencies {
compile project("${dbflow_project_prefix}dbflow-core")
compile 'com.squareup:javapoet:1.8.0'
compile 'com.github.agrosner:KPoet:1.0.0'
compile 'com.google.auto.service:auto-service:1.0-rc2'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
implementation project("${dbflow_project_prefix}dbflow-core")
implementation 'com.squareup:javapoet:1.9.0'
implementation 'com.github.agrosner:KPoet:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"

testCompile 'junit:junit:4.12'
compileOnly 'org.glassfish:javax.annotation:10.0-b28'

testImplementation 'junit:junit:4.12'

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object ClassNames {

val TYPE_CONVERTER = ClassName.get(CONVERTER, "TypeConverter")
val TYPE_CONVERTER_GETTER: ClassName = ClassName.get(PROPERTY_PACKAGE,
"TypeConvertedProperty.TypeConverterGetter")
"TypeConvertedProperty.TypeConverterGetter")

val MIGRATION = ClassName.get(MIGRATION_PACKAGE, "Migration")

Expand Down Expand Up @@ -87,9 +87,13 @@ object ClassNames {
val SQLITE = ClassName.get(LANGUAGE, "SQLite")

val CACHEABLE_LIST_MODEL_SAVER = ClassName.get(SAVEABLE, "CacheableListModelSaver")
val SINGLE_MODEL_SAVER = ClassName.get(SAVEABLE, "ModelSaver")
val AUTOINCREMENT_MODEL_SAVER = ClassName.get(SAVEABLE, "AutoIncrementModelSaver")

val SINGLE_KEY_CACHEABLE_MODEL_LOADER = ClassName.get(QUERIABLE, "SingleKeyCacheableModelLoader")
val SINGLE_KEY_CACHEABLE_LIST_MODEL_LOADER = ClassName.get(QUERIABLE, "SingleKeyCacheableListModelLoader")

val NON_NULL = ClassName.get("android.support.annotation", "NonNull")

val GENERATED = ClassName.get("javax.annotation", "Generated")
}
Loading