Skip to content

Commit

Permalink
Merge pull request #1494 from Raizlabs/develop
Browse files Browse the repository at this point in the history
4.2.2
  • Loading branch information
agrosner authored Dec 18, 2017
2 parents 6eaee99 + 8c6cf3d commit d4bd71b
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 17 deletions.
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.1-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.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)

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.1"
def dbflow_version = "4.2.2"
// 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
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ enum class SQLiteHelper {
private val sNumberMethodList = hashSetOf(TypeName.BYTE, TypeName.DOUBLE, TypeName.FLOAT,
TypeName.LONG, TypeName.SHORT, TypeName.INT)

operator fun get(typeName: TypeName?): SQLiteHelper = sTypeMap[typeName] ?: SQLiteHelper.TEXT
operator fun get(typeName: TypeName?): SQLiteHelper = sTypeMap[typeName]
?: throw IllegalArgumentException("Cannot map $typeName to a SQLite Type. If this is a " +
"TypeConverter, ensure it maps to a primitive type.")

fun getWrapperMethod(typeName: TypeName?): String {
var sqLiteHelper = get(typeName).sqliteStatementWrapperMethod
if (typeName == TypeName.FLOAT.box()) {
sqLiteHelper = "Float";
sqLiteHelper = "Float"
}
return sqLiteHelper;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class SqliteStatementAccessCombiner(combiner: Combiner)
val fieldAccess: CodeBlock = getFieldAccessBlock(this@addCode, modelBlock,
defineProperty = defineProperty)
val wrapperMethod = SQLiteHelper.getWrapperMethod(wrapperFieldTypeName ?: fieldTypeName)
val statementMethod = SQLiteHelper[fieldTypeName].sqLiteStatementMethod
val statementMethod = SQLiteHelper[wrapperFieldTypeName ?: fieldTypeName].sqLiteStatementMethod

var offset = "$index + $columnRepresentation"
if (columnRepresentation.isNullOrEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ object DefinitionUtils {
var statement: String? = null

if (SQLiteHelper.containsType(wrapperTypeName ?: elementTypeName)) {
statement = SQLiteHelper[elementTypeName].toString()
statement = SQLiteHelper[wrapperTypeName ?: elementTypeName].toString()
}

return CodeBlock.builder().add("\$L \$L", QueryBuilder.quote(columnName), statement)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,18 @@ class FeedEntry(@PrimaryKey var id: Int = 0,

@Table(database = TestDatabase::class)
@ManyToMany(
generatedTableClassName = "Refund", referencedTable = Transfer::class,
referencedTableColumnName = "refund_in", thisTableColumnName = "refund_out",
saveForeignKeyModels = true
generatedTableClassName = "Refund", referencedTable = Transfer::class,
referencedTableColumnName = "refund_in", thisTableColumnName = "refund_out",
saveForeignKeyModels = true
)
data class Transfer(@PrimaryKey var transfer_id: UUID = UUID.randomUUID())

@Table(database = TestDatabase::class)
data class Transfer2(
@PrimaryKey
var id: UUID = UUID.randomUUID(),
@ForeignKey(stubbedRelationship = true)
var origin: Account? = null
@PrimaryKey
var id: UUID = UUID.randomUUID(),
@ForeignKey(stubbedRelationship = true)
var origin: Account? = null
)

@Table(database = TestDatabase::class)
Expand All @@ -133,12 +133,12 @@ class SqlListenerModel(@PrimaryKey var id: Int = 0) : SQLiteStatementListener {
}
}

class CustomType(var name: String? = "")
class CustomType(var name: Int? = 0)

class CustomTypeConverter : TypeConverter<String, CustomType>() {
class CustomTypeConverter : TypeConverter<Int, CustomType>() {
override fun getDBValue(model: CustomType?) = model?.name

override fun getModelValue(data: String?) = if (data == null) {
override fun getModelValue(data: Int?) = if (data == null) {
null
} else {
CustomType(data)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.raizlabs.android.dbflow.models

import com.raizlabs.android.dbflow.BaseUnitTest
import com.raizlabs.android.dbflow.kotlinextensions.modelAdapter
import org.junit.Assert.assertEquals
import org.junit.Test

/**
* Description:
*/
class SimpleTestModelsTest : BaseUnitTest() {

@Test
fun validateCreationQuery() {
assertEquals("CREATE TABLE IF NOT EXISTS `TypeConverterModel`(" +
"`id` INTEGER, " +
"`opaqueData` BLOB, " +
"`blob` BLOB, " +
"`customType` INTEGER, " +
"PRIMARY KEY(`id`, `customType`))", modelAdapter<TypeConverterModel>().creationQuery)
}
}
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.1
version=4.2.2
version_code=1
group=com.raizlabs.android
bt_siteUrl=https://github.com/Raizlabs/DBFlow
Expand Down

0 comments on commit d4bd71b

Please sign in to comment.