Remove duplicates
This commit is contained in:
parent
3a095c5071
commit
ee74a84339
|
@ -1,8 +1,7 @@
|
|||
// need to handle table name + field or just field, depending on if relationships used
|
||||
import { FieldType, Row, Table } from "@budibase/types"
|
||||
import { helpers } from "@budibase/shared-core"
|
||||
import { helpers, PROTECTED_INTERNAL_COLUMNS } from "@budibase/shared-core"
|
||||
import { generateRowIdField } from "../../../../integrations/utils"
|
||||
import { CONSTANT_INTERNAL_ROW_COLS } from "../../../../db/utils"
|
||||
|
||||
function extractFieldValue({
|
||||
row,
|
||||
|
@ -94,7 +93,7 @@ export function basicProcessing({
|
|||
thisRow._rev = "rev"
|
||||
} else {
|
||||
const columns = Object.keys(table.schema)
|
||||
for (let internalColumn of [...CONSTANT_INTERNAL_ROW_COLS, ...columns]) {
|
||||
for (let internalColumn of [...PROTECTED_INTERNAL_COLUMNS, ...columns]) {
|
||||
thisRow[internalColumn] = extractFieldValue({
|
||||
row,
|
||||
tableName: table._id!,
|
||||
|
|
|
@ -57,14 +57,6 @@ export const getUserMetadataParams = dbCore.getUserMetadataParams
|
|||
export const generateUserMetadataID = dbCore.generateUserMetadataID
|
||||
export const getGlobalIDFromUserMetadataID =
|
||||
dbCore.getGlobalIDFromUserMetadataID
|
||||
export const CONSTANT_INTERNAL_ROW_COLS = [
|
||||
"_id",
|
||||
"_rev",
|
||||
"type",
|
||||
"createdAt",
|
||||
"updatedAt",
|
||||
"tableId",
|
||||
]
|
||||
|
||||
/**
|
||||
* Gets parameters for retrieving tables, this is a utility function for the getDocParams function.
|
||||
|
|
|
@ -31,10 +31,7 @@ import {
|
|||
SQLITE_DESIGN_DOC_ID,
|
||||
SQS_DATASOURCE_INTERNAL,
|
||||
} from "@budibase/backend-core"
|
||||
import {
|
||||
CONSTANT_INTERNAL_ROW_COLS,
|
||||
generateJunctionTableID,
|
||||
} from "../../../../db/utils"
|
||||
import { generateJunctionTableID } from "../../../../db/utils"
|
||||
import AliasTables from "../sqlAlias"
|
||||
import { outputProcessing } from "../../../../utilities/rowProcessor"
|
||||
import pick from "lodash/pick"
|
||||
|
@ -44,7 +41,7 @@ import {
|
|||
getRelationshipColumns,
|
||||
getTableIDList,
|
||||
} from "./filters"
|
||||
import { dataFilters } from "@budibase/shared-core"
|
||||
import { dataFilters, PROTECTED_INTERNAL_COLUMNS } from "@budibase/shared-core"
|
||||
|
||||
const builder = new sql.Sql(SqlClient.SQL_LITE)
|
||||
const MISSING_COLUMN_REGEX = new RegExp(`no such column: .+`)
|
||||
|
@ -65,7 +62,7 @@ function buildInternalFieldList(
|
|||
})
|
||||
}
|
||||
fieldList = fieldList.concat(
|
||||
CONSTANT_INTERNAL_ROW_COLS.map(col => `${table._id}.${col}`)
|
||||
PROTECTED_INTERNAL_COLUMNS.map(col => `${table._id}.${col}`)
|
||||
)
|
||||
for (let col of Object.values(table.schema)) {
|
||||
const isRelationship = col.type === FieldType.LINK
|
||||
|
@ -355,7 +352,7 @@ export async function search(
|
|||
|
||||
// check if we need to pick specific rows out
|
||||
if (options.fields) {
|
||||
const fields = [...options.fields, ...CONSTANT_INTERNAL_ROW_COLS]
|
||||
const fields = [...options.fields, ...PROTECTED_INTERNAL_COLUMNS]
|
||||
finalRows = finalRows.map((r: any) => pick(r, fields))
|
||||
}
|
||||
|
||||
|
|
|
@ -10,12 +10,10 @@ import {
|
|||
Table,
|
||||
} from "@budibase/types"
|
||||
import tablesSdk from "../"
|
||||
import {
|
||||
CONSTANT_INTERNAL_ROW_COLS,
|
||||
generateJunctionTableID,
|
||||
} from "../../../../db/utils"
|
||||
import { generateJunctionTableID } from "../../../../db/utils"
|
||||
import { isEqual } from "lodash"
|
||||
import { DEFAULT_TABLES } from "../../../../db/defaultData/datasource_bb_default"
|
||||
import { PROTECTED_INTERNAL_COLUMNS } from "@budibase/shared-core"
|
||||
|
||||
const FieldTypeMap: Record<FieldType, SQLiteType> = {
|
||||
[FieldType.BOOLEAN]: SQLiteType.NUMERIC,
|
||||
|
@ -122,7 +120,7 @@ function mapTable(table: Table): SQLiteTables {
|
|||
}
|
||||
// there are some extra columns to map - add these in
|
||||
const constantMap: Record<string, SQLiteType> = {}
|
||||
CONSTANT_INTERNAL_ROW_COLS.forEach(col => {
|
||||
PROTECTED_INTERNAL_COLUMNS.forEach(col => {
|
||||
constantMap[col] = SQLiteType.TEXT
|
||||
})
|
||||
const thisTable: SQLiteTable = {
|
||||
|
|
Loading…
Reference in New Issue