HTTP POST works but GET fails with feathers sequelize standard service

146 Views Asked by At

I am trying to get started with feathers.js and sequelize. I am following the Chat guide, but am using sequelize rather than the default db. I am using a local SQL Server 2016 instance, this is what my sequelize object looks like:

  const sequelize = new Sequelize('feathers_backend', null, null, {
    dialect: 'mssql',
    dialectModulePath: 'sequelize-msnodesqlv8',
    logging: false,
    dialectOptions: {
      driver: 'SQL Server Native Client 11.0',
      instanceName: 'MSSQLSERVER01',
      trustedConnection: true,
    }
  });

I got as far as creating the messages API and downloading the postman HTTP examples.

I expected the application to work as described in the guide - i.e. regular CRUD behaviour.

POSTing new messages works fine, with the expected result returned. However, as soon as I do a GET, I get this error:

info: after: messages - Method: create info: after: messages - Method: create info: error: messages - Method: find: [Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax near 'OFFSET'. error: SequelizeDatabaseError: [Microsoft][SQL Server Native Client 11.0][SQL Server]Incorrect syntax near 'OFFSET'. at Query.formatError (C:\Users\George\Source\Repos\feathers-app\node_modules\sequelize\lib\dialects\mssql\query.js:322:12) at Request.connection.lib.Request [as callback] (C:\Users\George\Source\Repos\feathers-app\node_modules\sequelize\lib\dialects\mssql\query.js:107:25) at Connection.removeRequest (C:\Users\George\Source\Repos\feathers-app\node_modules\sequelize-msnodesqlv8\lib\connection.js:173:13) at context.connection.queryRaw (C:\Users\George\Source\Repos\feathers-app\node_modules\sequelize-msnodesqlv8\lib\request.js:31:14) at routeStatementError (C:\Users\George\Source\Repos\feathers-app\node_modules\msnodesqlv8\lib\driverRead.js:20:7) at C:\Users\George\Source\Repos\feathers-app\node_modules\msnodesqlv8\lib\driverRead.js:204:13 at Object.cbFreeStatement [as end] (C:\Users\George\Source\Repos\feathers-app\node_modules\msnodesqlv8\lib\driverMgr.js:202:7)

I can't see why one of the HTTP methods would be fine and the other not? Noting the OFFSET syntax error, this is what the generated SQL looks like:

Executing (default): SELECT [id], [text], [createdAt], [updatedAt] FROM [messages] AS [messages] OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;
0

There are 0 best solutions below