@@ -211,18 +211,9 @@ describe('plpgsql-parser', () => {
211211 } ) ;
212212
213213 describe ( 'SELECT INTO statement parsing' , ( ) => {
214- // This test documents a bug in @libpg -query/parser where PL/pgSQL functions
215- // containing SELECT INTO statements fail to parse, causing the function
216- // to not be recognized as a PL/pgSQL function and preventing hydration.
217- //
218- // Bug: parsePlPgSQLSync throws "Unexpected non-whitespace character after JSON"
219- // when the function body contains SELECT INTO statements.
220- //
221- // This causes inconsistent behavior:
222- // - Functions with DELETE/INSERT/UPDATE: parse successfully, get hydrated
223- // - Functions with SELECT INTO: fail to parse, not recognized as PL/pgSQL
224- //
225- // Related issue: https://github.com/pganalyze/libpg_query/issues/XXX
214+ // Regression tests to ensure PL/pgSQL functions containing SELECT INTO
215+ // statements are correctly parsed and hydrated. These tests verify that
216+ // SELECT INTO works consistently with other DML statements like DELETE.
226217
227218 it ( 'should parse function with SELECT INTO statement' , ( ) => {
228219 const selectIntoSql = `
@@ -239,8 +230,6 @@ describe('plpgsql-parser', () => {
239230
240231 const parsed = parse ( selectIntoSql ) ;
241232
242- // This currently fails because @libpg -query/parser cannot parse
243- // PL/pgSQL functions with SELECT INTO statements
244233 expect ( parsed . functions ) . toHaveLength ( 1 ) ;
245234 expect ( parsed . functions [ 0 ] . kind ) . toBe ( 'plpgsql-function' ) ;
246235 expect ( parsed . functions [ 0 ] . plpgsql . hydrated ) . toBeDefined ( ) ;
@@ -261,8 +250,6 @@ describe('plpgsql-parser', () => {
261250
262251 const parsed = parse ( selectIntoSchemaSql ) ;
263252
264- // This currently fails because @libpg -query/parser cannot parse
265- // PL/pgSQL functions with SELECT INTO statements
266253 expect ( parsed . functions ) . toHaveLength ( 1 ) ;
267254 expect ( parsed . functions [ 0 ] . kind ) . toBe ( 'plpgsql-function' ) ;
268255 } ) ;
@@ -283,15 +270,13 @@ describe('plpgsql-parser', () => {
283270 const parsed = parse ( selectIntoSql ) ;
284271 const result = deparseSync ( parsed ) ;
285272
286- // When this works, the deparsed SQL should have consistent quoting
287- // (either all quoted or all unquoted based on QuoteUtils rules)
273+ // Deparsed SQL should have consistent quoting based on QuoteUtils rules
288274 expect ( result ) . toContain ( 'SELECT' ) ;
289275 expect ( result ) . toContain ( 'INTO' ) ;
290276 expect ( result ) . toContain ( 'v_result' ) ;
291277 } ) ;
292278
293- // Contrast: DELETE statements parse correctly
294- it ( 'should parse function with DELETE statement (works correctly)' , ( ) => {
279+ it ( 'should parse function with DELETE statement' , ( ) => {
295280 const deleteSql = `
296281 CREATE FUNCTION delete_data()
297282 RETURNS void
@@ -304,7 +289,6 @@ describe('plpgsql-parser', () => {
304289
305290 const parsed = parse ( deleteSql ) ;
306291
307- // DELETE statements work correctly
308292 expect ( parsed . functions ) . toHaveLength ( 1 ) ;
309293 expect ( parsed . functions [ 0 ] . kind ) . toBe ( 'plpgsql-function' ) ;
310294 expect ( parsed . functions [ 0 ] . plpgsql . hydrated ) . toBeDefined ( ) ;
0 commit comments