Skip to content

Commit

Permalink
Merge pull request #7 from 2023-2-Design-Pattern/kms/select-join-bug
Browse files Browse the repository at this point in the history
Select * join 버그 해결
  • Loading branch information
mskim9967 authored Nov 5, 2023
2 parents 49a0348 + 2e27344 commit d5fe26b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
24 changes: 24 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Git Rule

### 커밋 룰
- 선 이슈 생성 & 후 개발

ex) `git commit -m "feat: ~~~"`
- `feat` 기능 구현
- `refactor` 리팩토링
- `fix` 버그 수정
- `test` 테스트코드
- `config` 빌드, 패키지, 환경변수 등의 수정
- `comment` 주석 추가 및 변경
- `docs` 문서 수정
- `rename` 파일/폴더명 수정
- `remove` 파일/폴더 삭제
- `etc` → 그 외

### 브랜치 룰
- `[이름 이니셜]/[수행한 작업]`

ex) `kms/select-join-fix`

### Merge 룰
- `개인브랜치 → (PR) → develop`, `develop → main` 방향으로만 머지한다
31 changes: 8 additions & 23 deletions src/com/holub/database/ConcreteTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,11 @@
private transient boolean isDirty = false;
private transient LinkedList transactionStack = new LinkedList();

/*
Getter
*/

public LinkedList getRowSet() {
return rowSet;
}

public String[] getColumnNames() {
return columnNames;
}

public String getTableName() {
return tableName;
}

/**********************************************************************
* Create a table with the given name and columns.
*
* @param tableName the name of the table.
* @param an array of Strings that specify the column names.
*/
public ConcreteTable(String tableName, String[] columnNames) {
this.tableName = tableName;
Expand Down Expand Up @@ -479,13 +463,14 @@ public Table select(Selector where, String[] requestedColumns, // {=ConcreteTabl
// iterators for each table involved in the join.

// Fix point - join 했을 때의 모든 컬럼 불러오기
if (requestedColumns == null){
ArrayList<String> tempList = new ArrayList<String>();
requestedColumns = tempList.toArray(String[]::new);
for (Table table : allTables){
ConcreteTable concreteTable = (ConcreteTable) table;
requestedColumns = Stream.concat(Arrays.stream(requestedColumns), Arrays.stream(concreteTable.getColumnNames())).toArray(String[]::new);
}
if (Objects.isNull(requestedColumns)) {
Set<String> cols = new LinkedHashSet<>();

for(Table table : allTables)
for(int i = 0; i < table.rows().columnCount(); i++)
cols.add(table.rows().columnName(i));

requestedColumns = cols.toArray(new String[cols.size()]);
}

Table resultTable = new ConcreteTable(null, requestedColumns);
Expand Down

0 comments on commit d5fe26b

Please sign in to comment.