diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryMethods.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryMethods.java index 06d5541f..a4d1e81e 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryMethods.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryMethods.java @@ -65,6 +65,11 @@ public class QueryMethods { return new DistinctQueryColumn(columns); } + //CONVERT ( data_type [ ( length ) ] , expression [ , style ] ) + public static StringFunctionQueryColumn convert(String... params) { + return new StringFunctionQueryColumn("CONVERT", params); + } + public static StringQueryColumn column(String column) { return new StringQueryColumn(column); } @@ -85,7 +90,7 @@ public class QueryMethods { return new OperatorQueryCondition(" NOT ", childCondition); } - public static QueryCondition noCondition(){ + public static QueryCondition noCondition() { return QueryCondition.createEmpty(); } @@ -110,7 +115,7 @@ public class QueryMethods { return select(count("1")); } - public static RawValue raw(String raw){ + public static RawValue raw(String raw) { return new RawValue(raw); } diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/StringFunctionQueryColumn.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/StringFunctionQueryColumn.java new file mode 100644 index 00000000..8fb5cbd6 --- /dev/null +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/StringFunctionQueryColumn.java @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *
+ * 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 com.mybatisflex.core.query;
+
+import com.mybatisflex.core.dialect.IDialect;
+import com.mybatisflex.core.util.SqlUtil;
+import com.mybatisflex.core.util.StringUtil;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * 数据库 聚合函数,例如 CONVERT(NVARCHAR(30), GETDATE(), 126) 等等
+ */
+public class StringFunctionQueryColumn extends QueryColumn {
+
+ protected String fnName;
+ protected List