Chip Clark
10/23/2021, 12:45 AMprisma:query SELECT 1
prisma:query SELECT [dbo].[Page].[ID], [dbo].[Page].[Title], [dbo].[Page].[Description], [dbo].[Page].[Icon], [dbo].[Page].[Sidebar],
[dbo].[Page].[IsActive], [dbo].[Page].[Sort] FROM [dbo].[Page] WHERE 1=1
prisma:query SELECT 1
prisma:query SELECT [dbo].[MainSidebar].[ID], [dbo].[MainSidebar].[Main_Sidebar] FROM [dbo].[MainSidebar] WHERE 1=1
{"Title":"New Item","Description":"","Icon":"pe-7s-refresh-2","Sidebar":"","IsActive":false,"Sort":"1"}
prisma:query SELECT 1
prisma:info Begin transaction
prisma:query BEGIN TRAN
prisma:query
INSERT INTO [dbo].[Page] (
[Title],
[Description],
[Icon],
[Sidebar],
[IsActive],
[Sort]
)
VALUES (
DEFAULT,
@P1,
@P2,
@P3,
@P4,
@P5,
@P6
);
prisma:info Rollback transaction
prisma:query ROLLBACK
[Nest] 146544 - 10/22/2021, 5:40:42 PM [ExceptionsHandler]
Invalid `prisma.executeRaw()` invocation:
Raw query failed. Code: `110`. Message: `There are fewer columns in the INSERT statement than values specified in the VALUES clause.
The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.` +234239ms
Error:
Invalid `prisma.executeRaw()` invocation:
Raw query failed. Code: `110`. Message: `There are fewer columns in the INSERT statement than values specified in the VALUES clause.
The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.`
at cb (C:\Sites\AM-API-LMS\node_modules\@prisma\client\runtime\index.js:38537:17)
at async Promise.all (index 0)
at async PageService.createPage (C:\Sites\AM-API-LMS\dist\Page\Page.service.js:73:30)
at async C:\Sites\AM-API-LMS\node_modules\@nestjs\core\router\router-execution-context.js:46:28
at async C:\Sites\AM-API-LMS\node_modules\@nestjs\core\router\router-proxy.js:9:17
schema:
model Page {
ID Int @id @default(autoincrement())
Title String? @db.NVarChar(255)
Description String? @db.NText
Icon String? @db.NVarChar(255)
Sidebar String? @db.NText
IsActive Boolean?
Sort Int?
// Assoc_Page_Tag Assoc_Page_Tag[]
}
page.service.ts
async createPage(data: Prisma.PageCreateInput) {
const payload = {
...data
};
console.log(JSON.stringify(data));
const insert = this.prisma.$executeRaw`
INSERT INTO [dbo].[Page] (
[Title],
[Description],
[Icon],
[Sidebar],
[IsActive],
[Sort]
)
VALUES (
DEFAULT,
${payload.Title},
${payload.Description},
${payload.Icon},
${payload.Sidebar},
${payload.IsActive},
${payload.Sort}
);`;
const lastId = this.prisma.$queryRaw`
SELECT @@IDENTITY as id;
`;
const [, response] = await this.prisma.$transaction([insert, lastId]);
return this.PagebyID({ id: response?.[0]?.id });
}
Ryan
10/25/2021, 5:27 AMDEFAULT
in this case?Chip Clark
10/25/2021, 3:38 PMChip Clark
10/25/2021, 3:38 PMChip Clark
10/27/2021, 2:49 PM{"Title":"Networking, Events & Sponsorships","Description":"","Icon":"calendar-check","IconStyle":"far","URL":"<http://spam01/marketing/Pages/Default.aspx>","IsActive":true,"Sort":100}
prisma:query SELECT 1
prisma:info Begin transaction
prisma:query BEGIN TRAN
prisma:query
INSERT INTO [dbo].[Page] (
[Title],
[Description],
[Icon],
[IconStyle],
[URL],
[IsActive],
[Sort]
)
VALUES (
@P1,
@P2,
@P3,
@P4,
@P5,
@P6,
@P7
);
prisma:query
SELECT @@IDENTITY as id;
prisma:info Commit transaction
prisma:query COMMIT
what is:
undefined
{ ID: undefined }
prisma:query SELECT [dbo].[Subpage].[ID], [dbo].[Subpage].[Title], [dbo].[Subpage].[Description], [dbo].[Subpage].[Icon], [dbo].[Subpage].[URL], [dbo].[Subpage].[URLTarget], [dbo].[Subpage].[IsActive], [dbo].[Subpage].[Sort], [dbo].[Subpage].[IconStyle], [dbo].[Subpage].[Sidebar] FROM [dbo].[Subpage] WHERE 1=1 ORDER BY 1 OFFSET @P1 ROWS FETCH NEXT @P2 ROWS ONLY
prisma:query SELECT [dbo].[Subpage].[ID], [dbo].[Subpage].[Title], [dbo].[Subpage].[Description], [dbo].[Subpage].[Icon], [dbo].[Subpage].[URL], [dbo].[Subpage].[URLTarget], [dbo].[Subpage].[IsActive], [dbo].[Subpage].[Sort], [dbo].[Subpage].[IconStyle], [dbo].[Subpage].[Sidebar] FROM [dbo].[Subpage] WHERE 1=1
In the code, I am looking at the { id: response?.[0]?.id } - and it comes back undefined, which suggests the record doesn't exist.
I don't get an error that the POST fails, but it doesn't succeed.
Thoughts as to where I can look to see what's going on.Chip Clark
10/27/2021, 4:30 PM[dbo].[Page] - should be [dbo].[Subpage]