Skip to content

Commit

Permalink
Support for UNIQUE conflict clauses. (Kotlin#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
monxalo authored and yanex committed Jul 31, 2017
1 parent 6d5cbe2 commit 62e4ca4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions anko/library/static/sqlite/src/sqlTypes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ val NOT_NULL: SqlTypeModifier = SqlTypeModifierImpl("NOT NULL")
val AUTOINCREMENT: SqlTypeModifier = SqlTypeModifierImpl("AUTOINCREMENT")
val UNIQUE: SqlTypeModifier = SqlTypeModifierImpl("UNIQUE")

fun UNIQUE(conflictClause: ConflictClause): SqlTypeModifier {
return SqlTypeModifierImpl("UNIQUE ON CONFLICT $conflictClause")
}

enum class ConflictClause {
ROLLBACK,
ABORT,
FAIL,
IGNORE,
REPLACE
}

fun DEFAULT(value: String): SqlTypeModifier = SqlTypeModifierImpl("DEFAULT $value")

private open class SqlTypeImpl(override val name: String, val modifiers: String? = null) : SqlType {
Expand Down

0 comments on commit 62e4ca4

Please sign in to comment.