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

An invalid constraint causes a TypeError #425

Open
firelizzard18 opened this issue Nov 6, 2024 · 0 comments
Open

An invalid constraint causes a TypeError #425

firelizzard18 opened this issue Nov 6, 2024 · 0 comments

Comments

@firelizzard18
Copy link

Describe the bug

Executing

CREATE TABLE "age_groups" (
  "age_group_id" uuid NOT NULL,
  "title" text NOT NULL,
  "description" text,
  CONSTRAINT "age_groups_pkey" PRIMARY KEY ("age_groups")
);

results in

TypeError: Cannot read properties of undefined (reading 'hash')
      
      💥 This is a nasty error, which was unexpected by pg-mem. Also known "a bug" 😁 Please file an issue !

The issue is here:

pg-mem/src/table.ts

Lines 593 to 598 in 8f84e85

for (const e of expressions) {
const getter = this.selection.getColumn(e.name);
keys.push({
value: getter,
});
}

If the column doesn't exist, getter and therefore keys[I].value is undefined which causes createIndex to fail.

To Reproduce

Execute the query above.

pg-mem version

pg-mem@^3.0.3:
  version "3.0.3"
  resolved "https://registry.yarnpkg.com/pg-mem/-/pg-mem-3.0.3.tgz#0c8862f9bd096a3dcd2addf97e96675fd687a7ad"
  integrity sha512-Bwg8T46AEMjAmqFT5KIuR2ukRE4GzkVSic7U8CAXqlzFr631N9fTGo4JqNgBHrRCT1qR4Nt2bjZA1AL9JhP4uw==
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