From 3f10237a7e925b9b1471d55dd9e8cd0add93fd63 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 12 Nov 2025 00:32:42 +0000 Subject: [PATCH] test: add reproduction test for issue #4000 - large INSERT INTO statements Add test case that reproduces the 'syntax error at end of input' bug when parsing large structure.sql files with very long INSERT INTO schema_migrations statements (3000+ entries). This test currently fails with the expected error, confirming the bug reproduction. Refs: #4000 Co-Authored-By: hirotaka.miyagi@route06.co.jp --- .../src/parser/sql/postgresql/index.test.ts | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/frontend/packages/schema/src/parser/sql/postgresql/index.test.ts b/frontend/packages/schema/src/parser/sql/postgresql/index.test.ts index e1a09bb4ac..ba82413072 100644 --- a/frontend/packages/schema/src/parser/sql/postgresql/index.test.ts +++ b/frontend/packages/schema/src/parser/sql/postgresql/index.test.ts @@ -1230,4 +1230,48 @@ CREATE TYPE status AS ENUM ('active', 'inactive'); }) }) }) + + describe('issue #4000: large INSERT INTO statements', () => { + it('should handle very long INSERT INTO schema_migrations statements', async () => { + const migrationCount = 3000 + const migrationValues = [] + for (let i = 1; i <= migrationCount; i++) { + migrationValues.push(`('migration_${i}')`) + } + + const sql = /* sql */ ` + -- Dummy PostgreSQL structure.sql for reproduction + CREATE EXTENSION IF NOT EXISTS "plpgsql" WITH SCHEMA pg_catalog; + + CREATE TABLE public.users ( + id SERIAL PRIMARY KEY, + name VARCHAR(255), + email VARCHAR(255) + ); + + CREATE TABLE public.posts ( + id SERIAL PRIMARY KEY, + user_id INTEGER REFERENCES public.users(id), + title VARCHAR(255), + body TEXT + ); + + -- Insert migrations + INSERT INTO schema_migrations VALUES + ${migrationValues.join(',\n')}; + ` + + const { value, errors } = await processor(sql) + + expect(errors).toEqual([]) + + // Verify that the tables were parsed correctly + expect(value.tables).toHaveProperty('users') + expect(value.tables).toHaveProperty('posts') + expect(value.tables['users']?.columns).toHaveProperty('id') + expect(value.tables['users']?.columns).toHaveProperty('name') + expect(value.tables['users']?.columns).toHaveProperty('email') + expect(value.tables['posts']?.columns).toHaveProperty('user_id') + }) + }) })