Skip to content
This repository has been archived by the owner on Dec 23, 2021. It is now read-only.

Commit

Permalink
fix: avoid update un-necessary field for hana
Browse files Browse the repository at this point in the history
  • Loading branch information
Soontao committed Sep 22, 2020
1 parent 1cfd3ce commit dc583cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/edm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,17 +232,17 @@ export const GeometryCollection = (function GeometryCollection() {
*
* @param returnType
*/
export function ReturnType<T>(returnType: T): T {
return returnType;
export function ReturnType(returnType: unknown): PropertyDecorator {
return returnType as PropertyDecorator;
}

/**
* decorator wrapper, indicate user inner decorator means parameter type
*
* @param returnType
*/
export function ParameterType<T>(parameterType: T): T {
return parameterType;
export function ParameterType(parameterType: unknown): ParameterDecorator {
return parameterType as ParameterDecorator;
}

/** Edm.Collection decorator for describing properties as collections */
Expand Down
5 changes: 2 additions & 3 deletions test/type/school_model/Teacher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,16 @@ export class Teacher {
// }
@ODataAction
async addClass(
@Edm.ReturnType(Edm.Int32) classId: number,
@Edm.ParameterType(Edm.Int32) classId: number,
@oInject.service(lazyRef(() => Class)) classService: InjectedTypedService<Class>
) {
const c = await classService.findOne(classId);

if (c === undefined) {
throw new ResourceNotFoundError(`not found instance class[${classId}]`);
}
c.teacherOneId = this.tid;

await classService.update(c.cid, c); // save with hooks lifecycle, suggested
await classService.update(c.cid, { teacherOneId: this.tid }); // save with hooks lifecycle, suggested
}

// GET http://localhost:50000/Teachers(1)/Default.queryClass()
Expand Down

0 comments on commit dc583cc

Please sign in to comment.