mirror of
https://github.com/CarmJos/EasySQL.git
synced 2024-09-19 21:35:47 +00:00
[v0.3.1] 修复一些小的规范问题
This commit is contained in:
parent
386093e58b
commit
36a23af450
@ -15,6 +15,7 @@ public interface SQLUpdateBatchAction extends SQLAction<List<Integer>> {
|
|||||||
*/
|
*/
|
||||||
SQLUpdateBatchAction addBatch(@NotNull String sql);
|
SQLUpdateBatchAction addBatch(@NotNull String sql);
|
||||||
|
|
||||||
|
@Override
|
||||||
default @NotNull String getSQLContent() {
|
default @NotNull String getSQLContent() {
|
||||||
return getSQLContents().get(0);
|
return getSQLContents().get(0);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public class PreparedSQLBatchUpdateActionImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreparedSQLUpdateBatchAction addParamsBatch(Object[] params) {
|
public PreparedSQLUpdateBatchAction addParamsBatch(Object... params) {
|
||||||
this.allParams.add(params);
|
this.allParams.add(params);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public class PreparedSQLUpdateActionImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreparedSQLUpdateActionImpl setParams(Object[] params) {
|
public PreparedSQLUpdateActionImpl setParams(Object... params) {
|
||||||
this.params = params;
|
this.params = params;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public class PreparedQueryActionImpl extends QueryActionImpl implements Prepared
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PreparedQueryActionImpl setParams(@Nullable Object[] params) {
|
public PreparedQueryActionImpl setParams(@Nullable Object... params) {
|
||||||
this.params = params;
|
this.params = params;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public abstract class AbstractConditionalBuilder<B extends ConditionalBuilder<B,
|
|||||||
public B addCondition(
|
public B addCondition(
|
||||||
@NotNull String[] queryNames, @Nullable Object[] queryValues
|
@NotNull String[] queryNames, @Nullable Object[] queryValues
|
||||||
) {
|
) {
|
||||||
if (queryNames.length != queryValues.length) {
|
if (queryValues == null || queryNames.length != queryValues.length) {
|
||||||
throw new RuntimeException("queryNames are not match with queryValues");
|
throw new RuntimeException("queryNames are not match with queryValues");
|
||||||
}
|
}
|
||||||
for (int i = 0; i < queryNames.length; i++) {
|
for (int i = 0; i < queryNames.length; i++) {
|
||||||
|
@ -111,7 +111,7 @@ public class TableCreateBuilderImpl extends AbstractSQLBuilder implements TableC
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableCreateBuilder setColumns(@NotNull String[] columns) {
|
public TableCreateBuilder setColumns(@NotNull String... columns) {
|
||||||
this.columns = Arrays.asList(columns);
|
this.columns = Arrays.asList(columns);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ public class TableQueryBuilderImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TableQueryBuilderImpl selectColumns(@NotNull String[] columnNames) {
|
public TableQueryBuilderImpl selectColumns(@NotNull String... columnNames) {
|
||||||
this.columns = columnNames;
|
this.columns = columnNames;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ public class SQLManagerImpl implements SQLManager {
|
|||||||
if (isDebugMode()) getLogger().info("[DEBUG] " + msg);
|
if (isDebugMode()) getLogger().info("[DEBUG] " + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Logger getLogger() {
|
public Logger getLogger() {
|
||||||
return LOGGER;
|
return LOGGER;
|
||||||
}
|
}
|
||||||
@ -103,7 +104,7 @@ public class SQLManagerImpl implements SQLManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Integer> executeSQLBatch(@NotNull String sql, String[] moreSQL) {
|
public List<Integer> executeSQLBatch(@NotNull String sql, String... moreSQL) {
|
||||||
SQLUpdateBatchAction action = new SQLUpdateBatchActionImpl(this, sql);
|
SQLUpdateBatchAction action = new SQLUpdateBatchActionImpl(this, sql);
|
||||||
if (moreSQL != null && moreSQL.length > 0) {
|
if (moreSQL != null && moreSQL.length > 0) {
|
||||||
Arrays.stream(moreSQL).forEach(action::addBatch);
|
Arrays.stream(moreSQL).forEach(action::addBatch);
|
||||||
|
@ -128,16 +128,12 @@ public class StatementUtil {
|
|||||||
* @return 数据类型,默认为 {@link Types#VARCHAR}
|
* @return 数据类型,默认为 {@link Types#VARCHAR}
|
||||||
*/
|
*/
|
||||||
public static int getNullType(PreparedStatement statement, int paramIndex) {
|
public static int getNullType(PreparedStatement statement, int paramIndex) {
|
||||||
int sqlType = Types.VARCHAR;
|
|
||||||
|
|
||||||
final ParameterMetaData pmd;
|
|
||||||
try {
|
try {
|
||||||
pmd = statement.getParameterMetaData();
|
ParameterMetaData pmd = statement.getParameterMetaData();
|
||||||
sqlType = pmd.getParameterType(paramIndex);
|
return pmd.getParameterType(paramIndex);
|
||||||
} catch (SQLException ignore) {
|
} catch (SQLException ignore) {
|
||||||
|
return Types.VARCHAR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return sqlType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,12 +7,14 @@ import cc.carm.lib.easysql.testrunner.tests.TableCreateTest;
|
|||||||
import cc.carm.lib.easysql.testrunner.tests.TableRenameTest;
|
import cc.carm.lib.easysql.testrunner.tests.TableRenameTest;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.jetbrains.annotations.TestOnly;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@TestOnly
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
Loading…
Reference in New Issue
Block a user