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

creating an ENUM type, pg-mem throws an unexpected error #443

Open
arbisoft-qaisarirfan opened this issue Feb 25, 2025 · 2 comments
Open

Comments

@arbisoft-qaisarirfan
Copy link

arbisoft-qaisarirfan commented Feb 25, 2025

When running a Sequelize migration that involves creating an ENUM type, pg-mem throws an unexpected error:

Migration failed: Error: 
        at Query.run (/Users/qaisar.irfan/Documents/nestjs-sequelize-pg-mem/node_modules/sequelize/src/dialects/postgres/query.js:76:25)
        at /Users/qaisar.irfan/Documents/nestjs-sequelize-pg-mem/node_modules/sequelize/src/sequelize.js:650:28
        at async Promise.all (index 0)
        at PostgresQueryInterface.ensureEnums (/Users/qaisar.irfan/Documents/nestjs-sequelize-pg-mem/node_modules/sequelize/src/dialects/postgres/query-interface.js:47:21)
        at PostgresQueryInterface.createTable (/Users/qaisar.irfan/Documents/nestjs-sequelize-pg-mem/node_modules/sequelize/src/dialects/abstract/query-interface.js:210:5)
        at Object.up (/Users/qaisar.irfan/Documents/nestjs-sequelize-pg-mem/migrations/20250203115647-create-users.js:9:5)
        at usersMigration (/Users/qaisar.irfan/Documents/nestjs-sequelize-pg-mem/test/test-utils.ts:126:7)
        at Object.<anonymous> (/Users/qaisar.irfan/Documents/nestjs-sequelize-pg-mem/src/user/user.service.spec.ts:32:5) {
      name: 'SequelizeDatabaseError',
      parent: TypeError: Cannot read properties of null (reading 'Symbol()')
            
      *️⃣ Failed SQL statement: SELECT t.typname enum_name, array_agg(e.enumlabel ORDER BY enumsortorder) enum_value FROM pg_type t JOIN pg_enum e ON t.oid = e.enumtypid JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace WHERE n.nspname = 'public' AND t.typname='enum_Users_role' GROUP BY 1;

To Reproduce

Run a Sequelize migration that attempts to create a table with an ENUM column. The error occurs when querying pg_type and pg_enum.

SELECT t.typname enum_name, array_agg(e.enumlabel ORDER BY enumsortorder) enum_value 
FROM pg_type t 
JOIN pg_enum e ON t.oid = e.enumtypid 
JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace 
WHERE n.nspname = 'public' AND t.typname='enum_Users_role' 
GROUP BY 1;

This query fails in pg-mem, but succeeds in a real PostgreSQL database.

pg-mem version

"version": "3.0.5",

Image

@Yahyaali1
Copy link

stuck in same issue 😢

@ali-chishti
Copy link

getting the same issue

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

3 participants