dbeaver / dbeaver/dbeaver

Problem (error) with composite foreign key

Open
#15,485 1 comment 0 reactions 0 assignees View on GitHub
x:sqlite xf:metadata
Dominant language
Java
Stars
51.8k
Forks
4.4k
Avg merge
3d 8h
Merged PRs (30d)
188

Description

**System information:**
_- Operating system (distribution) and version:_ **Microsoft Windows [Version 10.0.19043.1526]**
_- DBeaver version:_ **Version 21.3.4.202202051448**
_- Additional extensions:_ **No extensions**

**Connection specification:**
_- Database name and version:_ **SQLite [3.36.0]**
_- Driver name:_ **SQLite [3.36.0]**
_- Do you use tunnels or proxies (SSH, SOCKS, etc)?:_ **No**

**Describe the problem you're observing:**
1) SQL ( Sqlite3 file: [temp.zip](https://github.com/dbeaver/dbeaver/files/8060238/temp.zip) ):
```sql
PRAGMA foreign_keys = off;
BEGIN TRANSACTION;

-- Table: test_123_FK
DROP TABLE IF EXISTS test_123_FK;
CREATE TABLE test_123_FK (id_1_FK INTEGER NOT NULL UNIQUE, id_2_FK INTEGER NOT NULL UNIQUE, id_3_FK INTEGER UNIQUE NOT NULL, FOREIGN KEY (id_1_FK, id_2_FK) REFERENCES test_12_PK (id_1_PK, id_2_PK), FOREIGN KEY (id_2_FK, id_3_FK) REFERENCES test_23_PK (id_2_PK, id_3_PK));

-- Table: test_12_PK
DROP TABLE IF EXISTS test_12_PK;
CREATE TABLE test_12_PK (id_1_PK INTEGER NOT NULL UNIQUE, id_2_PK INTEGER NOT NULL UNIQUE, PRIMARY KEY (id_1_PK, id_2_PK));

-- Table: test_23_PK
DROP TABLE IF EXISTS test_23_PK;
CREATE TABLE test_23_PK (id_2_PK INTEGER NOT NULL UNIQUE, id_3_PK INTEGER NOT NULL UNIQUE, PRIMARY KEY (id_2_PK, id_3_PK));

COMMIT TRANSACTION;
PRAGMA foreign_keys = on;
```
**Problem:**
![image](https://user-images.githubusercontent.com/88368163/153855010-1a6d0646-077d-49c6-baa7-3ecbfeae334f.png)

**Correct**
![image](https://user-images.githubusercontent.com/88368163/153855749-e632d486-0e4f-4d4d-aab7-d4a1a26e1b73.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.