kylefarris / node-querybuilder

Node QueryBuilder Adapter for Node.js (tags: nodejs, node, mysql, active record, activerecord, querybuilder, query builder)
49 stars 19 forks source link

Issue with ` sign .I want to escape this sign #9

Closed agravatfemina closed 7 years ago

agravatfemina commented 7 years ago

queryBuilder.join('tbl_user as u','CASE WHEN m.iMsgTo ='+params.iUserID+' THEN m.iMsgFrom = u.user_id WHEN m.iMsgFrom ='+params.iUserID+' THEN m.iMsgTo = u.user_id END','INNER');

This is a subpart of query. When I am executing this query query builder is adding CASE WHEN .Please help me with this. i don't want to add this ` sign with join on query.

Need help ASAP.

kylefarris commented 7 years ago

@agravatfemina I've fixed this for you in the latest version (v.0.15.0). join method had an undocumented and not-fully-working escape parameter. It used to just escape the table name but now it will not escape the conditions of the join as well.

I've updated the documentation, but, all you should need to do now is this:

queryBuilder.join(
    'tbl_user as u', 
    'CASE WHEN m.iMsgTo ='+params.iUserID+' THEN m.iMsgFrom = u.user_id WHEN m.iMsgFrom ='+params.iUserID+' THEN m.iMsgTo = u.user_id END', 
    'INNER',
    false
);

Notice the final false parameter.

Hope that helps!