-
Notifications
You must be signed in to change notification settings - Fork 51
Description
Describe the bug**
If a table has an index with an expression in , such as
CREATE INDEX ix_test ON index_test (( CASE WHEN flag THEN value1 ELSE value2 END ));
The code fails to parse it giving the error that it "follows an unexpected structure".
If you use "WithNoConcurrentIndexOps()" it bypasses the failing parsing for the creation of an index, but this does not work if the index already exists and you are trying to create a diff
Expected behaviour**
- An index creation with an expression in it should not cause this library to fail
- A modification to a database with an expression with an expression in should not cause this library to fail
To Reproduce
Some code to reproduce both occurrences of the issue can be found here: https://github.com/MatthewVallins/pg_schema_diff_idx_failure
Context
I believe the issue is due to regex parsing of the index with the pattern ^(CREATE (UNIQUE )?INDEX )(.*)$"
This doesn't work however for these more complex indexes as it does not capture the new line in them and fails.
Adding (?s) to enable dotall mode (?s)^(CREATE (UNIQUE )?INDEX )(.*)$ should resolve it