loopbackio / loopbackio/loopback-next

While updating record by id using repository throwing ROWCOUNT error

Ouverte
#6,960 12 commentaires 0 réactions 1 personne assignée Voir sur GitHub

@achrinza y travaille déjà.

Depuis le 5/4/2022.

blocked bug db:MSSQL Repository
Langage dominant
TypeScript
Étoiles
5.1k
Forks
1.1k
Merge moyen
2 j 21 h
PR mergées (30 j)
27

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.