Skip to content
Snippets Groups Projects
Commit 783cf542 authored by Bulat Niatshin's avatar Bulat Niatshin Committed by Kirill Yukhin
Browse files

sql: ON CONFLICT works correctly

- ON CONFLICT work checked:
Works correctly (not including ROLLBACK, because sql transactions
are not implemented now)
- Tests for ON CONFLICT implemented
parent 075a28df
No related branches found
No related tags found
No related merge requests found
test_run = require('test_run').new()
---
...
-- Create space
box.sql.execute("CREATE TABLE t (id INTEGER PRIMARY KEY, v INTEGER UNIQUE ON CONFLICT ABORT)")
---
...
box.sql.execute("CREATE TABLE q (id INTEGER PRIMARY KEY, v INTEGER UNIQUE ON CONFLICT FAIL)")
---
...
box.sql.execute("CREATE TABLE p (id INTEGER PRIMARY KEY, v INTEGER UNIQUE ON CONFLICT IGNORE)")
---
...
box.sql.execute("CREATE TABLE e (id INTEGER PRIMARY KEY, v INTEGER NOT NULL ON CONFLICT REPLACE DEFAULT 1337)")
---
...
-- Insert values and select them
box.sql.execute("INSERT INTO t values (1, 1), (2, 2), (3, 1)")
---
- error: 'UNIQUE constraint failed: t.v'
...
box.sql.execute("SELECT * FROM t")
---
- - [1, 1]
- [2, 2]
...
box.sql.execute("INSERT INTO q values (1, 1), (2, 2), (3, 1)")
---
- error: 'UNIQUE constraint failed: q.v'
...
box.sql.execute("SELECT * FROM q")
---
- - [1, 1]
- [2, 2]
...
box.sql.execute("INSERT INTO p values (1, 1), (2, 2), (3, 1), (4, 5)")
---
...
box.sql.execute("SELECT * FROM p")
---
- - [1, 1]
- [2, 2]
- [4, 5]
...
box.sql.execute("INSERT INTO e values (1, 1), (2, 2), (3, 1)")
---
...
box.sql.execute("SELECT * FROM e")
---
- - [1, 1]
- [2, 2]
- [3, 1]
...
test_run = require('test_run').new()
-- Create space
box.sql.execute("CREATE TABLE t (id INTEGER PRIMARY KEY, v INTEGER UNIQUE ON CONFLICT ABORT)")
box.sql.execute("CREATE TABLE q (id INTEGER PRIMARY KEY, v INTEGER UNIQUE ON CONFLICT FAIL)")
box.sql.execute("CREATE TABLE p (id INTEGER PRIMARY KEY, v INTEGER UNIQUE ON CONFLICT IGNORE)")
box.sql.execute("CREATE TABLE e (id INTEGER PRIMARY KEY, v INTEGER NOT NULL ON CONFLICT REPLACE DEFAULT 1337)")
-- Insert values and select them
box.sql.execute("INSERT INTO t values (1, 1), (2, 2), (3, 1)")
box.sql.execute("SELECT * FROM t")
box.sql.execute("INSERT INTO q values (1, 1), (2, 2), (3, 1)")
box.sql.execute("SELECT * FROM q")
box.sql.execute("INSERT INTO p values (1, 1), (2, 2), (3, 1), (4, 5)")
box.sql.execute("SELECT * FROM p")
box.sql.execute("INSERT INTO e values (1, 1), (2, 2), (3, 1)")
box.sql.execute("SELECT * FROM e")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment