Comments (6)
hi @shahednasser - it looks like it is being handled :)
from medusa.
Hello! Can you share the code snippet that's causing the error to occur?
from medusa.
hi @shahednasser - thank you for your response. To be honest, I am not sure which part of my code executes it as there are these workflows, steps etc.
To reproduce this issue, it is enough to just follow the instruction here: https://docs.medusajs.com/v2/resources/recipes/digital-products/examples/standard, but instead of having hasMany
just go with hasOne
in digitalProduct
.
from medusa.
Can you share the point in the recipe where you started running into this error? Also can you share the full error message?
from medusa.
Regarding recipe - when we have creation of data models here: https://docs.medusajs.com/v2/resources/recipes/digital-products/examples/standard#create-data-models it is enough to change
medias: model.hasMany(() => DigitalProductMedia, {
mappedBy: "digitalProduct",
}),
to
```ts
medias: model.hasOne(() => DigitalProductMedia, {
mappedBy: "digitalProduct",
}),
This of course causes that in a lot of places the update is needed, but after alignments, it is impossible to add digital product via UI.
Here is the full error (I just change digital_product_medias
to digital_product_reference
as mentioned in the first message):
error: insert into "public"."digital_product_reference" ("id", "type", "licence_key", "digital_product_id", "created_at", "updated_at") values ('01J67TCZJTPXFGM22Y9VFWEXJ3', 'licence_key', 'LICENCE_KEY-123', '01J67TCZJTPQB9YWGTSZ73VP1Q', '2024-08-26T17:05:38.907Z', '2024-08-26T17:05:38.907Z', '01J67TCZJTPQB9YWGTSZ73VP1Q') returning "id", "created_at", "updated_at" - INSERT has more expressions than target columns
{
message: `insert into "public"."digital_product_reference" ("id", "type", "licence_key", "digital_product_id", "created_at", "updated_at") values ('01J67TCZJTPXFGM22Y9VFWEXJ3', 'licence_key', 'LICENCE_KEY-123', '01J67TCZJTPQB9YWGTSZ73VP1Q', '2024-08-26T17:05:38.907Z', '2024-08-26T17:05:38.907Z', '01J67TCZJTPQB9YWGTSZ73VP1Q') returning "id", "created_at", "updated_at" - INSERT has more expressions than target columns`,
name: 'SyntaxErrorException',
stack: `SyntaxErrorException: insert into "public"."digital_product_reference" ("id", "type", "licence_key", "digital_product_id", "created_at", "updated_at") values ('01J67TCZJTPXFGM22Y9VFWEXJ3', 'licence_key', 'LICENCE_KEY-123', '01J67TCZJTPQB9YWGTSZ73VP1Q', '2024-08-26T17:05:38.907Z', '2024-08-26T17:05:38.907Z', '01J67TCZJTPQB9YWGTSZ73VP1Q') returning "id", "created_at", "updated_at" - INSERT has more expressions than target columns\n` +
' at PostgreSqlExceptionConverter.convertException (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@mikro-orm/postgresql/PostgreSqlExceptionConverter.js:32:24)\n' +
' at PostgreSqlDriver.convertException (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@mikro-orm/core/drivers/DatabaseDriver.js:201:54)\n' +
' at /home/ubuntu/rsc/medusa/app-medusa/node_modules/@mikro-orm/core/drivers/DatabaseDriver.js:205:24\n' +
' at processTicksAndRejections (node:internal/process/task_queues:95:5)\n' +
' at async PostgreSqlDriver.nativeInsertMany (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@mikro-orm/knex/AbstractSqlDriver.js:302:21)\n' +
' at async ChangeSetPersister.persistNewEntity (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@mikro-orm/core/unit-of-work/ChangeSetPersister.js:88:21)\n' +
' at async ChangeSetPersister.executeInserts (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@mikro-orm/core/unit-of-work/ChangeSetPersister.js:32:13)\n' +
' at async ChangeSetPersister.runForEachSchema (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@mikro-orm/core/unit-of-work/ChangeSetPersister.js:71:13)\n' +
' at async UnitOfWork.commitCreateChangeSets (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@mikro-orm/core/unit-of-work/UnitOfWork.js:741:9)\n' +
' at async UnitOfWork.persistToDatabase (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@mikro-orm/core/unit-of-work/UnitOfWork.js:705:13)\n' +
' at async UnitOfWork.doCommit (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@mikro-orm/core/unit-of-work/UnitOfWork.js:301:17)\n' +
' at async UnitOfWork.commit (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@mikro-orm/core/unit-of-work/UnitOfWork.js:268:13)\n' +
' at async SqlEntityManager.flush (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@mikro-orm/core/EntityManager.js:1122:9)\n' +
' at async fork.getConnection.transactional (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@mikro-orm/core/EntityManager.js:775:17)\n' +
' at async PostgreSqlConnection.transactional (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@mikro-orm/knex/AbstractSqlConnection.js:36:25)\n' +
' at async transactionWrapper (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@medusajs/utils/src/dal/utils.ts:32:10)\n' +
' at async MikroOrmAbstractBaseRepository_.transaction (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@medusajs/utils/src/dal/mikro-orm/mikro-orm-repository.ts:74:12)\n' +
' at async AbstractService_.descriptor.value (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@medusajs/utils/src/modules-sdk/decorators/inject-transaction-manager.ts:44:14)\n' +
' at async DigitalProductModuleService.methodImplementation (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@medusajs/utils/src/modules-sdk/medusa-service.ts:194:26)\n' +
' at async Proxy.<anonymous> (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@medusajs/orchestration/src/workflow/local-workflow.ts:124:20)\n' +
' at async Object.async.digital_product.digital_product (/home/ubuntu/rsc/medusa/app-medusa/src/workflows/create-digital-product/steps/create-digital-product.ts:22:28)\n' +
' at async Object.invoke (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@medusajs/workflows-sdk/src/utils/composer/helpers/create-step-handler.ts:55:52)\n' +
' at async DistributedTransaction.handler (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@medusajs/orchestration/src/workflow/workflow-manager.ts:214:16)\n' +
' at async Promise.allSettled (index 0)\n' +
' at async promiseAll (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@medusajs/utils/src/common/promise-all.ts:23:18)\n' +
' at async TransactionOrchestrator.executeNext (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@medusajs/orchestration/src/transaction/transaction-orchestrator.ts:848:7)\n' +
' at async TransactionOrchestrator.resume (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@medusajs/orchestration/src/transaction/transaction-orchestrator.ts:893:5)\n' +
' at async LocalWorkflow.run (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@medusajs/orchestration/src/workflow/local-workflow.ts:365:5)\n' +
' at async originalExecution (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@medusajs/workflows-sdk/src/helper/workflow-export.ts:102:25)\n' +
' at async LocalWorkflow.newRun [as run] (/home/ubuntu/rsc/medusa/app-medusa/node_modules/@medusajs/workflows-sdk/src/helper/workflow-export.ts:186:12)\n' +
' at async POST (/home/ubuntu/rsc/medusa/app-medusa/src/api/admin/digital-products/route.ts:58:22)\n' +
' at async /home/ubuntu/rsc/medusa/app-medusa/node_modules/@medusajs/utils/src/common/wrap-handler.ts:17:14\n' +
'\n' +
`previous error: insert into "public"."digital_product_reference" ("id", "type", "licence_key", "digital_product_id", "created_at", "updated_at") values ('01J67TCZJTPXFGM22Y9VFWEXJ3', 'licence_key', 'LICENCE_KEY-123', '01J67TCZJTPQB9YWGTSZ73VP1Q', '2024-08-26T17:05:38.907Z', '2024-08-26T17:05:38.907Z', '01J67TCZJTPQB9YWGTSZ73VP1Q') returning "id", "created_at", "updated_at" - INSERT has more expressions than target columns\n` +
' at Parser.parseErrorMessage (/home/ubuntu/rsc/medusa/app-medusa/node_modules/pg-protocol/src/parser.ts:369:69)\n' +
' at Parser.handlePacket (/home/ubuntu/rsc/medusa/app-medusa/node_modules/pg-protocol/src/parser.ts:188:21)\n' +
' at Parser.parse (/home/ubuntu/rsc/medusa/app-medusa/node_modules/pg-protocol/src/parser.ts:103:30)\n' +
' at Socket.<anonymous> (/home/ubuntu/rsc/medusa/app-medusa/node_modules/pg-protocol/src/index.ts:7:48)\n' +
' at Socket.emit (node:events:519:28)\n' +
' at Socket.emit (node:domain:488:12)\n' +
' at addChunk (node:internal/streams/readable:559:12)\n' +
' at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)\n' +
' at Socket.Readable.push (node:internal/streams/readable:390:5)\n' +
' at TCP.onStreamRead (node:internal/stream_base_commons:190:23)\n' +
' at TCP.callbackTrampoline (node:internal/async_hooks:130:17)',
length: 117,
severity: 'ERROR',
code: '42601',
detail: undefined,
hint: undefined,
position: '288',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'analyze.c',
line: '1026',
routine: 'transformInsertRow'
}
from medusa.
Looking at the error stack trace, the error occurs at src/workflows/create-digital-product/steps/create-digital-product.ts
line 22, and the workflow is executed at src/api/admin/digital-products/route.ts:58:22
Can you share the code in both files? Also the request you're making to the create digital product API route (with the request body)?
from medusa.
Related Issues (20)
- Medusa v2 Docs: Issue in 4.2.2. Service Factory - Medusa v2 Docs HOT 1
- npm install package version not found HOT 1
- Fix URL in getPublicOas Function to Correct API Spec Download Path @medusajs/medusa-oas-cli HOT 2
- Issue in Medusa V2 Learning Resources - Unit Price cannot be added during Cart Creation but document says so HOT 3
- Migration failes with exit code 0 HOT 4
- Duplicate customers HOT 2
- Stripe Payments not working HOT 4
- Malformed syntax. 2.0.6-preview HOT 4
- Server running in worker mode doesn't have health HOT 2
- Stripe payments - 'intent' must be a string but got undefined HOT 1
- bug: Promotions - Buy X get Y HOT 11
- Medusa Learning Resources: Issue in B2B Recipe - Medusa Learning Resources
- Incorrect doc link
- ui package breakpoint inconsistency
- Product Tag not saving when edit product. HOT 1
- Error starting server with scheduled jobs due to a new change in bullmq HOT 3
- Medusa v2 Docs: Issue in 3.11. Workflows - Medusa v2 Docs HOT 1
- Omnibus directive compliance
- Docs(Code Issue): Code Issue in /deployments/server/deploying-on-heroku HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from medusa.