loopbackio / loopbackio/loopback-next
While updating record by id using repository throwing ROWCOUNT error
@achrinza がすでに取り組んでいます。
2022年4月5日 から。
- 主要言語
- TypeScript
- スター
- 5.1k
- フォーク
- 1.1k
- 平均マージ
- 2日 21時間
- マージ済み PR(30日)
- 27
説明
## Steps to reproduce
my model looks like these
```typescript
@model({
settings: {
'mssql': {schema: `boim`, table: `test`},
strict: true,
},
})
export class TestModel extends Entity {
@property({
type: 'number',
id: true,
generated:true,
})
id?: number;
@property({
type: 'date',
required: true,
})
date_created: string;
@property({
type: 'date',
})
start_date?: string;
@property({
type: 'date',
})
end_date?: string;
@property({
type: 'string',
})
charge?: string;
@property({
type: 'string',
})
param?: string;
@property({
type: 'string',
})
output?: string;
@property({
type: 'string',
})
response?: string;
@property({
type: 'string',
})
status?: string | null;
@property({
type: 'boolean',
})
working?: boolean;
constructor(data?: Partial) {
super(data);
}
}
export interface TestModelRelations {
// describe navigational properties here
}
export type TestModelWithRelations = TestModel & TestModelRelations;
```
My repository
```typescript
export class TestModelRepository extends DefaultCrudRepository<
TestModel,
typeof TestModel.prototype.id,
TestModelRelations
> {
constructor(
@inject('datasources.msSqlDs') dataSource: MsSqlDsDataSource,
) {
super(TestModel, dataSource);
}
}
```
in my controller
```typescript
constructor(
@inject(RestBindings.Http.RESPONSE) private response: Response,
@repository(TestModelRepository)
private testModelRepository: TestModelRepository,
) {}
```
I have generated my application using lb4 cli
## Current Behavior
When I use `updateById()` (e.g. `this.testModelRepository.updateById(id,{working:true})`), I am getting the `Must declare the scalar variable "@@ROWCOUNT"` error.
I tried to print the SQL query that is generated by changing debug settings and I got this in the log:
```
loopback:connector:mssql SQL: UPDATE [boim].[test] SET [working]=@param1 WHERE [id]=@param2;SELECT @@ROWCOUNT as count Parameters: [true,987] +4s
loopback:connector:mssql Result: {"code":"EREQUEST","originalError":{"info":{"name":"ERROR","event":"errorMessage","number":137,"state":1,"class":16,"message":"Must declare the scalar variable \"@@ROWCOUNT\".","serverName":"mydatabase","procName":"","lineNumber":1}},"name":"RequestError","number":137,"lineNumber":1,"state":1,"class":16,"serverName":"mydatabase","procName":"","precedingErrors":[]} undefined +2s
```
## Expected Behavior
## Link to reproduction sandbox
## Additional information
darwin x64 10.16.3
npm ls --prod --depth 0 | grep loopback
├── @loopback/boot@3.1.2
├── @loopback/core@2.13.1
├── @loopback/repository@3.3.0
├── @loopback/rest@9.1.1
├── @loopback/rest-explorer@3.0.5
├── @loopback/service-proxy@3.0.5
├── loopback-connector-mssql@3.8.0
├── loopback-connector-mysql@5.4.4
-->
## Related Issues
_See [Reporting Issues](http://loopback.io/doc/en/contrib/Reporting-issues.html) for more tips on writing good issues_
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
評価
この issue はまだ評価されていません。