1
0
Fork 0
mirror of synced 2024-08-06 05:38:40 +12:00

Merge pull request #13752 from Budibase/BUDI-8279/prevent-changing-date-or-time-only-when-fetched

Prevent changing date or time only when fetched
This commit is contained in:
Adria Navarro 2024-05-23 15:27:26 +02:00 committed by GitHub
commit 7d77b517be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 19 deletions

View file

@ -604,27 +604,29 @@
<DatePicker bind:value={editableColumn.constraints.datetime.latest} />
</div>
</div>
{#if datasource?.source !== SourceName.ORACLE && datasource?.source !== SourceName.SQL_SERVER && !editableColumn.dateOnly}
<div>
<div class="row">
<Label>Time zones</Label>
<AbsTooltip
position="top"
type="info"
text={isCreating
? null
: "We recommend not changing how timezones are handled for existing columns, as existing data will not be updated"}
>
<Icon size="XS" name="InfoOutline" />
</AbsTooltip>
{#if !editableColumn.timeOnly}
{#if datasource?.source !== SourceName.ORACLE && datasource?.source !== SourceName.SQL_SERVER && !editableColumn.dateOnly}
<div>
<div class="row">
<Label>Time zones</Label>
<AbsTooltip
position="top"
type="info"
text={isCreating
? null
: "We recommend not changing how timezones are handled for existing columns, as existing data will not be updated"}
>
<Icon size="XS" name="InfoOutline" />
</AbsTooltip>
</div>
<Toggle
bind:value={editableColumn.ignoreTimezones}
text="Ignore time zones"
/>
</div>
<Toggle
bind:value={editableColumn.ignoreTimezones}
text="Ignore time zones"
/>
</div>
{/if}
<Toggle bind:value={editableColumn.dateOnly} text="Date only" />
{/if}
<Toggle bind:value={editableColumn.dateOnly} text="Date only" />
{:else if editableColumn.type === FieldType.NUMBER && !editableColumn.autocolumn}
<div class="split-label">
<div class="label-length">

View file

@ -73,6 +73,16 @@ function validate(table: Table, oldTable?: Table) {
`Column "${key}" has subtype "${column.subtype}" - this is not supported.`
)
}
if (column.type === FieldType.DATETIME) {
const oldColumn = oldTable?.schema[key] as typeof column
if (oldColumn && column.timeOnly !== oldColumn.timeOnly) {
throw new Error(
`Column "${key}" can not change from time to datetime or viceversa.`
)
}
}
}
}