1
0
Fork 0
mirror of synced 2024-09-20 11:27:56 +12:00

Respond to PR comments.

This commit is contained in:
Sam Rose 2024-07-19 15:07:58 +01:00
parent 8a49953449
commit c64d76eb84
No known key found for this signature in database
3 changed files with 14 additions and 12 deletions

View file

@ -8,6 +8,7 @@ const DOUBLE_SEPARATOR = `${SEPARATOR}${SEPARATOR}`
const ROW_ID_REGEX = /^\[.*]$/g
const ENCODED_SPACE = encodeURIComponent(" ")
const ISO_DATE_REGEX = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/
const TIME_REGEX = /^(?:\d{2}:)?(?:\d{2}:)(?:\d{2})$/
export function isExternalTableID(tableId: string) {
return tableId.startsWith(DocumentType.DATASOURCE + SEPARATOR)
@ -147,6 +148,10 @@ export function isValidFilter(value: any) {
return value != null && value !== ""
}
export function isValidTime(value: string) {
return TIME_REGEX.test(value)
}
export function sqlLog(client: string, query: string, values?: any[]) {
if (!environment.SQL_LOGGING_ENABLE) {
return

View file

@ -99,18 +99,16 @@ export async function processAutoColumn(
}
}
async function processDeafultValues(table: Table, row: Row) {
async function processDefaultValues(table: Table, row: Row) {
const ctx: { ["Current User"]?: User; user?: User } = {}
const identity = context.getIdentity()
if (identity) {
if (identity._id && identity.type === IdentityType.USER) {
const user = await cache.user.getUser(identity._id)
delete user.password
if (identity?._id && identity.type === IdentityType.USER) {
const user = await cache.user.getUser(identity._id)
delete user.password
ctx["Current User"] = user
ctx.user = user
}
ctx["Current User"] = user
ctx.user = user
}
for (let [key, schema] of Object.entries(table.schema)) {
@ -221,7 +219,7 @@ export async function inputProcessing(
}
await processAutoColumn(userId, table, clonedRow, opts)
await processDeafultValues(table, clonedRow)
await processDefaultValues(table, clonedRow)
return { table, row: clonedRow }
}

View file

@ -1,7 +1,6 @@
import { sql } from "@budibase/backend-core"
import { FieldType } from "@budibase/types"
const TIME_REGEX = /^(?:\d{2}:)?(?:\d{2}:)(?:\d{2})$/
const parseArrayString = (value: any) => {
if (typeof value === "string") {
if (value === "") {
@ -117,7 +116,7 @@ export const TYPE_TRANSFORM_MAP: any = {
parse: (date: any) => {
if (date instanceof Date) {
return date.toISOString()
} else if (typeof date === "string" && TIME_REGEX.test(date)) {
} else if (typeof date === "string" && sql.utils.isValidTime(date)) {
return date
} else {
const parsed = new Date(date)