Skip to content

Commit

Permalink
fix bug with apostrophes in the search terms
Browse files Browse the repository at this point in the history
  • Loading branch information
KeithKelleher committed Mar 31, 2021
1 parent c036516 commit d611ccf
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/TCRD.js
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ and f.itype = ?`, [filter.order]));
for (var i in args.filter.facets) {
let f = args.filter.facets[i];
if ('type' == f.facet) {
q.whereRaw(`ppitypes REGEXP '${f.values.join("|")}'`);
q.whereRaw(`ppitypes REGEXP "${f.values.join('|')}"`);
} else {
q = q.whereIn(f.facet, f.values);
}
Expand Down
2 changes: 1 addition & 1 deletion src/models/FieldInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class FieldInfo {
}
} else {
if (this.valuesDelimited) {
query.where(this.parent.database.raw(`${this.select} REGEXP '${this.allowedValues.join('|')}'`));
query.where(this.parent.database.raw(`${this.select} REGEXP "${this.allowedValues.join('|')}"`));
} else {
query.whereIn(this.parent.database.raw(this.select), this.allowedValues);
}
Expand Down
4 changes: 2 additions & 2 deletions src/models/disease/diseaseList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class DiseaseList extends DataModelList {
static getDescendentsQuery(knex: any, diseaseName: string) {
let finderQuery = knex("ncats_do")
.min({lft: 'lft', rght: 'rght'})
.whereRaw(`name = "?"`, diseaseName);
.whereRaw(`name = ?`, diseaseName);
let query = knex({lst: 'ncats_do', finder: finderQuery})
.select('lst.name')
.where('finder.lft', '<=', knex.raw('lst.lft'))
Expand Down Expand Up @@ -110,7 +110,7 @@ export class DiseaseList extends DataModelList {
getAssociatedTargetQuery(): any {
return this.database({ncats_disease: 'ncats_disease', ncats_d2da: 'ncats_d2da', disease: 'disease', protein: 'protein'})
.distinct({name: this.keyString()}).count('* as associationCount')
.whereRaw(this.database.raw(`match(uniprot,sym,stringid) against('${this.associatedTarget}' in boolean mode)`))
.whereRaw(this.database.raw(`match(uniprot,sym,stringid) against("${this.associatedTarget}" in boolean mode)`))
.andWhere('ncats_disease.id', this.database.raw('ncats_d2da.ncats_disease_id'))
.andWhere('ncats_d2da.disease_assoc_id', this.database.raw('disease.id'))
.andWhere('disease.protein_id', this.database.raw(`protein.id`))
Expand Down
2 changes: 1 addition & 1 deletion src/models/ligand/ligandList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class LigandList extends DataModelList {
protein: "protein"
})
.distinct("ncats_ligands.identifier")
.whereRaw(this.database.raw(`match(uniprot,sym,stringid) against('${this.associatedTarget}' in boolean mode)`))
.whereRaw(this.database.raw(`match(uniprot,sym,stringid) against("${this.associatedTarget}" in boolean mode)`))
.andWhere(this.database.raw(`ncats_ligands.id = ncats_ligand_activity.ncats_ligand_id`))
.andWhere(this.database.raw(`ncats_ligand_activity.target_id = t2tc.target_id`))
.andWhere(this.database.raw(`t2tc.protein_id = protein.id`)).as('assocTarget');
Expand Down
2 changes: 1 addition & 1 deletion src/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,7 @@ const resolvers = {
reference: 'reference',
pubs: 'pubmed_ids'
})
.whereRaw(`ncats_ligands.identifier = '${ligand.ligid}'`)
.whereRaw(`ncats_ligands.identifier = "${ligand.ligid}"`)
.andWhere(dataSources.tcrd.db.raw(`ncats_ligand_activity.ncats_ligand_id = ncats_ligands.id`));
if (dataSources.associatedTargetTCRDID) {
query.andWhere(dataSources.tcrd.db.raw(`ncats_ligand_activity.target_id = ${dataSources.associatedTargetTCRDID}`));
Expand Down
2 changes: 1 addition & 1 deletion src/target_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module.exports.getProteinListFromPPI = function(ppiTarget, confidence) {
let proteinIDquery = this.db("protein")
.select("id").whereRaw(this.db.raw(`match(uniprot,sym,stringid) against('${ppiTarget}' in boolean mode)`));
.select("id").whereRaw(this.db.raw(`match(uniprot,sym,stringid) against("${ppiTarget}" in boolean mode)`));
let ppiListQuery = this.db("ncats_ppi")
.select(this.db.raw('distinct other_id as protein_id'))
.whereIn('protein_id', proteinIDquery)
Expand Down

0 comments on commit d611ccf

Please sign in to comment.