Bläddra i källkod

fix(plugin): fix data format error in sql plugin

remove default config for query (#1907)

Signed-off-by: Jianxiang Ran <rxan_embedded@163.com>
superxan 1 år sedan
förälder
incheckning
856b3e16b5
2 ändrade filer med 74 tillägg och 85 borttagningar
  1. 65 65
      extensions/sources/sql/sql.json
  2. 9 20
      extensions/sources/sql/sql.yaml

+ 65 - 65
extensions/sources/sql/sql.json

@@ -61,12 +61,73 @@
         }
         }
       },
       },
       {
       {
+        "name": "lookup",
+        "default": {
+          "cache": {
+            "name": "cache",
+            "default": true,
+            "optional": false,
+            "control": "radio",
+            "type": "bool",
+            "hint": {
+              "en_US": "Whether to enable cache for lookup",
+              "zh_CN": "是否开启查询缓存"
+            },
+            "label": {
+              "en_US": "Enable lookup cache",
+              "zh_CN": "开启查询缓存"
+            }
+          },
+          "cacheTtl": {
+            "name": "cacheTtl",
+            "default": 600,
+            "optional": true,
+            "control": "text",
+            "type": "int",
+            "hint": {
+              "en_US": "Cache Time To Live",
+              "zh_CN": "缓存时间"
+            },
+            "label": {
+              "en_US": "Cache TTL",
+              "zh_CN": "缓存时间"
+            }
+          },
+          "cacheMissingKey": {
+            "name": "cacheMissingKey",
+            "default": true,
+            "optional": false,
+            "control": "radio",
+            "type": "bool",
+            "hint": {
+              "en_US": "Whether to cache missing lookup of null value",
+              "zh_CN": "是否缓存未命中的空值"
+            },
+            "label": {
+              "en_US": "Cache missing key",
+              "zh_CN": "缓存未命中的 Key"
+            }
+          }
+        },
+        "optional": true,
+        "control": "list",
+        "type": "object",
+        "hint": {
+          "en_US": "Lookup table configuration, only effective when using as a lookup table",
+          "zh_CN": "查询表配置,仅在作为查询表使用时生效"
+        },
+        "label": {
+          "en_US": "Lookup table configuration",
+          "zh_CN": "查询表配置"
+        }
+      },
+      {
         "name": "internalSqlQueryCfg",
         "name": "internalSqlQueryCfg",
         "default": {
         "default": {
           "table":{
           "table":{
             "name": "table",
             "name": "table",
-            "default": "tableName",
-            "optional": false,
+            "default": "",
+            "optional": true,
             "control": "text",
             "control": "text",
             "type": "string",
             "type": "string",
             "hint": {
             "hint": {
@@ -110,7 +171,7 @@
           },
           },
           "limit": {
           "limit": {
             "name": "limit",
             "name": "limit",
-            "default": 10,
+            "default": "",
             "optional": true,
             "optional": true,
             "control": "text",
             "control": "text",
             "type": "int",
             "type": "int",
@@ -173,7 +234,7 @@
           "TemplateSql": {
           "TemplateSql": {
             "name": "TemplateSql",
             "name": "TemplateSql",
             "default": "",
             "default": "",
-            "optional": false,
+            "optional": true,
             "control": "text",
             "control": "text",
             "type": "string",
             "type": "string",
             "hint": {
             "hint": {
@@ -258,67 +319,6 @@
           "en_US": "Query Template",
           "en_US": "Query Template",
           "zh_CN": "查询模版"
           "zh_CN": "查询模版"
         }
         }
-      },
-      {
-        "name": "lookup",
-        "default": {
-          "cache": {
-            "name": "cache",
-            "default": true,
-            "optional": false,
-            "control": "radio",
-            "type": "bool",
-            "hint": {
-              "en_US": "Whether to enable cache for lookup",
-              "zh_CN": "是否开启查询缓存"
-            },
-            "label": {
-              "en_US": "Enable lookup cache",
-              "zh_CN": "开启查询缓存"
-            }
-          },
-          "cacheTtl": {
-            "name": "cacheTtl",
-            "default": "600",
-            "optional": true,
-            "control": "text",
-            "type": "string",
-            "hint": {
-              "en_US": "Cache Time To Live",
-              "zh_CN": "缓存时间"
-            },
-            "label": {
-              "en_US": "Cache TTL",
-              "zh_CN": "缓存时间"
-            }
-          },
-          "cacheMissingKey": {
-            "name": "cacheMissingKey",
-            "default": true,
-            "optional": false,
-            "control": "radio",
-            "type": "bool",
-            "hint": {
-              "en_US": "Whether to cache missing lookup of null value",
-              "zh_CN": "是否缓存未命中的空值"
-            },
-            "label": {
-              "en_US": "Cache missing key",
-              "zh_CN": "缓存未命中的 Key"
-            }
-          }
-        },
-        "optional": true,
-        "control": "list",
-        "type": "object",
-        "hint": {
-          "en_US": "Lookup table configuration, only effective when using as a lookup table",
-          "zh_CN": "查询表配置,仅在作为查询表使用时生效"
-        },
-        "label": {
-          "en_US": "Lookup table configuration",
-          "zh_CN": "查询表配置"
-        }
       }
       }
     ]
     ]
   },
   },

+ 9 - 20
extensions/sources/sql/sql.yaml

@@ -1,21 +1,12 @@
 default:
 default:
-  interval: 10000
-  url: mysql://user:test@140.210.204.147/user?parseTime=true
-  internalSqlQueryCfg:
-    table: test
-    limit: 1
-    indexField: registerTime
-    indexValue: "2022-04-21 10:23:55"
-    indexFieldType: "DATETIME"
-    dateTimeFormat: "YYYY-MM-dd HH:mm:ss"
+
+sqlite_config:
+  url: sqlite:/tmp/test.db
   lookup:
   lookup:
     cache: true
     cache: true
     cacheTtl: 600
     cacheTtl: 600
     cacheMissingKey: true
     cacheMissingKey: true
 
 
-sqlite_config:
-  url: sqlite:/tmp/test.db
-
 sqlserver_config:
 sqlserver_config:
   url: sqlserver://username:password@140.210.204.147/testdb
   url: sqlserver://username:password@140.210.204.147/testdb
   internalSqlQueryCfg:
   internalSqlQueryCfg:
@@ -28,17 +19,15 @@ sqlserver_config:
 # select top 10 * from Student where id > 1010 order by id ASC
 # select top 10 * from Student where id > 1010 order by id ASC
 
 
 mysql_config:
 mysql_config:
-  interval: 10000
   url: mysql://user:test@140.210.204.147/user?parseTime=true
   url: mysql://user:test@140.210.204.147/user?parseTime=true
-  internalSqlQueryCfg:
-    table: test
-    limit: 1
-    indexField: registerTime
-    indexValue: "2022-04-21 10:23:55"
-    indexFieldType: "DATETIME"
-    dateTimeFormat: "YYYY-MM-dd HH:mm:ss"
+  lookup:
+    cache: true
+    cacheTtl: 600
+    cacheMissingKey: true
 
 
 template_config:
 template_config:
+  interval: 10000
+  url: mysql://user:test@140.210.204.147/user?parseTime=true
   templateSqlQueryCfg:
   templateSqlQueryCfg:
     TemplateSql: "select * from table where entry_date > '{{.entry_date}}'"
     TemplateSql: "select * from table where entry_date > '{{.entry_date}}'"
     indexField: entry_date
     indexField: entry_date