DB 컬럼 정보를 불러오는 기능 + DB 컬럼 속성을 변경하는 기능 #901
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#894 작업을 하다가 아쉬운 점이 있어서 새 기능을 만들어 보았습니다.
현재는 모듈 업데이트를 하거나 그 밖에 DB 스키마 변경이 필요할 때 컬럼을 추가하거나 삭제할 수는 있지만, 이미 있는 컬럼의 자료형이나 길이를 변경할 수는 없도록 되어 있습니다. 그렇다고 쿼리를 직접 써서 변경한다면 XE의 원칙에 어긋나겠고요...
그래서 특정 테이블의 특정 컬럼에 대한 정보(자료형, 길이, 기본값, null여부)를 불러온 후 변경이 필요하다고 판단되면 변경을 요청할 수 있는 기능을 추가해 보았습니다.
getColumnInfo()
메소드는 해당 컬럼의 속성이 담긴 객체를 반환합니다.modifyColumn()
메소드는 컬럼 속성을 변경하는 데 사용하며, 사용하는 파라미터의 종류와 순서는 이미 있는addColumn()
메소드와 같습니다.변경이 필요하지 않은 속성까지 변경되는 것을 막기 위해서는
getColumnInfo()
메소드에서 받은 값을 도로 집어넣는 것이 좋습니다.속성 변경에 성공한 경우
true
, 실패한 경우false
를 반환합니다.MySQL, MS SQL, 큐브리드 모두 동일한 기능을 갖도록 만들어졌으나, 일부 버전의 큐브리드는 컬럼 속성 변경이 불가능한 경우도 있습니다. 이 경우
modifyColumn()
메소드는false
를 반환하게 됩니다. 그 밖에도 DB 권한 등 여러 가지 이유로 스키마 변경에 실패할 수 있으므로, 이 메소드를 사용하는 모듈에서는false
를 반환하는 경우를 반드시 확인하고 적절한 조치를 취해야 합니다.많은 테스트를 바라며, 모듈 업데이트시 새로운 기능을 구현하면서도 구 버전과의 호환성을 유지하고 싶은 분들에게 도움이 되면 좋겠습니다.