Skip to content

Conversation

@Wookshin
Copy link

@Wookshin Wookshin commented Jul 8, 2022

Iterate, isNotNull 태그에 대하여 구현했습니다.

  1. iterate Convert 기능 구현
  2. isNotNull Convert 기능 구현

1. iterate Convert 기능 구현
2. isNotNull Convert 기능 구현
@Wookshin
Copy link
Author

Wookshin commented Jul 8, 2022

안녕하세요 OldBlackJoe님!
npm에 제공하신 ibatis-mapper 라이브러리 매우 잘 사용중입니다.
좋은 소스 공유해주셔서 감사해요^^

라이브러리를 사용하다가 iterate, isNotNull 기능이 필요하여 구현했습니다.
해당 PR의 코드 내용 참고하셔서 문제 없는지 리뷰 부탁드려요.

Comment on lines -12 to -13
const queryTypes = [ 'statement', 'select', 'insert', 'update', 'delete' ];

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

참조하지 않는 변수 제거

return convertBinaryCondition(children, param, namespace, iBatisMapper, isFirst);
break;
case 'iterate':
return convertIterate(children, param, namespace, iBatisMapper);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iterate 기능 추가

Comment on lines +23 to 24
case 'isNotNull':
return convertBinaryCondition(children, param, namespace, iBatisMapper, isFirst);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isNotNull 기능 추가

Comment on lines +174 to +176
case 'isNotNull':
evalResult = param.hasOwnProperty(property);
break;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isNotNull의 경우 comapreValue를 갖지 않으므로, Parameter에 속성 Key가 존재하는지만 확인

Comment on lines +233 to +238
var convertString = param[property].reduce((prev, cur, index)=>{
var iterateValue = (index === 0) ? `${open}'${cur}'` : `${prev}${conjunction}'${cur}'`;
if (index === param[property].length - 1)
iterateValue += close;
return iterateValue
}, `${open}${close}`);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iterate는 open, close, conjuection 옵션을 가짐(ex. open="(", close=")",conjunction=",")
배열로 되어있는 파라미터 값을 해당 옵션을 토대로 변경함.
ex. ["apple", "grape"] → ('apple', 'grape')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant