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

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 = {