mirror of https://github.com/apache/superset.git
fix: duplicate DB names (#15614)
This commit is contained in:
parent
d70ac21054
commit
5d86ffe768
|
@ -532,16 +532,16 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const setDatabaseModel = (engine: string) => {
|
const setDatabaseModel = (database_name: string) => {
|
||||||
const selectedDbModel = availableDbs?.databases.filter(
|
const selectedDbModel = availableDbs?.databases.filter(
|
||||||
(db: DatabaseObject) => db.engine === engine,
|
(db: DatabaseObject) => db.name === database_name,
|
||||||
)[0];
|
)[0];
|
||||||
const { name, parameters } = selectedDbModel;
|
const { engine, parameters } = selectedDbModel;
|
||||||
const isDynamic = parameters !== undefined;
|
const isDynamic = parameters !== undefined;
|
||||||
setDB({
|
setDB({
|
||||||
type: ActionType.dbSelected,
|
type: ActionType.dbSelected,
|
||||||
payload: {
|
payload: {
|
||||||
database_name: name,
|
database_name,
|
||||||
configuration_method: isDynamic
|
configuration_method: isDynamic
|
||||||
? CONFIGURATION_METHOD.DYNAMIC_FORM
|
? CONFIGURATION_METHOD.DYNAMIC_FORM
|
||||||
: CONFIGURATION_METHOD.SQLALCHEMY_URI,
|
: CONFIGURATION_METHOD.SQLALCHEMY_URI,
|
||||||
|
@ -566,7 +566,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
|
||||||
a.name.localeCompare(b.name),
|
a.name.localeCompare(b.name),
|
||||||
)
|
)
|
||||||
.map((database: DatabaseForm) => (
|
.map((database: DatabaseForm) => (
|
||||||
<Select.Option value={database.engine} key={database.engine}>
|
<Select.Option value={database.name} key={database.name}>
|
||||||
{database.name}
|
{database.name}
|
||||||
</Select.Option>
|
</Select.Option>
|
||||||
))}
|
))}
|
||||||
|
@ -620,7 +620,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
|
||||||
.map((database: DatabaseForm) => (
|
.map((database: DatabaseForm) => (
|
||||||
<IconButton
|
<IconButton
|
||||||
className="preferred-item"
|
className="preferred-item"
|
||||||
onClick={() => setDatabaseModel(database.engine)}
|
onClick={() => setDatabaseModel(database.name)}
|
||||||
buttonText={database.name}
|
buttonText={database.name}
|
||||||
icon={dbImages?.[database.engine]}
|
icon={dbImages?.[database.engine]}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -25,6 +25,7 @@ export type DatabaseObject = {
|
||||||
// Connection + general
|
// Connection + general
|
||||||
id?: number;
|
id?: number;
|
||||||
database_name: string;
|
database_name: string;
|
||||||
|
name: string; // synonym to database_name
|
||||||
sqlalchemy_uri?: string;
|
sqlalchemy_uri?: string;
|
||||||
backend?: string;
|
backend?: string;
|
||||||
created_by?: null | DatabaseUser;
|
created_by?: null | DatabaseUser;
|
||||||
|
|
Loading…
Reference in New Issue