loopbackio / loopbackio/loopback-next

While updating record by id using repository throwing ROWCOUNT error

Offen
#6,960 12 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

@achrinza arbeitet bereits daran.

Seit 05.4.2022.

blocked bug db:MSSQL Repository
Vorherrschende Sprache
TypeScript
Sterne
5.1k
Forks
1.1k
Ø Merge
2 T. 21 Std.
Gemergte PRs (30 T.)
27

Beschreibung

## 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_

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.