Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Adapter error when using skip #38

Open
ionutchirvasa opened this issue Jan 6, 2022 · 1 comment
Open

Adapter error when using skip #38

ionutchirvasa opened this issue Jan 6, 2022 · 1 comment

Comments

@ionutchirvasa
Copy link

ionutchirvasa commented Jan 6, 2022

No matter what blueprint API I use I get when using skip without populate=false the adapter throws an error!

Sample request:

Fails: http://localhost:1337/api/audit?skip=1
Works: http://localhost:1337/api/audit?skip=1&populate=false

I event tried this wit a model that has no relations set up and I get the same error.

I attached the error I receive from the server.
Adapter error.txt

Edit:
The issue is related with the generated sql query; it's missing the sorting column(please see row 2: (ORDER BY ).
SELECT TOP 1 * FROM ( SELECT ROW_NUMBER() OVER(ORDER BY ) as row#, [audit].[createdAt], [audit].[updatedAt], [createdBy].[createdAt] as [createdBy.createdAt], [createdBy].[updatedAt] as [createdBy.updatedAt], [createdBy].[id] as [createdBy.id], [createdBy].[firstName] as [createdBy.firstName], [createdBy].[lastName] as [createdBy.lastName], [createdBy].[photo] as [createdBy.photo], [createdBy].[email] as [createdBy.email], [createdBy].[username] as [createdBy.username], [createdBy].[createdBy] as [createdBy.createdBy], [createdBy].[departmentID] as [createdBy.departmentID], [audit].[id], [audit].[newValue], [audit].[oldValue], [audit].[modelID], [audit].[modelName] FROM [audit] WITH (NOLOCK) left outer join [user] as [createdBy] on [createdBy].[id] = [audit].[createdBy] ) as completeDataSet where row# > 1 FOR JSON PATH

   Workaround:
   Explicitly specifying the sort param in the URL solves the issue:
   http://localhost:1337/api/audit?skip=1&sort=id
@acraileanu
Copy link

@davepreston: potential fix - acraileanu@a4d9905

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

No branches or pull requests

2 participants