loopbackio / loopbackio/loopback-next

While updating record by id using repository throwing ROWCOUNT error

Abierto
#6,960 12 comentarios 0 reacciones 1 asignado Ver en GitHub

@achrinza ya está trabajando en esto.

Desde el 5/4/2022.

blocked bug db:MSSQL Repository
Lenguaje dominante
TypeScript
Estrellas
5.1k
Forks
1.1k
Merge medio
2 d 21 h
PR fusionados (30 d)
27

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.