-
Notifications
You must be signed in to change notification settings - Fork 30
fix: view array operator #89
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| CREATE OR REPLACE VIEW test_array_operators AS | ||
| SELECT | ||
| id, | ||
| value, | ||
| CASE WHEN value IN (10, 20, 30) THEN 'matched' ELSE 'not_matched' END AS equal_any_test, | ||
| CASE WHEN value > ANY (ARRAY[10, 20, 30]) THEN 'high' ELSE 'low' END AS greater_any_test, | ||
| CASE WHEN value < ANY (ARRAY[5, 15, 25]) THEN 'found_lower' ELSE 'all_higher' END AS less_any_test, | ||
| CASE WHEN priority <> ANY (ARRAY[1, 2, 3]) THEN 'different' ELSE 'same' END AS not_equal_any_test | ||
| FROM test_data; |
21 changes: 21 additions & 0 deletions
21
testdata/diff/create_view/add_view_array_operators/new.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| CREATE TABLE public.test_data ( | ||
| id SERIAL PRIMARY KEY, | ||
| value INTEGER, | ||
| priority INTEGER | ||
| ); | ||
|
|
||
| -- View with various array operators to test ScalarArrayOpExpr formatting | ||
| -- The fix ensures that: | ||
| -- 1. Only "= ANY" is converted to "IN" syntax | ||
| -- 2. Other operators (>, <, <>) preserve "ANY" syntax | ||
| CREATE VIEW public.test_array_operators AS | ||
| SELECT | ||
| id, | ||
| value, | ||
| -- This SHOULD be converted to IN syntax (= ANY -> IN) | ||
| CASE WHEN value = ANY(ARRAY[10, 20, 30]) THEN 'matched' ELSE 'not_matched' END AS equal_any_test, | ||
| -- These should NOT be converted to IN syntax - they must preserve ANY | ||
| CASE WHEN value > ANY(ARRAY[10, 20, 30]) THEN 'high' ELSE 'low' END AS greater_any_test, | ||
| CASE WHEN value < ANY(ARRAY[5, 15, 25]) THEN 'found_lower' ELSE 'all_higher' END AS less_any_test, | ||
| CASE WHEN priority <> ANY(ARRAY[1, 2, 3]) THEN 'different' ELSE 'same' END AS not_equal_any_test | ||
| FROM test_data; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| CREATE TABLE public.test_data ( | ||
| id SERIAL PRIMARY KEY, | ||
| value INTEGER, | ||
| priority INTEGER | ||
| ); |
20 changes: 20 additions & 0 deletions
20
testdata/diff/create_view/add_view_array_operators/plan.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "version": "1.0.0", | ||
| "pgschema_version": "1.4.0", | ||
| "created_at": "1970-01-01T00:00:00Z", | ||
| "source_fingerprint": { | ||
| "hash": "423516aca5eb1f6a8f040d2cf4f1dee6e0dc441f91fc54489812bcdedb29bc28" | ||
| }, | ||
| "groups": [ | ||
| { | ||
| "steps": [ | ||
| { | ||
| "sql": "CREATE OR REPLACE VIEW test_array_operators AS\n SELECT\n id,\n value,\n CASE WHEN value IN (10, 20, 30) THEN 'matched' ELSE 'not_matched' END AS equal_any_test,\n CASE WHEN value > ANY (ARRAY[10, 20, 30]) THEN 'high' ELSE 'low' END AS greater_any_test,\n CASE WHEN value < ANY (ARRAY[5, 15, 25]) THEN 'found_lower' ELSE 'all_higher' END AS less_any_test,\n CASE WHEN priority <> ANY (ARRAY[1, 2, 3]) THEN 'different' ELSE 'same' END AS not_equal_any_test\n FROM test_data;", | ||
| "type": "view", | ||
| "operation": "create", | ||
| "path": "public.test_array_operators" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| CREATE OR REPLACE VIEW test_array_operators AS | ||
| SELECT | ||
| id, | ||
| value, | ||
| CASE WHEN value IN (10, 20, 30) THEN 'matched' ELSE 'not_matched' END AS equal_any_test, | ||
| CASE WHEN value > ANY (ARRAY[10, 20, 30]) THEN 'high' ELSE 'low' END AS greater_any_test, | ||
| CASE WHEN value < ANY (ARRAY[5, 15, 25]) THEN 'found_lower' ELSE 'all_higher' END AS less_any_test, | ||
| CASE WHEN priority <> ANY (ARRAY[1, 2, 3]) THEN 'different' ELSE 'same' END AS not_equal_any_test | ||
| FROM test_data; |
20 changes: 20 additions & 0 deletions
20
testdata/diff/create_view/add_view_array_operators/plan.txt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| Plan: 1 to add. | ||
|
|
||
| Summary by type: | ||
| views: 1 to add | ||
|
|
||
| Views: | ||
| + test_array_operators | ||
|
|
||
| DDL to be executed: | ||
| -------------------------------------------------- | ||
|
|
||
| CREATE OR REPLACE VIEW test_array_operators AS | ||
| SELECT | ||
| id, | ||
| value, | ||
| CASE WHEN value IN (10, 20, 30) THEN 'matched' ELSE 'not_matched' END AS equal_any_test, | ||
| CASE WHEN value > ANY (ARRAY[10, 20, 30]) THEN 'high' ELSE 'low' END AS greater_any_test, | ||
| CASE WHEN value < ANY (ARRAY[5, 15, 25]) THEN 'found_lower' ELSE 'all_higher' END AS less_any_test, | ||
| CASE WHEN priority <> ANY (ARRAY[1, 2, 3]) THEN 'different' ELSE 'same' END AS not_equal_any_test | ||
| FROM test_data; |
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.
Uh oh!
There was an error while loading. Please reload this page.