@@ -71,8 +71,8 @@ function isQueryResultSetColumns(columns) {
7171
7272// Returns true if the value represents an array of primitives (i.e., a
7373// single-column table). This should only be passed values for which
74- // canDisplayTable returns true.
75- function arrayIsPrimitive ( value ) {
74+ // isDataArray returns true.
75+ export function arrayIsPrimitive ( value ) {
7676 return (
7777 isTypedArray ( value ) ||
7878 arrayContainsPrimitives ( value ) ||
@@ -373,9 +373,10 @@ function likeOperand(operand) {
373373// This function applies table cell operations to an in-memory table (array of
374374// objects); it should be equivalent to the corresponding SQL query.
375375export function __table ( source , operations ) {
376- if ( arrayIsPrimitive ( source ) ) source = Array . from ( source , ( value ) => ( { value} ) ) ;
377376 const input = source ;
378377 let { schema, columns} = source ;
378+ let primitive = arrayIsPrimitive ( source ) ;
379+ if ( primitive ) source = Array . from ( source , ( value ) => ( { value} ) ) ;
379380 for ( const { type, operands} of operations . filter ) {
380381 const [ { value : column } ] = operands ;
381382 const values = operands . slice ( 1 ) . map ( ( { value} ) => value ) ;
@@ -474,6 +475,7 @@ export function __table(source, operations) {
474475 Object . fromEntries ( operations . select . columns . map ( ( c ) => [ c , d [ c ] ] ) )
475476 ) ;
476477 }
478+ if ( primitive ) source = source . map ( ( d ) => d . value ) ;
477479 if ( source !== input ) {
478480 if ( schema ) source . schema = schema ;
479481 if ( columns ) source . columns = columns ;
0 commit comments