Repository navigation
dialect(postgresql, mssql, sqlite), metadata(mssql): partial indexes - #90
Merged
Merged
Conversation
An index over the rows of a condition could not be written: the dialect API had no WHERE for an index, so a model that holds one could only leave it out, as a unique one written without its condition would hold for more rows than intended. DdlGenerator gains createIndex(name, table, columns, unique, condition, ifNotExists), which writes CREATE [UNIQUE] INDEX ... WHERE condition, and supportsFilteredIndexes(), false by default. Without a condition it writes the plain index of every dialect; with one it is empty where the database has no partial indexes. PostgreSQL and SQL Server write the condition as given, and SQLite from 3.8.0. Oracle, MySQL, MariaDB, H2, DuckDB (which rejects the WHERE as not implemented), Derby, ClickHouse, Hive, Impala and the ANSI dialect have none. The SQL Server provider reported a filtered index without its condition; it now reads sys.indexes.filter_definition. PostgreSQL's read it already. The consistency tests check the statements of every dialect. On PostgreSQL, SQL Server and SQLite a unique partial index is created, holds among the rows of its condition only, and is read back with its condition where a metadata provider reads indexes. The metadata contract creates one where the database has them and expects the provider to give its condition. Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An index over the rows of a condition could not be written: the dialect API had no
WHEREfor an index, so a model that holds one could only leave it out, as a unique one written without its condition would hold for more rows than intended.What changes
DdlGeneratorgains:Optional<String> createIndex(String indexName, TableReference table, List<String> columnNames, boolean unique, String condition, boolean ifNotExists), which writesCREATE [UNIQUE] INDEX ... WHERE condition. Without a condition it writes the plain index of every dialect; with one it is empty where the database has no partial indexes.boolean supportsFilteredIndexes(), false by default.WHEREas not implementedThe SQL Server metadata provider reported a filtered index without its condition; it now reads
sys.indexes.filter_definition. PostgreSQL's read it already.Tests
The consistency tests check the statements of every dialect. On PostgreSQL, SQL Server and SQLite a unique partial index is created, holds among the rows of its condition only, and is read back with its condition where a metadata provider reads indexes. The metadata contract creates one where the database has them and expects the provider to give its condition.