Skip to content
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

Deparse error with ON CONFLICT DO NOTHING #128

Open
ChrisJohnNewton opened this issue Dec 21, 2024 · 0 comments
Open

Deparse error with ON CONFLICT DO NOTHING #128

ChrisJohnNewton opened this issue Dec 21, 2024 · 0 comments

Comments

@ChrisJohnNewton
Copy link

ChrisJohnNewton commented Dec 21, 2024

I received this error stack trace while deparsing the following SQL:

INSERT INTO
  public.people (id, name, epithet, is_great, gender, type_id, date_of_birth, date_of_death, place_of_birth, place_of_death, biography, canonical_status_id, image_url, source_url)
VALUES
  (1, 'Asterius', 'of Amasea', FALSE, 'M', 1, '0350-01-01', '0410-01-01', 'Cappadocia', 'Amasea', NULL, 1, NULL, NULL),
  (2, 'Ausonius', NULL, FALSE, 'M', 1, '0310-01-01', '0395-01-01', 'Burdigala', NULL, NULL, NULL, NULL, NULL)
ON CONFLICT DO NOTHING;
/Users/chris/Documents/catholica/node_modules/pgsql-deparser/main/deparser.js:1231
            if (clause.infer.indexElems) {
                             ^

TypeError: Cannot read properties of undefined (reading 'indexElems')
    at Deparser.InsertStmt (/Users/chris/Documents/catholica/node_modules/pgsql-deparser/main/deparser.js:1231:30)
    at Deparser.deparse (/Users/chris/Documents/catholica/node_modules/pgsql-deparser/main/deparser.js:281:26)
    at Deparser.RawStmt (/Users/chris/Documents/catholica/node_modules/pgsql-deparser/main/deparser.js:285:25)
    at Deparser.deparse (/Users/chris/Documents/catholica/node_modules/pgsql-deparser/main/deparser.js:281:26)
    at /Users/chris/Documents/catholica/node_modules/pgsql-deparser/main/deparser.js:161:33
    at Array.map (<anonymous>)
    at Deparser.deparseQuery (/Users/chris/Documents/catholica/node_modules/pgsql-deparser/main/deparser.js:161:14)
    at deparse (/Users/chris/Documents/catholica/node_modules/pgsql-deparser/main/deparser.js:146:42)
    at file:///Users/chris/Documents/catholica/database/seeders/seed.js:28:19

Line 1231
image

It doesn't seem to like the ON CONFLICT DO NOTHING and clause has no infer property. I've fixed it locally with an optional chain after infer for both the if (line 1231) and else if (line 1236).
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant