Conversation
fix problems with sql parser fix some other problems
uapasha
left a comment
There was a problem hiding this comment.
Getting errors while performing some queries. Need to investigate further
lib/sql_parser.js
Outdated
| return null; | ||
| } | ||
|
|
||
| function parseHaveingConditions(str) { |
| } | ||
|
|
||
| function setFieldsConstructorsType(fieldsList, LocalState) { | ||
| let isConstructorsFinded = false; |
|
|
||
| return result; | ||
|
|
||
| function determineFieldsBySavedConstructors(fieldsArr, constructors) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
I should use map to return cloned array
| return fieldsArr; | ||
| } | ||
|
|
||
| function determineFieldsByModel(fieldsArr) { |
| } | ||
| } | ||
|
|
||
| function setFieldsConstructorsType(fieldsList, LocalState) { |
There was a problem hiding this comment.
lets use LocalState only inside setSQLQuery function. This setFieldsConstructorsType function should only return some result that we can use for setting to LocalState
| } | ||
| return field; | ||
| }); | ||
| const determineFieldsByModel = (fieldsArr, pivotModel) => { |
There was a problem hiding this comment.
determineFieldsBy... functions could be defined outside of target determineDefaultFields, e.g. as plain file variables
lib/sql_parser.js
Outdated
| return null; | ||
|
|
||
|
|
||
| function removeBraces(queryPart) { |
There was a problem hiding this comment.
can also be moved outside from function.
lib/sql_parser.js
Outdated
|
|
||
| function getWhere(query) { | ||
| let where = query.match(/\swhere\s+([\w([\])"'`.,/=<>\s]+$)/i); | ||
| let where = query.match(/\swhere\s+([\w([\])"'`.,/=<>\s]+$)/im); |
lib/sql_parser.js
Outdated
| const andOr = str.match(/\s+(and|or)\s+/gi); | ||
|
|
||
| if (andOr) { | ||
| let rest = str.slice(); |
lib/sql_parser.js
Outdated
| } else { | ||
| filters.push(str); | ||
| } | ||
| return filters.map((filter, i) => { |
There was a problem hiding this comment.
split to smaller functions
No description provided.