fix: treat SELECT ... INTO as a modification#95
Open
rathboma wants to merge 1 commit into
Open
Conversation
`SELECT ... INTO target` creates and populates a new table, so it modifies the database. The parser reported executionType `LISTING` for it because the statement type is `SELECT`. Flag any `SELECT` statement that contains an `INTO` clause as `MODIFICATION` for the dialects where `SELECT INTO` builds a table (generic, mssql, psql). Oracle and MySQL use `SELECT INTO` to assign variables, so they keep the `LISTING` classification. Closes #81
MasterOdin
reviewed
May 27, 2026
Comment on lines
+117
to
+121
| it('should still identify a plain "SELECT" as a listing', () => { | ||
| const actual = identify('SELECT * FROM Persons'); | ||
|
|
||
| expect(actual[0].executionType).to.eql('LISTING'); | ||
| }); |
Member
There was a problem hiding this comment.
I don't think we need this test as it's adequately covered by a bunch of other tests, if not explicitly so.
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.
Problem
identify("SELECT * INTO public.\"MyTable1\" FROM public.\"MyTable2\"")reportsexecutionType: "LISTING", butSELECT ... INTOcreates and populates a new table — it modifies the database.The parser derives
executionTypepurely from the statement type, andSELECTmaps toLISTING.Fixes #81.
Fix
When a
SELECTstatement contains anINTOclause, set itsexecutionTypetoMODIFICATION. This is gated to the dialects whereSELECT INTObuilds a table —generic,mssql,psql. Oracle and MySQL useSELECT INTOto assign values to variables rather than create a table, so they keep theLISTINGclassification (and the existing Oracle PL/SQL block tests are unaffected).Tests
Added a
SELECT ... INTOdescribe block totest/identifier/single-statement.spec.ts:SELECT ... INTO→MODIFICATION(generic — the exact case fromSELECT INTOstatementexecutionTypeisLISTING#81)SELECT ... INTO→MODIFICATION(mssql)SELECT ... INTO→MODIFICATION(psql)SELECTstill resolves toLISTINGSELECT ... INTO(variable assignment) staysLISTINGThe three
MODIFICATIONassertions fail without the parser change; the full suite passes with it.