Skip to content

Mysql: initialization fails when constraint doubled by unique key #172

@turishev

Description

@turishev

Describe the bug

We have a table in a our project like this:

CREATE TABLE IF NOT EXISTS some_table (
  id int unsigned NOT NULL AUTO_INCREMENT,
  ref_to_other_table_id int NOT NULL,
  PRIMARY KEY (id),
  UNIQUE KEY FK_other_table_id (ref_to_other_table_id),
  CONSTRAINT FK_other_table_id FOREIGN KEY (ref_to_other_table_id) REFERENCES other_table (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

This declaration is stupid, but is based on real case that must be fixed soon.

As a result, when trying to connect to DB, we get the following error:

[Trace - 03:15:17 ] Sending request 'workspace/executeCommand - (9)'.
Params: {
  "command": "switchConnections",
  "arguments": [
    "1"
  ]
}
[Trace - 03:15:17 ] Received response 'workspace/executeCommand - (9)' in 121ms.
Result: {
  "code": 0,
  "message": "sql: Scan error on column index 4, name \"REFERENCED_COLUMN_NAME\": converting NULL to string is unsupported"
}

As result, the completion of table names and field names doesn't work.

Versions

sqls version Version:0.2.28, Revision:HEAD
mysql Ver 8.4.4 for Linux on x86_64 (MySQL Community Server - GPL)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions