Test and fix single reference search

This commit is contained in:
Adria Navarro 2024-04-26 13:38:35 +02:00
parent 24aec6efb1
commit 06b3023b15
3 changed files with 13 additions and 3 deletions

View File

@ -19,7 +19,7 @@ const tableWithUserCol: Table = {
schema: { schema: {
user: { user: {
name: "user", name: "user",
type: FieldType.BB_REFERENCE, type: FieldType.BB_REFERENCE_SINGLE,
subtype: BBReferenceFieldSubType.USER, subtype: BBReferenceFieldSubType.USER,
}, },
}, },
@ -35,7 +35,7 @@ const tableWithUsersCol: Table = {
user: { user: {
name: "user", name: "user",
type: FieldType.BB_REFERENCE, type: FieldType.BB_REFERENCE,
subtype: BBReferenceFieldSubType.USERS, subtype: BBReferenceFieldSubType.USER,
}, },
}, },
} }

View File

@ -86,6 +86,16 @@ export function searchInputMapping(table: Table, options: RowSearchParams) {
} }
for (let [key, column] of Object.entries(table.schema)) { for (let [key, column] of Object.entries(table.schema)) {
switch (column.type) { switch (column.type) {
case FieldType.BB_REFERENCE_SINGLE:
const subtype = column.subtype
switch (subtype) {
case BBReferenceFieldSubType.USER:
userColumnMapping(key, options)
break
default:
utils.unreachable(subtype)
}
break
case FieldType.BB_REFERENCE: { case FieldType.BB_REFERENCE: {
const subtype = column.subtype const subtype = column.subtype
switch (subtype) { switch (subtype) {

View File

@ -116,7 +116,7 @@ export interface BBReferenceFieldMetadata
export interface BBReferenceSingleFieldMetadata export interface BBReferenceSingleFieldMetadata
extends Omit<BaseFieldSchema, "subtype"> { extends Omit<BaseFieldSchema, "subtype"> {
type: FieldType.BB_REFERENCE_SINGLE type: FieldType.BB_REFERENCE_SINGLE
subtype: BBReferenceFieldSubType subtype: Exclude<BBReferenceFieldSubType, BBReferenceFieldSubType.USERS>
} }
export interface AttachmentFieldMetadata extends BaseFieldSchema { export interface AttachmentFieldMetadata extends BaseFieldSchema {