@@ -71,8 +71,8 @@ function isQueryResultSetColumns(columns) {
71
71
72
72
// Returns true if the value represents an array of primitives (i.e., a
73
73
// 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 ) {
76
76
return (
77
77
isTypedArray ( value ) ||
78
78
arrayContainsPrimitives ( value ) ||
@@ -373,9 +373,10 @@ function likeOperand(operand) {
373
373
// This function applies table cell operations to an in-memory table (array of
374
374
// objects); it should be equivalent to the corresponding SQL query.
375
375
export function __table ( source , operations ) {
376
- if ( arrayIsPrimitive ( source ) ) source = Array . from ( source , ( value ) => ( { value} ) ) ;
377
376
const input = source ;
378
377
let { schema, columns} = source ;
378
+ let primitive = arrayIsPrimitive ( source ) ;
379
+ if ( primitive ) source = Array . from ( source , ( value ) => ( { value} ) ) ;
379
380
for ( const { type, operands} of operations . filter ) {
380
381
const [ { value : column } ] = operands ;
381
382
const values = operands . slice ( 1 ) . map ( ( { value} ) => value ) ;
@@ -474,6 +475,7 @@ export function __table(source, operations) {
474
475
Object . fromEntries ( operations . select . columns . map ( ( c ) => [ c , d [ c ] ] ) )
475
476
) ;
476
477
}
478
+ if ( primitive ) source = source . map ( ( d ) => d . value ) ;
477
479
if ( source !== input ) {
478
480
if ( schema ) source . schema = schema ;
479
481
if ( columns ) source . columns = columns ;
0 commit comments