Skip to content

Commit

Permalink
Merge pull request #1498 from Raizlabs/develop
Browse files Browse the repository at this point in the history
4.2.3
  • Loading branch information
agrosner authored Dec 20, 2017
2 parents d4bd71b + 1175f66 commit eb5ed84
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 31 deletions.
7 changes: 2 additions & 5 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

DBFlow Version:
Issue Kind (Bug, Question, Feature):

Please note if you are using Instant Run, there may be bugs where generated classes are not created. Ensure you are using
the [apt](https://bitbucket.org/hvisser/android-apt) or [kapt](http://blog.jetbrains.com/kotlin/2015/06/better-annotation-processing-supporting-stubs-in-kapt/) plugins and that incremental compilation is off.
Bug or Feature Request:

Description:
Description:
4 changes: 2 additions & 2 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.2.2-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.2.3-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 @@ -43,7 +43,7 @@ Add the library to the project-level build.gradle, using the apt plugin to enabl
apply plugin: 'kotlin-kapt' // required for kotlin.
def dbflow_version = "4.2.2"
def dbflow_version = "4.2.3"
// 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)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.7.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,13 +551,13 @@ public Operator<T> concatenate(@Nullable Object value) {
value = typeConverter.getDBValue(value);
}
if (value instanceof String || value instanceof IOperator
|| value instanceof Character) {
|| value instanceof Character) {
operation = String.format("%1s %1s ", operation, Operation.CONCATENATE);
} else if (value instanceof Number) {
operation = String.format("%1s %1s ", operation, Operation.PLUS);
} else {
throw new IllegalArgumentException(
String.format("Cannot concatenate the %1s", value != null ? value.getClass() : "null"));
String.format("Cannot concatenate the %1s", value != null ? value.getClass() : "null"));
}
this.value = value;
isValueSet = true;
Expand Down Expand Up @@ -617,7 +617,8 @@ public String convertObjectToString(Object object, boolean appendInnerParenthesi
converted = convertToDB ? typeConverter.getDBValue(object) : object;
} catch (ClassCastException c) {
// if object type is not valid converted type, just use type as is here.
FlowLog.log(FlowLog.Level.W, c);
FlowLog.log(FlowLog.Level.I, "Value passed to operation is not valid type for TypeConverter in the column. " +
"Preserving value " + object + " to be used as is.");
}
return BaseOperator.convertValueToString(converted, appendInnerParenthesis, false);
} else {
Expand Down Expand Up @@ -792,10 +793,10 @@ public T secondValue() {
@Override
public void appendConditionToQuery(@NonNull QueryBuilder queryBuilder) {
queryBuilder.append(columnName()).append(operation())
.append(convertObjectToString(value(), true))
.appendSpaceSeparated(Operation.AND)
.append(convertObjectToString(secondValue(), true))
.appendSpace().appendOptional(postArgument());
.append(convertObjectToString(value(), true))
.appendSpaceSeparated(Operation.AND)
.append(convertObjectToString(secondValue(), true))
.appendSpace().appendOptional(postArgument());
}

@Override
Expand Down Expand Up @@ -852,7 +853,7 @@ public In<T> and(@Nullable T argument) {
@Override
public void appendConditionToQuery(@NonNull QueryBuilder queryBuilder) {
queryBuilder.append(columnName()).append(operation())
.append("(").append(OperatorGroup.joinArguments(",", inArguments, this)).append(")");
.append("(").append(OperatorGroup.joinArguments(",", inArguments, this)).append(")");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,26 @@ public void setModelAdapter(@NonNull ModelAdapter<TModel> modelAdapter) {

public synchronized boolean save(@NonNull TModel model) {
return save(model, getWritableDatabase(), modelAdapter.getInsertStatement(),
modelAdapter.getUpdateStatement());
modelAdapter.getUpdateStatement());
}

public synchronized boolean save(@NonNull TModel model,
@NonNull DatabaseWrapper wrapper) {
return save(model, wrapper, modelAdapter.getInsertStatement(wrapper),
modelAdapter.getUpdateStatement(wrapper));
public synchronized boolean save(@NonNull TModel model, @NonNull DatabaseWrapper wrapper) {
boolean exists = getModelAdapter().exists(model, wrapper);

if (exists) {
exists = update(model, wrapper);
}

if (!exists) {
exists = insert(model, wrapper) > INSERT_FAILED;
}

if (exists) {
NotifyDistributor.get().notifyModelChanged(model, getModelAdapter(), BaseModel.Action.SAVE);
}

// return successful store into db.
return exists;
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -201,8 +214,8 @@ public synchronized boolean update(@NonNull TModel model,
modelAdapter.saveForeignKeys(model, wrapper);
modelAdapter.bindToContentValues(contentValues, model);
boolean successful = wrapper.updateWithOnConflict(modelAdapter.getTableName(), contentValues,
modelAdapter.getPrimaryConditionClause(model).getQuery(), null,
ConflictAction.getSQLiteDatabaseAlgorithmInt(modelAdapter.getUpdateOnConflictAction())) != 0;
modelAdapter.getPrimaryConditionClause(model).getQuery(), null,
ConflictAction.getSQLiteDatabaseAlgorithmInt(modelAdapter.getUpdateOnConflictAction())) != 0;
if (successful) {
NotifyDistributor.get().notifyModelChanged(model, modelAdapter, BaseModel.Action.UPDATE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.database.sqlite.SQLiteStatement;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.raizlabs.android.dbflow.annotation.PrimaryKey;
import com.raizlabs.android.dbflow.structure.database.DatabaseStatement;
Expand Down Expand Up @@ -211,7 +212,7 @@ void bindToInsertStatement(@NonNull DatabaseStatement sqLiteStatement, @NonNull
* @return The value for the {@link PrimaryKey#autoincrement()}
* if it has the field. This method is overridden when its specified for the {@link TModel}
*/
@NonNull
@Nullable
Number getAutoIncrementingId(@NonNull TModel model);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.ContentValues;
import android.database.sqlite.SQLiteStatement;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.raizlabs.android.dbflow.annotation.ConflictAction;
import com.raizlabs.android.dbflow.annotation.ForeignKey;
Expand Down Expand Up @@ -291,7 +292,7 @@ public void updateAutoIncrement(@NonNull TModel model, @NonNull Number id) {
* @return The value for the {@link PrimaryKey#autoincrement()}
* if it has the field. This method is overridden when its specified for the {@link TModel}
*/
@NonNull
@Nullable
@Override
public Number getAutoIncrementingId(@NonNull TModel model) {
throw new InvalidDBConfiguration(
Expand All @@ -314,11 +315,7 @@ public String getAutoIncrementingColumnName() {

public boolean hasAutoIncrement(TModel model) {
Number id = getAutoIncrementingId(model);
//noinspection ConstantConditions
if (id == null) {
throw new IllegalStateException("An autoincrementing column field cannot be null.");
}
return id.longValue() > 0;
return id != null && id.longValue() > 0;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=4.2.2
version=4.2.3
version_code=1
group=com.raizlabs.android
bt_siteUrl=https://github.com/Raizlabs/DBFlow
Expand Down

0 comments on commit eb5ed84

Please sign in to comment.