Skip to content

Commit

Permalink
optimize: optimize no primary key output log (apache#1861)
Browse files Browse the repository at this point in the history
  • Loading branch information
slievrly authored and zjinlei committed Oct 31, 2019
1 parent b5659d5 commit e6a7e7c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
15 changes: 15 additions & 0 deletions common/src/main/java/io/seata/common/util/LambdaUtils.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.seata.common.util;

import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ public Map<String, ColumnMeta> getPrimaryKeyMap() {
}

if (pk.size() > 1) {
throw new NotSupportYetException("Multi PK");
throw new NotSupportYetException(String.format("%s contains multi PK, but current not support.", tableName));
}
if (pk.size() < 1) {
throw new NotSupportYetException(String.format("%s needs to contain the primary key.", tableName));
}

return pk;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,11 @@ public void testGetPkName() {
public void testContainsPK() {
TableMeta tableMeta = new TableMeta();
Assertions.assertFalse(tableMeta.containsPK(null));
Assertions.assertFalse(tableMeta.containsPK(Lists.newArrayList("id")));

Throwable exception = Assertions.assertThrows(NotSupportYetException.class, () -> {
tableMeta.containsPK(Lists.newArrayList("id"));
});
Assertions.assertEquals(tableMeta.getTableName() + " needs to contain the primary key.",
exception.getMessage());
IndexMeta primary = new IndexMeta();
primary.setIndextype(IndexType.PRIMARY);
ColumnMeta columnMeta = new ColumnMeta();
Expand Down

0 comments on commit e6a7e7c

Please sign in to comment.