@@ -157,7 +157,7 @@ public abstract class AbstractSQLConfig<T extends Object> implements SQLConfig<T
157157 // TODO 改成更好的正则,校验前面为单词,中间为操作符,后面为值
158158 PATTERN_FUNCTION = Pattern .compile ("^[A-Za-z0-9%,:_@&~`!=\\ <\\ >\\ |\\ [\\ ]\\ {\\ } /\\ .\\ +\\ -\\ *\\ ^\\ ?\\ (\\ )\\ $]+$" );
159159
160- TABLE_KEY_MAP = new HashMap <String , String >();
160+ TABLE_KEY_MAP = new HashMap <>();
161161 TABLE_KEY_MAP .put (Table .class .getSimpleName (), Table .TABLE_NAME );
162162 TABLE_KEY_MAP .put (Column .class .getSimpleName (), Column .TABLE_NAME );
163163 TABLE_KEY_MAP .put (PgClass .class .getSimpleName (), PgClass .TABLE_NAME );
@@ -195,9 +195,15 @@ public abstract class AbstractSQLConfig<T extends Object> implements SQLConfig<T
195195 DATABASE_LIST .add (DATABASE_HIVE );
196196 DATABASE_LIST .add (DATABASE_PRESTO );
197197 DATABASE_LIST .add (DATABASE_TRINO );
198+ DATABASE_LIST .add (DATABASE_MILVUS );
198199 DATABASE_LIST .add (DATABASE_INFLUXDB );
199200 DATABASE_LIST .add (DATABASE_TDENGINE );
201+ DATABASE_LIST .add (DATABASE_SNOWFLAKE );
202+ DATABASE_LIST .add (DATABASE_DATABRICKS );
200203 DATABASE_LIST .add (DATABASE_REDIS );
204+ DATABASE_LIST .add (DATABASE_MONGODB );
205+ DATABASE_LIST .add (DATABASE_CASSANDRA );
206+ DATABASE_LIST .add (DATABASE_KAFKA );
201207 DATABASE_LIST .add (DATABASE_MQ );
202208
203209 RAW_MAP = new LinkedHashMap <>(); // 保证顺序,避免配置冲突等意外情况
@@ -1189,6 +1195,14 @@ public static boolean isPresto(String db) {
11891195 return DATABASE_PRESTO .equals (db );
11901196 }
11911197
1198+ @ Override
1199+ public boolean isTrino () {
1200+ return isTrino (getSQLDatabase ());
1201+ }
1202+ public static boolean isTrino (String db ) {
1203+ return DATABASE_TRINO .equals (db );
1204+ }
1205+
11921206 @ Override
11931207 public boolean isSnowflake () {
11941208 return isSnowflake (getSQLDatabase ());
@@ -1214,11 +1228,11 @@ public static boolean isCassandra(String db) {
12141228 }
12151229
12161230 @ Override
1217- public boolean isTrino () {
1218- return isTrino (getSQLDatabase ());
1231+ public boolean isMilvus () {
1232+ return isMilvus (getSQLDatabase ());
12191233 }
1220- public static boolean isTrino (String db ) {
1221- return DATABASE_TRINO .equals (db );
1234+ public static boolean isMilvus (String db ) {
1235+ return DATABASE_MILVUS .equals (db );
12221236 }
12231237
12241238 @ Override
@@ -1245,20 +1259,36 @@ public static boolean isRedis(String db) {
12451259 return DATABASE_REDIS .equals (db );
12461260 }
12471261
1262+ @ Override
1263+ public boolean isMongoDB () {
1264+ return isMongoDB (getSQLDatabase ());
1265+ }
1266+ public static boolean isMongoDB (String db ) {
1267+ return DATABASE_MONGODB .equals (db );
1268+ }
1269+
1270+ @ Override
1271+ public boolean isKafka () {
1272+ return isKafka (getSQLDatabase ());
1273+ }
1274+ public static boolean isKafka (String db ) {
1275+ return DATABASE_KAFKA .equals (db );
1276+ }
1277+
12481278 @ Override
12491279 public boolean isMQ () {
12501280 return isMQ (getSQLDatabase ());
12511281 }
12521282 public static boolean isMQ (String db ) {
1253- return DATABASE_MQ .equals (db );
1283+ return DATABASE_MQ .equals (db ) || isKafka ( db ) ;
12541284 }
12551285
12561286 @ Override
12571287 public String getQuote () {
12581288 if (isElasticsearch ()) {
12591289 return "" ;
12601290 }
1261- return isMySQL () || isMariaDB () || isTiDB () || isClickHouse () || isTDengine () ? "`" : "\" " ;
1291+ return isMySQL () || isMariaDB () || isTiDB () || isClickHouse () || isTDengine () || isMilvus () ? "`" : "\" " ;
12621292 }
12631293
12641294 public String quote (String s ) {
@@ -1272,6 +1302,7 @@ public String getSchema() {
12721302 }
12731303
12741304 @ NotNull
1305+ @ Override
12751306 public String getSQLSchema () {
12761307 String table = getTable ();
12771308 //强制,避免因为全局默认的 @schema 自动填充进来,导致这几个类的 schema 为 sys 等其它值
@@ -1953,14 +1984,14 @@ public String getColumnString(boolean inSQLJoin) throws Exception {
19531984 }
19541985
19551986 // 简单点, 后台配置就带上 AS
1956- // int index = expression.lastIndexOf(":");
1957- // String alias = expression.substring(index+1);
1958- // boolean hasAlias = StringUtil.isName(alias);
1959- // String pre = index > 0 && hasAlias ? expression.substring(0, index) : expression;
1960- // if (RAW_MAP.containsValue(pre) || "".equals(RAW_MAP.get(pre))) { // newSQLConfig 提前处理好的
1961- // expression = pre + (hasAlias ? " AS " + alias : "");
1962- // continue;
1963- // }
1987+ int index = expression .lastIndexOf (":" );
1988+ String alias = expression .substring (index +1 );
1989+ boolean hasAlias = StringUtil .isName (alias );
1990+ String pre = index > 0 && hasAlias ? expression .substring (0 , index ) : expression ;
1991+ if (RAW_MAP .containsValue (pre ) || "" .equals (RAW_MAP .get (pre ))) { // newSQLConfig 提前处理好的
1992+ keys [ i ] = pre + (hasAlias ? " AS " + alias : "" );
1993+ continue ;
1994+ }
19641995 }
19651996
19661997 if (expression .length () > 100 ) {
@@ -2001,6 +2032,16 @@ public String parseSQLExpression(String key, String expression, boolean containR
20012032 * @return
20022033 */
20032034 public String parseSQLExpression (String key , String expression , boolean containRaw , boolean allowAlias , String example ) {
2035+ if (containRaw ) {
2036+ String s = RAW_MAP .get (expression );
2037+ if ("" .equals (s )) {
2038+ return expression ;
2039+ }
2040+ if (s != null ) {
2041+ return s ;
2042+ }
2043+ }
2044+
20042045 String quote = getQuote ();
20052046 int start = expression .indexOf ('(' );
20062047 if (start < 0 ) {
@@ -2578,9 +2619,22 @@ public static int getOffset(int page, int count) {
25782619 */
25792620 @ JSONField (serialize = false )
25802621 public String getLimitString () {
2581- if (count <= 0 || RequestMethod .isHeadMethod (getMethod (), true )) {
2622+ int count = getCount ();
2623+
2624+ if (isMilvus ()) {
2625+ if (count == 0 ) {
2626+ Parser <T > parser = getParser ();
2627+ count = parser == null ? AbstractParser .MAX_QUERY_COUNT : parser .getMaxQueryCount ();
2628+ }
2629+
2630+ int offset = getOffset (getPage (), count );
2631+ return " LIMIT " + offset + ", " + count ; // 目前 moql-transx 的限制
2632+ }
2633+
2634+ if (count <= 0 || RequestMethod .isHeadMethod (getMethod (), true )) { // TODO HEAD 真的不需要 LIMIT ?
25822635 return "" ;
25832636 }
2637+
25842638 return getLimitString (
25852639 getPage ()
25862640 , getCount ()
0 commit comments