Skip to content

#40527 Fix false "Invalid column reference" error for UNSIGNED type modifier in CREATE TABLE#40708

Open
dev-miro26 wants to merge 13 commits intodbeaver:develfrom
dev-miro26:dbeaver#40527-fix-unsigned-invalid-column-reference
Open

#40527 Fix false "Invalid column reference" error for UNSIGNED type modifier in CREATE TABLE#40708
dev-miro26 wants to merge 13 commits intodbeaver:develfrom
dev-miro26:dbeaver#40527-fix-unsigned-invalid-column-reference

Conversation

@dev-miro26
Copy link
Copy Markdown
Contributor

@dev-miro26 dev-miro26 commented Apr 6, 2026

Closes: #40527

Summary

  • Fixes false "Invalid column reference" error for MySQL type modifiers like UNSIGNED and ZEROFILL in DDL statements (e.g. CREATE TABLE test (id INT UNSIGNED NOT NULL))
  • Introduces a dedicated typeModifier grammar rule in columnDefinition to accept dialect-specific type modifiers between the data type and constraints
  • Makes DEFAULT keyword mandatory in defaultClause to resolve grammar ambiguity between type modifiers and default value expressions
  • Registers typeModifier in LSMInspections for proper autocompletion and syntax classification

Problem

In the SQL script editor, UNSIGNED is underlined with the error "Invalid column reference" in DDL queries:

CREATE TABLE test_table (
    test_table_id INT UNSIGNED NOT NULL,
    test_name VARCHAR(10) NOT NULL
);

How to test

  1. Connect to a MySQL 8.x database
  2. Open a SQL script editor
  3. Type: CREATE TABLE test_table (test_table_id INT UNSIGNED NOT NULL, test_name VARCHAR(10) NOT NULL);
  4. Verify UNSIGNED is not underlined with "Invalid column reference"
  5. Verify CREATE TABLE test_table (col1 INT DEFAULT 5 NOT NULL); still works correctly (default value recognized)
  6. Verify ALTER TABLE test_table ADD COLUMN col2 BIGINT UNSIGNED NOT NULL; does not show the error

…MKnownRuleNames and refining default value expression logic in SQLQueryColumnSpec.
@dev-miro26
Copy link
Copy Markdown
Contributor Author

@E1izabeth
Could you please review this PR?

Copy link
Copy Markdown
Member

@E1izabeth E1izabeth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've correctly found the root cause of the issue. However, the fix is masking the problem instead of fixing the root cause. So, we can not accept the proposed solution.

@dev-miro26
Copy link
Copy Markdown
Contributor Author

You've correctly found the root cause of the issue. However, the fix is masking the problem instead of fixing the root cause. So, we can not accept the proposed solution.

Let me solve again.

@dev-miro26 dev-miro26 requested a review from E1izabeth April 7, 2026 15:39
Comment on lines +124 to +128
for (STMTreeNode child : node.findChildrenOfName(STMKnownRuleNames.typeModifier)) {
if (typeName != null) {
typeName = typeName + " " + child.getTextContent();
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this change.

  • Are we sure that introducing any amount of actual-identifiers as typeModifier won't effectively consume any not-yet-covered keywords, turning it into nonsense?
  • Having the above, are we sure that type name construction by concatenation with a modifier won't break constraint expression analysis in terms of types?
  • Consider such a line:
    columnName customTypeName someDbSpecificModifiers CHECK (columnName.compositeField < 10)
    Having someDbSpecificModifiers treated as part of the customTypeName will break the composite type lookup and thus break compositeField completion and validation.

The solution I see is to add type modifiers to the dialect and dynamically bring those constants into the grammar. You can take a look at how it's done with knownIdentifierQuotes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update again.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UNSIGNED in DDL show Invalid column reference in sql script editor

2 participants