Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T360 sql editor bug #28

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

T360 sql editor bug #28

wants to merge 11 commits into from

Conversation

BagrijRoman
Copy link
Collaborator

No description provided.

@BagrijRoman BagrijRoman requested a review from uapasha May 16, 2017 14:07
@BagrijRoman BagrijRoman self-assigned this May 16, 2017
Copy link
Contributor

@uapasha uapasha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting errors while performing some queries. Need to investigate further

@@ -148,6 +191,33 @@ function getOffset(query) {
return null;
}

function parseHaveingConditions(str) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in Haveing

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -109,3 +112,25 @@ function resetData(LocalState) {
LocalState.set('VIEW_OBJECT', viewObj);
}
}

function setFieldsConstructorsType(fieldsList, LocalState) {
let isConstructorsFinded = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isConstructorsFound

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return result;

function determineFieldsBySavedConstructors(fieldsArr, constructors) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, don't mutate function parameter fieldsArr http://eslint.org/docs/rules/no-param-reassign
It is better to create a clone and make manipulations on it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should use map to return cloned array

return fieldsArr;
}

function determineFieldsByModel(fieldsArr) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same with mutations here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@@ -109,3 +112,25 @@ function resetData(LocalState) {
LocalState.set('VIEW_OBJECT', viewObj);
}
}

function setFieldsConstructorsType(fieldsList, LocalState) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets use LocalState only inside setSQLQuery function. This setFieldsConstructorsType function should only return some result that we can use for setting to LocalState

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}
return field;
});
const determineFieldsByModel = (fieldsArr, pivotModel) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

determineFieldsBy... functions could be defined outside of target determineDefaultFields, e.g. as plain file variables

}
return null;


function removeBraces(queryPart) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can also be moved outside from function.

}

function getWhere(query) {
let where = query.match(/\swhere\s+([\w([\])"'`.,/=<>\s]+$)/i);
let where = query.match(/\swhere\s+([\w([\])"'`.,/=<>\s]+$)/im);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace let

const andOr = str.match(/\s+(and|or)\s+/gi);

if (andOr) {
let rest = str.slice();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove let

} else {
filters.push(str);
}
return filters.map((filter, i) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

split to smaller functions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants