@@ -30,9 +30,15 @@ import {
3030import HyperJson , { GetLineActions , LineAction } from '@/components/HyperJson' ;
3131import { mergePath } from '@/utils' ;
3232
33- function buildJSONExtractStringQuery (
33+ type JSONExtractFn =
34+ | 'JSONExtractString'
35+ | 'JSONExtractFloat'
36+ | 'JSONExtractBool' ;
37+
38+ export function buildJSONExtractQuery (
3439 keyPath : string [ ] ,
3540 parsedJsonRootPath : string [ ] ,
41+ jsonExtractFn : JSONExtractFn = 'JSONExtractString' ,
3642) : string | null {
3743 const nestedPath = keyPath . slice ( parsedJsonRootPath . length ) ;
3844 if ( nestedPath . length === 0 ) {
@@ -41,7 +47,7 @@ function buildJSONExtractStringQuery(
4147
4248 const baseColumn = parsedJsonRootPath [ parsedJsonRootPath . length - 1 ] ;
4349 const jsonPathArgs = nestedPath . map ( p => `'${ p } '` ) . join ( ', ' ) ;
44- return `JSONExtractString (${ baseColumn } , ${ jsonPathArgs } )` ;
50+ return `${ jsonExtractFn } (${ baseColumn } , ${ jsonPathArgs } )` ;
4551}
4652
4753import { RowSidePanelContext } from './DBRowSidePanel' ;
@@ -258,7 +264,7 @@ export function DBRowJsonViewer({
258264
259265 // Handle parsed JSON from string columns using JSONExtractString
260266 if ( isInParsedJson && parsedJsonRootPath ) {
261- const jsonQuery = buildJSONExtractStringQuery (
267+ const jsonQuery = buildJSONExtractQuery (
262268 keyPath ,
263269 parsedJsonRootPath ,
264270 ) ;
@@ -301,10 +307,20 @@ export function DBRowJsonViewer({
301307
302308 // Handle parsed JSON from string columns using JSONExtractString
303309 if ( isInParsedJson && parsedJsonRootPath ) {
304- const jsonQuery = buildJSONExtractStringQuery (
310+ let jsonExtractFn : JSONExtractFn = 'JSONExtractString' ;
311+
312+ if ( typeof value === 'number' ) {
313+ jsonExtractFn = 'JSONExtractFloat' ;
314+ } else if ( typeof value === 'boolean' ) {
315+ jsonExtractFn = 'JSONExtractBool' ;
316+ }
317+
318+ const jsonQuery = buildJSONExtractQuery (
305319 keyPath ,
306320 parsedJsonRootPath ,
321+ jsonExtractFn ,
307322 ) ;
323+
308324 if ( jsonQuery ) {
309325 searchFieldPath = jsonQuery ;
310326 }
@@ -342,7 +358,7 @@ export function DBRowJsonViewer({
342358
343359 // Handle parsed JSON from string columns using JSONExtractString
344360 if ( isInParsedJson && parsedJsonRootPath ) {
345- const jsonQuery = buildJSONExtractStringQuery (
361+ const jsonQuery = buildJSONExtractQuery (
346362 keyPath ,
347363 parsedJsonRootPath ,
348364 ) ;
@@ -368,10 +384,7 @@ export function DBRowJsonViewer({
368384
369385 // Handle parsed JSON from string columns using JSONExtractString
370386 if ( isInParsedJson && parsedJsonRootPath ) {
371- const jsonQuery = buildJSONExtractStringQuery (
372- keyPath ,
373- parsedJsonRootPath ,
374- ) ;
387+ const jsonQuery = buildJSONExtractQuery ( keyPath , parsedJsonRootPath ) ;
375388 if ( jsonQuery ) {
376389 columnFieldPath = jsonQuery ;
377390 }
0 commit comments