diff --git a/app/src/main/java/com/todoroo/andlib/data/Table.kt b/app/src/main/java/com/todoroo/andlib/data/Table.kt
index db5b4e48e..1a6f14bd6 100644
--- a/app/src/main/java/com/todoroo/andlib/data/Table.kt
+++ b/app/src/main/java/com/todoroo/andlib/data/Table.kt
@@ -2,7 +2,7 @@ package com.todoroo.andlib.data
import com.todoroo.andlib.sql.DBObject
-class Table private constructor(private val name: String, alias: String?) : DBObject
(name) {
+class Table private constructor(private val name: String, alias: String?) : DBObject(name) {
constructor(name: String) : this(name, null)
diff --git a/app/src/main/java/com/todoroo/andlib/sql/DBObject.kt b/app/src/main/java/com/todoroo/andlib/sql/DBObject.kt
index 03c830f6d..d3f652428 100644
--- a/app/src/main/java/com/todoroo/andlib/sql/DBObject.kt
+++ b/app/src/main/java/com/todoroo/andlib/sql/DBObject.kt
@@ -2,18 +2,10 @@ package com.todoroo.andlib.sql
import java.util.*
-abstract class DBObject> internal constructor(val expression: String) : Cloneable {
+abstract class DBObject internal constructor(val expression: String) : Cloneable {
var alias: String? = null
- open fun `as`(newAlias: String): T {
- return try {
- val clone = clone() as T
- clone.alias = newAlias
- clone
- } catch (e: CloneNotSupportedException) {
- throw RuntimeException(e)
- }
- }
+ abstract fun `as`(newAlias: String): DBObject
protected fun hasAlias() = alias != null
@@ -21,7 +13,7 @@ abstract class DBObject> internal constructor(val expression: St
if (this === other) {
return true
}
- if (other !is DBObject<*>) {
+ if (other !is DBObject) {
return false
}
return expression == other.expression && alias == other.alias
diff --git a/app/src/main/java/com/todoroo/andlib/sql/Field.kt b/app/src/main/java/com/todoroo/andlib/sql/Field.kt
index dd426c0e5..615b58fd1 100644
--- a/app/src/main/java/com/todoroo/andlib/sql/Field.kt
+++ b/app/src/main/java/com/todoroo/andlib/sql/Field.kt
@@ -1,12 +1,22 @@
package com.todoroo.andlib.sql
-open class Field(expression: String) : DBObject(expression) {
+open class Field(expression: String) : DBObject(expression) {
fun eq(value: Any?): Criterion = if (value == null) {
UnaryCriterion.isNull(this)
} else {
UnaryCriterion.eq(this, value)
}
+ override fun `as`(newAlias: String): Field {
+ return try {
+ val clone = clone() as Field
+ clone.alias = newAlias
+ clone
+ } catch (e: CloneNotSupportedException) {
+ throw RuntimeException(e)
+ }
+ }
+
fun gt(value: Any?): Criterion = UnaryCriterion.gt(this, value)
fun gte(value: Any?): Criterion = UnaryCriterion.gte(this, value)