Browse Source

Merge pull request #7197 from nocodb/fix/select-default-value

fix: Escape single quote properly and when updating single select default value
pull/7222/head
Raju Udava 12 months ago committed by GitHub
parent
commit
d51666455c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      packages/nc-gui/components/smartsheet/column/DefaultValue.vue
  2. 14
      packages/nocodb/src/services/columns.service.ts

4
packages/nc-gui/components/smartsheet/column/DefaultValue.vue

@ -27,8 +27,8 @@ const cdfValue = ref<string | null>(null)
const editEnabled = ref(false) const editEnabled = ref(false)
const updateCdfValue = (cdf: string | null) => { const updateCdfValue = (cdf: string | null) => {
vModel.value.cdf = cdf vModel.value = { ...vModel.value, cdf }
cdfValue.value = vModel.value.cdf cdfValue.value = cdf
} }
onMounted(() => { onMounted(() => {

14
packages/nocodb/src/services/columns.service.ts

@ -444,12 +444,7 @@ export class ColumnsService {
} }
// handle single quote for default value // handle single quote for default value
if ( if (driverType === 'pg' || driverType === 'sqlite3') {
driverType === 'mysql' ||
driverType === 'mysql2' ||
driverType === 'pg' ||
driverType === 'sqlite3'
) {
colBody.cdf = colBody.cdf.replace(/'/g, "'"); colBody.cdf = colBody.cdf.replace(/'/g, "'");
} else { } else {
colBody.cdf = colBody.cdf.replace(/'/g, "''"); colBody.cdf = colBody.cdf.replace(/'/g, "''");
@ -1300,12 +1295,7 @@ export class ColumnsService {
} }
// handle single quote for default value // handle single quote for default value
if ( if (driverType === 'pg' || driverType === 'sqlite3') {
driverType === 'mysql' ||
driverType === 'mysql2' ||
driverType === 'pg' ||
driverType === 'sqlite3'
) {
colBody.cdf = colBody.cdf.replace(/'/g, "'"); colBody.cdf = colBody.cdf.replace(/'/g, "'");
} else { } else {
colBody.cdf = colBody.cdf.replace(/'/g, "''"); colBody.cdf = colBody.cdf.replace(/'/g, "''");

Loading…
Cancel
Save