Browse Source

fix(gui): check default value defined or not

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4459/head
Pranav C 2 years ago
parent
commit
12a95968ba
  1. 24
      packages/nc-gui/components/cell/MultiSelect.vue
  2. 24
      packages/nc-gui/components/cell/SingleSelect.vue

24
packages/nc-gui/components/cell/MultiSelect.vue

@ -209,17 +209,19 @@ async function addIfMissingAndSave() {
const updatedColMeta = { ...column.value } const updatedColMeta = { ...column.value }
// todo: refactor and avoid repetition // todo: refactor and avoid repetition
// Postgres returns default value wrapped with single quotes & casted with type so we have to get value between single quotes to keep it unified for all databases if (updatedColMeta.cdf) {
if (isPg.value) { // Postgres returns default value wrapped with single quotes & casted with type so we have to get value between single quotes to keep it unified for all databases
updatedColMeta.cdf = updatedColMeta.cdf.substring( if (isPg.value) {
updatedColMeta.cdf.indexOf(`'`) + 1, updatedColMeta.cdf = updatedColMeta.cdf.substring(
updatedColMeta.cdf.lastIndexOf(`'`), updatedColMeta.cdf.indexOf(`'`) + 1,
) updatedColMeta.cdf.lastIndexOf(`'`),
} )
}
// Mysql escapes single quotes with backslash so we keep quotes but others have to unescaped
if (!isMysql.value) { // Mysql escapes single quotes with backslash so we keep quotes but others have to unescaped
updatedColMeta.cdf = updatedColMeta.cdf.replace(/''/g, "'") if (!isMysql.value) {
updatedColMeta.cdf = updatedColMeta.cdf.replace(/''/g, "'")
}
} }
await $api.dbTableColumn.update( await $api.dbTableColumn.update(

24
packages/nc-gui/components/cell/SingleSelect.vue

@ -132,17 +132,19 @@ async function addIfMissingAndSave() {
const updatedColMeta = { ...column.value } const updatedColMeta = { ...column.value }
// todo: refactor and avoid repetition // todo: refactor and avoid repetition
// Postgres returns default value wrapped with single quotes & casted with type so we have to get value between single quotes to keep it unified for all databases if (updatedColMeta.cdf) {
if (isPg.value) { // Postgres returns default value wrapped with single quotes & casted with type so we have to get value between single quotes to keep it unified for all databases
updatedColMeta.cdf = updatedColMeta.cdf.substring( if (isPg.value) {
updatedColMeta.cdf.indexOf(`'`) + 1, updatedColMeta.cdf = updatedColMeta.cdf.substring(
updatedColMeta.cdf.lastIndexOf(`'`), updatedColMeta.cdf.indexOf(`'`) + 1,
) updatedColMeta.cdf.lastIndexOf(`'`),
} )
}
// Mysql escapes single quotes with backslash so we keep quotes but others have to unescaped
if (!isMysql.value) { // Mysql escapes single quotes with backslash so we keep quotes but others have to unescaped
updatedColMeta.cdf = updatedColMeta.cdf.replace(/''/g, "'") if (!isMysql.value) {
updatedColMeta.cdf = updatedColMeta.cdf.replace(/''/g, "'")
}
} }
await $api.dbTableColumn.update( await $api.dbTableColumn.update(

Loading…
Cancel
Save