Browse Source

fix(api): oracledb - time value insert/update

feat/oracle-support
Pranav C 2 years ago committed by Pranav C
parent
commit
684903ddbd
  1. 4
      packages/nc-gui/components/cell/TimePicker.vue
  2. 5
      packages/nc-gui/composables/useProject.ts
  3. 16
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

4
packages/nc-gui/components/cell/TimePicker.vue

@ -11,7 +11,7 @@ const { modelValue, isPk } = defineProps<Props>()
const emit = defineEmits(['update:modelValue'])
const { isMysql } = useProject()
const { isMysql, isOracle } = useProject()
const { showNull } = useGlobal()
@ -25,7 +25,7 @@ const column = inject(ColumnInj)!
let isTimeInvalid = $ref(false)
const dateFormat = isMysql(column.value.base_id) ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ'
const dateFormat = isMysql(column.value.base_id) || isOracle(column.value.base_id) ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ'
const localState = $computed({
get() {

5
packages/nc-gui/composables/useProject.ts

@ -82,6 +82,10 @@ export const useProject = createSharedComposable(() => {
return ['mysql', ClientType.MYSQL].includes(getBaseType(baseId))
}
function isOracle(baseId?: string) {
return getBaseType(baseId) === 'oracledb'
}
function isMssql(baseId?: string) {
return getBaseType(baseId) === 'mssql'
}
@ -204,6 +208,7 @@ export const useProject = createSharedComposable(() => {
loadTables,
isMysql,
isMssql,
isOracle,
isPg,
sqlUis,
isSharedBase,

16
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

@ -1644,18 +1644,16 @@ class BaseModelSqlv2 {
if (this.isOracle) {
for (const col of this.model.columns) {
if (
(col.dt === 'DATE' || col.dt.startsWith('TIMESTAMP')) &&
col.uidt === UITypes.Date &&
insertObj[col.column_name]
) {
!insertObj[col.column_name] ||
!(col.dt === 'DATE' || col.dt.startsWith('TIMESTAMP'))
)
continue;
if (col.uidt === UITypes.Date) {
insertObj[col.column_name] = this.dbDriver.raw(
`TO_DATE('${insertObj[col.column_name]}','YYYY-MM-DD')`
);
} else if (
(col.dt === 'DATE' || col.dt.startsWith('TIMESTAMP')) &&
col.uidt === UITypes.DateTime &&
insertObj[col.column_name]
) {
} else if (col.uidt === UITypes.DateTime || col.uidt === UITypes.Time) {
// ref - https://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements004.htm#i34924
insertObj[col.column_name] = this.dbDriver.raw(
`TO_DATE('${insertObj[col.column_name]}','yyyy-MM-dd HH24:mi:ss')`

Loading…
Cancel
Save