Browse Source

fix(gui-v2): fix project schema for pg and mssql

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/2970/head
mertmit 2 years ago
parent
commit
86bfebffd6
  1. 8
      packages/nc-gui-v2/pages/project/index/create-external.vue
  2. 9
      packages/nc-gui-v2/utils/projectCreateUtils.ts

8
packages/nc-gui-v2/pages/project/index/create-external.vue

@ -59,7 +59,7 @@ const validators = computed(() => {
'dataSource.connection.database': [fieldRequiredValidator], 'dataSource.connection.database': [fieldRequiredValidator],
...([ClientType.PG, ClientType.MSSQL].includes(formState.dataSource.client) ...([ClientType.PG, ClientType.MSSQL].includes(formState.dataSource.client)
? { ? {
'dataSource.connection.searchPath.0': [fieldRequiredValidator], 'dataSource.searchPath.0': [fieldRequiredValidator],
} }
: {}), : {}),
}), }),
@ -288,11 +288,11 @@ onMounted(() => {
</a-form-item> </a-form-item>
<!-- Schema name --> <!-- Schema name -->
<a-form-item <a-form-item
v-if="[ClientType.MSSQL, ClientType.PG].includes(formState.dataSource.client)" v-if="[ClientType.MSSQL, ClientType.PG].includes(formState.dataSource.client) && formState.dataSource.searchPath"
:label="$t('labels.schemaName')" :label="$t('labels.schemaName')"
v-bind="validateInfos['dataSource.connection.searchPath.0']" v-bind="validateInfos['dataSource.searchPath.0']"
> >
<a-input v-model:value="formState.dataSource.connection.searchPath[0]" size="small" /> <a-input v-model:value="formState.dataSource.searchPath[0]" size="small" />
</a-form-item> </a-form-item>
<a-collapse ghost expand-icon-position="right" class="mt-6"> <a-collapse ghost expand-icon-position="right" class="mt-6">

9
packages/nc-gui-v2/utils/projectCreateUtils.ts

@ -12,7 +12,6 @@ export interface ProjectCreateForm {
password: string password: string
port: number | string port: number | string
ssl?: Record<string, string> ssl?: Record<string, string>
searchPath?: string[]
} }
| { | {
client?: ClientType.SQLITE client?: ClientType.SQLITE
@ -22,6 +21,7 @@ export interface ProjectCreateForm {
} }
useNullAsDefault?: boolean useNullAsDefault?: boolean
} }
searchPath?: string[]
} }
inflection: { inflection: {
inflectionColumn?: string inflectionColumn?: string
@ -73,7 +73,6 @@ const sampleConnectionData: Record<ClientType | string, ProjectCreateForm['dataS
user: 'postgres', user: 'postgres',
password: 'password', password: 'password',
database: '_test', database: '_test',
searchPath: ['public'],
ssl: { ssl: {
ca: '', ca: '',
key: '', key: '',
@ -110,7 +109,6 @@ const sampleConnectionData: Record<ClientType | string, ProjectCreateForm['dataS
user: 'sa', user: 'sa',
password: 'Password123.', password: 'Password123.',
database: '_test', database: '_test',
searchPath: ['dbo'],
ssl: { ssl: {
ca: '', ca: '',
key: '', key: '',
@ -203,6 +201,11 @@ export const getDefaultConnectionConfig = (client: ClientType): ProjectCreateFor
return { return {
client, client,
connection: sampleConnectionData[client], connection: sampleConnectionData[client],
searchPath: [ClientType.PG, ClientType.MSSQL].includes(client)
? client === ClientType.PG
? ['public']
: ['dbo']
: undefined,
} }
} }

Loading…
Cancel
Save