Skip to content

Commit

Permalink
Merge pull request #100 from open-source-labs/roadmap
Browse files Browse the repository at this point in the history
bugfix: resolved issue preventing mysql from showing up without postgres
  • Loading branch information
haemie authored Jul 10, 2023
2 parents e9bb765 + 305ad36 commit 35a6790
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
1 change: 0 additions & 1 deletion backend/ertable-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
AlterTablesObjType,
AlterColumnsObjType,
AddConstraintObjType,
AddColumnsObjType,
} from '../frontend/types';

import { BackendObjType, DBType } from './BE_types';
Expand Down
18 changes: 6 additions & 12 deletions backend/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ const DBFunctions: DBFunctions = {
pool
.query(query)
.then((databases) => {
for (let i = 0; i < databases.rows.length; i++) {
for (let i = 0; i < databases.rows.length; i += 1) {
const data = databases.rows[i];
const { db_name } = data;

Expand Down Expand Up @@ -489,17 +489,11 @@ const DBFunctions: DBFunctions = {
pool
.query(query)
.then((databases) => {
for (let i = 0; i < databases[0].length; i++) {
for (let i = 0; i < databases[0].length; i += 1) {
const data = databases[0][i];
const { db_name } = data;
if (
db_name !== 'postgres' &&
db_name !== 'template0' &&
db_name !== 'template1'
) {
data.db_type = dbType;
dbList.push(data);
}
data.db_type = dbType;
data.db_size = data.db_size ? `${data.db_size}KB` : '0KB';
dbList.push(data);
}

logger("MySQL 'getDBNames' resolved.", LogType.SUCCESS);
Expand All @@ -519,7 +513,7 @@ const DBFunctions: DBFunctions = {
const stats = fs.statSync(path)
const fileSizeInKB = stats.size / 1024;
// Convert the file size to megabytes (optional)
const data = { db_name: filename, db_size: `${fileSizeInKB}kB`, db_type: DBType.SQLite }
const data = { db_name: filename, db_size: `${fileSizeInKB}KB`, db_type: DBType.SQLite }
dbList.push(data);
resolve(dbList);
}
Expand Down
10 changes: 5 additions & 5 deletions frontend/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ const App = () => {
if (isDbLists(dbLists)) {
setDBInfo(dbLists.databaseList);
setTables(dbLists.tableList);
setPGStatus(dbLists.databaseConnected[0]);
setMYSQLStatus(dbLists.databaseConnected[1]);
setPGStatus(dbLists.databaseConnected.PG);
setMYSQLStatus(dbLists.databaseConnected.MySQL);

setSelectedTable(selectedTable || dbTables[0]);
}
Expand Down Expand Up @@ -149,7 +149,7 @@ const App = () => {
case 'newSchemaView':
shownView = 'newSchemaView';
break;
case 'threeDView':
case 'threeDView':
shownView = 'threeDView';
break;
case 'quickStartView':
Expand Down Expand Up @@ -220,10 +220,10 @@ const App = () => {
/>
<QuickStartView show={shownView === 'quickStartView'} />

<ThreeDView
<ThreeDView
show={shownView === 'threeDView'}
selectedDb={selectedDb}
dbTables={dbTables}
dbTables={dbTables}
dbType={curDBType}
/>

Expand Down
13 changes: 10 additions & 3 deletions frontend/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,14 @@ export interface TableInfo {
}

export interface DbLists {
databaseConnected: boolean[];
databaseConnected: {
PG: boolean,
MySQL: boolean,
RDSPG: boolean,
RDSMySQL: boolean,
SQLite: boolean,
directPGURI: boolean,
};
databaseList: DatabaseInfo[];
tableList: TableInfo[];
dbType: DBType;
Expand All @@ -180,8 +187,8 @@ export const isDbLists = (obj: unknown): obj is DbLists => {
return false;
if (obj.databaseList[0] && typeof obj.databaseList[0].db_name !== 'string')
return false;
if (obj.databaseList[0] && typeof obj.databaseList[0].db_size !== 'string')
return false;
// if (obj.databaseList[0] && typeof obj.databaseList[0].db_size !== 'string' )
// return false;
if (obj.tableList[0] && typeof obj.tableList[0].table_name !== 'string')
return false;
if (obj.tableList[0] && typeof obj.tableList[0].table_catalog !== 'string')
Expand Down

0 comments on commit 35a6790

Please sign in to comment.