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;
try {
const showEvents = semverCheck('eventsTab', this.props.serverVersion);
console.log(showEvents);
if (showEvents) {
this.setState({ showEvents: true });
}
@ -312,30 +311,30 @@ class Main extends React.Component {
</div>
{!this.state.loveConsentState.isDismissed
? [
<div
key="main_love_1"
className={styles.shareSection + ' dropdown-toggle'}
aria-expanded="false"
onClick={this.handleDropdownToggle.bind(this)}
>
<img
className={'img-responsive'}
src={pixHeart}
alt={'pix Heart'}
/>
{/* <i className={styles.heart + ' fa fa-heart'} /> */}
</div>,
<ul
key="main_love_2"
className={'dropdown-menu ' + styles.dropdown_menu}
>
<div className={styles.dropdown_menu_container}>
<div className={styles.closeDropDown}>
<i
className="fa fa-close"
onClick={this.closeLoveIcon.bind(this)}
/>
{/*
<div
key="main_love_1"
className={styles.shareSection + ' dropdown-toggle'}
aria-expanded="false"
onClick={this.handleDropdownToggle.bind(this)}
>
<img
className={'img-responsive'}
src={pixHeart}
alt={'pix Heart'}
/>
{/* <i className={styles.heart + ' fa fa-heart'} /> */}
</div>,
<ul
key="main_love_2"
className={'dropdown-menu ' + styles.dropdown_menu}
>
<div className={styles.dropdown_menu_container}>
<div className={styles.closeDropDown}>
<i
className="fa fa-close"
onClick={this.closeLoveIcon.bind(this)}
/>
{/*
<img
className={'img-responsive'}
src={closeIcon}
@ -343,8 +342,8 @@ class Main extends React.Component {
onClick={this.closeLoveIcon.bind(this)}
/>
*/}
</div>
{/*
</div>
{/*
<div className={styles.arrow_up_dropdown} />
<div className={styles.graphqlHeartText}>
Love GraphQL Engine? Shout it from the rooftops!
@ -355,37 +354,37 @@ class Main extends React.Component {
</span>
</div>
*/}
<div className={styles.displayFlex}>
<li className={styles.pixelText1}>
<div className={styles.displayFlex}>
<li className={styles.pixelText1}>
Roses are red, <br />
Violets are blue;
<br />
<br />
Star us on Github,
<br />
<br />
To make our <i className={'fa fa-heart'} /> go
wooooo!
</li>
<li className={'dropdown-item'}>
<a
href="https://github.com/hasura/graphql-engine"
target="_blank"
rel="noopener noreferrer"
>
<div className={styles.socialIcon}>
<img
className="img img-responsive"
src={
'https://storage.googleapis.com/hasura-graphql-engine/console/assets/githubicon.png'
}
alt={'Github'}
/>
</div>
<div className={styles.pixelText}>
<i className="fa fa-star" />
</li>
<li className={'dropdown-item'}>
<a
href="https://github.com/hasura/graphql-engine"
target="_blank"
rel="noopener noreferrer"
>
<div className={styles.socialIcon}>
<img
className="img img-responsive"
src={
'https://storage.googleapis.com/hasura-graphql-engine/console/assets/githubicon.png'
}
alt={'Github'}
/>
</div>
<div className={styles.pixelText}>
<i className="fa fa-star" />
&nbsp; Star
</div>
</a>
{/*
</div>
</a>
{/*
<div className={styles.gitHubBtn}>
<iframe
title="github"
@ -397,32 +396,32 @@ class Main extends React.Component {
/>
</div>
*/}
</li>
<li className={'dropdown-item '}>
<a
href="https://twitter.com/intent/tweet?hashtags=graphql,postgres&text=Just%20deployed%20a%20GraphQL%20backend%20with%20@HasuraHQ!%20%E2%9D%A4%EF%B8%8F%20%F0%9F%9A%80%0Ahttps://github.com//hasura/graphql-engine%0A"
target="_blank"
rel="noopener noreferrer"
>
<div className={styles.socialIcon}>
<img
className="img img-responsive"
src={
'https://storage.googleapis.com/hasura-graphql-engine/console/assets/twittericon.png'
}
alt={'Twitter'}
/>
</div>
<div className={styles.pixelText}>
<i className="fa fa-twitter" />
</li>
<li className={'dropdown-item '}>
<a
href="https://twitter.com/intent/tweet?hashtags=graphql,postgres&text=Just%20deployed%20a%20GraphQL%20backend%20with%20@HasuraHQ!%20%E2%9D%A4%EF%B8%8F%20%F0%9F%9A%80%0Ahttps://github.com//hasura/graphql-engine%0A"
target="_blank"
rel="noopener noreferrer"
>
<div className={styles.socialIcon}>
<img
className="img img-responsive"
src={
'https://storage.googleapis.com/hasura-graphql-engine/console/assets/twittericon.png'
}
alt={'Twitter'}
/>
</div>
<div className={styles.pixelText}>
<i className="fa fa-twitter" />
&nbsp; Tweet
</div>
</a>
</li>
</div>
</a>
</li>
</div>
</div>
</div>
</ul>,
]
</ul>,
]
: null}
</div>
</div>

View File

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

View File

@ -34,7 +34,7 @@ const executeSQL = isMigration => (dispatch, getState) => {
const currMigrationMode = getState().main.migrationMode;
const migrateUrl = returnMigrateUrl(currMigrationMode);
const currentSchema = getState().tables.currentSchema;
let currentSchema = 'public';
const isCascadeChecked = getState().rawSQL.isCascadeChecked;
let url = Endpoints.rawSQL;
@ -46,11 +46,18 @@ const executeSQL = isMigration => (dispatch, getState) => {
];
// check if track view enabled
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);
let trackViewName = matches ? matches[2] : '';
if (trackViewName.indexOf('.') !== -1) {
trackViewName = matches[2].split('.')[1];
// If group 5 is undefined, use group 3 and 4 for schema and table respectively
// If group 5 is present, use group 5 for table name using public schema.
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
const trackQuery = {