Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unique index cannot have indexed expression? #4986

Open
phidrho opened this issue May 14, 2024 · 1 comment
Open

Unique index cannot have indexed expression? #4986

phidrho opened this issue May 14, 2024 · 1 comment

Comments

@phidrho
Copy link

phidrho commented May 14, 2024

Details

Hi,

when I open Create index dialog and try to create Unique index using expression I get notification that "Unique index cannot have indexed expression...", see picture below:

notification

I searched through official SQLite3 documentation, but could not find this information that it's not allowed.

In Create Index documenation page, there is a note on indexes with expressions:

Expressions in an index may not reference other tables and may not use subqueries nor functions whose result might change (ex: random() or sqlite_version()). Expressions in an index may only refer to columns in the table that is being indexed. Indexes on expression will not work with versions of SQLite prior to version 3.9.0 (2015-10-14). See the Indexes On Expressions document for additional information about using general expressions in CREATE INDEX statements.

As noted above, only specific expressions are not allowed, not all expressions.

Under Indexes On Expressions documentation there is a sentence which refers to UNIQUE constraint within CREATE TABLE statement, not within CREATE INDEX:

Expressions may only be used in CREATE INDEX statements, not within UNIQUE or PRIMARY KEY constraints within the CREATE TABLE statement.

Am I missing something?

Operating system

Win 10

SQLiteStudio version

3.4.4

@pawelsalawa
Copy link
Owner

I'm not entirely sure why this was implemented, but it is likely, that the last mentioned precondition was misinterpreted by me at the time of implementation.

Note for bugfix implementation:

Function that needs fixing is IndexDialog::updateValidation() in https://github.com/pawelsalawa/sqlitestudio/blob/master/SQLiteStudio3/guiSQLiteStudio/dialogs/indexdialog.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants