Kotlin / anko

Pleasant Android application development
Apache License 2.0
15.89k stars 1.29k forks source link

[SQLite] Support for UNIQUE conflict clauses #353

Closed monxalo closed 4 years ago

monxalo commented 7 years ago

Support for table UNIQUE conflict clauses would be nice, e.g.:

CREATE TABLE table_name
(
  _id INTEGER PRIMARY KEY AUTOINCREMENT,
  record_id INTEGER NOT NULL,
  ...
  , UNIQUE ( record_id ) ON CONFLICT REPLACE
)

ON CONFLICT clause:

jlandrum commented 7 years ago

Isn't this already available?

https://github.com/Kotlin/anko/blob/master/anko/library/static/sqlite/src/sqlTypes.kt

monxalo commented 7 years ago

Yes, UNIQUE is already available. This is to support conflict clauses.

monxalo commented 7 years ago

A simpler version of the example can also be written like so:

CREATE TABLE table_name
(
  _id INTEGER PRIMARY KEY AUTOINCREMENT,
  record_id INTEGER NOT NULL UNIQUE ON CONFLICT REPLACE,
  ...
)