track table in run_sql handles schema name and table name separately (close #484) (#685)

This commit is contained in:
Aravind Shankar 2018-10-10 10:34:19 +05:30 committed by Shahidh K Muhammed
parent 5916b97b86
commit 40c391df09
3 changed files with 88 additions and 82 deletions

View File

@ -38,7 +38,6 @@ class Main extends React.Component {
let isUpdateAvailable = false; let isUpdateAvailable = false;
try { try {
const showEvents = semverCheck('eventsTab', this.props.serverVersion); const showEvents = semverCheck('eventsTab', this.props.serverVersion);
console.log(showEvents);
if (showEvents) { if (showEvents) {
this.setState({ showEvents: true }); this.setState({ showEvents: true });
} }

View File

@ -52,7 +52,7 @@ const DataHeader = ({
className={styles.schemaBorder} className={styles.schemaBorder}
to={appPrefix + '/schema'} to={appPrefix + '/schema'}
> >
Schema Schema - {currentSchema}
</Link> </Link>
</div> </div>
</div> </div>

View File

@ -34,7 +34,7 @@ const executeSQL = isMigration => (dispatch, getState) => {
const currMigrationMode = getState().main.migrationMode; const currMigrationMode = getState().main.migrationMode;
const migrateUrl = returnMigrateUrl(currMigrationMode); const migrateUrl = returnMigrateUrl(currMigrationMode);
const currentSchema = getState().tables.currentSchema; let currentSchema = 'public';
const isCascadeChecked = getState().rawSQL.isCascadeChecked; const isCascadeChecked = getState().rawSQL.isCascadeChecked;
let url = Endpoints.rawSQL; let url = Endpoints.rawSQL;
@ -46,11 +46,18 @@ const executeSQL = isMigration => (dispatch, getState) => {
]; ];
// check if track view enabled // check if track view enabled
if (getState().rawSQL.isTableTrackChecked) { if (getState().rawSQL.isTableTrackChecked) {
const regExp = /create (view|table) (\S+)/i; const regExp = /create (view|table) ((\S+)\.(\S+)|(\S+))/i;
const matches = sql.match(regExp); const matches = sql.match(regExp);
let trackViewName = matches ? matches[2] : ''; // If group 5 is undefined, use group 3 and 4 for schema and table respectively
if (trackViewName.indexOf('.') !== -1) { // If group 5 is present, use group 5 for table name using public schema.
trackViewName = matches[2].split('.')[1]; let trackViewName = '';
if (matches && matches.length === 6) {
if (matches[5]) {
trackViewName = matches[5];
} else {
currentSchema = matches[3].replace(/['"]+/g, '');
trackViewName = matches[4];
}
} }
trackViewName = trackViewName.replace(/['"]+/g, ''); // replace quotes trackViewName = trackViewName.replace(/['"]+/g, ''); // replace quotes
const trackQuery = { const trackQuery = {