@@ -51,7 +51,9 @@ const useLogQueryStore = defineStore('logQuery', () => {
51
51
const multipleRe = / t i m e s t a m p \( ( \d ) \) /
52
52
const getTsColumn = ( tableName : string ) => {
53
53
const fields = tableMap . value [ tableName ] || [ ]
54
- const field = fields . filter ( ( column ) => column . data_type . toLowerCase ( ) . indexOf ( 'timestamp' ) > - 1 ) [ 0 ]
54
+ const tsColumns = fields . filter ( ( column ) => column . data_type . toLowerCase ( ) . indexOf ( 'timestamp' ) > - 1 )
55
+ const tsIndexColumns = tsColumns . filter ( ( column ) => column . semantic_type === 'TIMESTAMP' )
56
+ const field = tsIndexColumns . length ? tsIndexColumns [ 0 ] : tsColumns [ 0 ]
55
57
if ( ! field ) {
56
58
return null
57
59
}
@@ -198,7 +200,8 @@ const useLogQueryStore = defineStore('logQuery', () => {
198
200
table_name,
199
201
table_schema,
200
202
column_name,
201
- data_type
203
+ data_type,
204
+ semantic_type
202
205
FROM
203
206
information_schema.columns
204
207
${ where }
@@ -219,6 +222,7 @@ const useLogQueryStore = defineStore('logQuery', () => {
219
222
name : row [ 2 ] ,
220
223
data_type : row [ 3 ] ,
221
224
label : row [ 2 ] ,
225
+ semantic_type : row [ 4 ] ,
222
226
} )
223
227
}
224
228
tableMap . value = tmp
@@ -233,15 +237,14 @@ const useLogQueryStore = defineStore('logQuery', () => {
233
237
return value
234
238
. replace ( / \\ / g, '\\\\' ) // Escape backslashes
235
239
. replace ( / ' / g, "''" ) // Escape single quotes by doubling
236
- . replace ( / " / g, '\\"' ) // Escape double quotes (if needed)
237
240
. replace ( / \n / g, '\\n' ) // Escape newline
238
241
. replace ( / \r / g, '\\r' ) // Escape carriage return
239
242
}
240
243
241
244
function singleCondition ( condition : Condition ) {
242
245
const column = condition . field
243
246
const columnType = getColumnOpType ( column . data_type )
244
-
247
+ const conditionVal = escapeSqlString ( condition . value )
245
248
let columnName = condition . field . name
246
249
if ( columnName . toUpperCase ( ) !== columnName && columnName . toLowerCase ( ) !== columnName ) {
247
250
columnName = `"${ columnName } "`
@@ -252,7 +255,7 @@ const useLogQueryStore = defineStore('logQuery', () => {
252
255
}
253
256
if ( condition . op === 'like' ) {
254
257
// return `MATCHES(${columnName},'"${escapeSqlString(condition.value)}"')`
255
- return `${ columnName } like '%${ condition . value } %'`
258
+ return `${ columnName } like '%${ conditionVal } %'`
256
259
}
257
260
if ( [ 'contains' , 'not contains' , 'match sequence' ] . indexOf ( condition . op ) > - 1 ) {
258
261
let val = escapeSqlString ( condition . value )
0 commit comments