Skip to content

Commit

Permalink
FIX : null value in search
Browse files Browse the repository at this point in the history
  • Loading branch information
juliecoust committed Jul 31, 2024
1 parent b77ef61 commit 7bf005b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class SQLiteInstrumentModelDataSource implements InstrumentModelDataSourc
async create(instrument_model: InstrumentModelRequestCreationModel): Promise<number> {
const params = [instrument_model.instrument_model_name, instrument_model.bodc_url];
const placeholders = params.map(() => '(?)').join(','); // TODO create tool funct
const sql = `INSERT INTO instrument_model (instrument_model, bodc_url) VALUES (` + placeholders + `);`;
const sql = `INSERT INTO instrument_model (instrument_model_name, bodc_url) VALUES (` + placeholders + `);`;

return await new Promise((resolve, reject) => {
this.db.run(sql, params, function (err) {
Expand Down Expand Up @@ -79,7 +79,7 @@ export class SQLiteInstrumentModelDataSource implements InstrumentModelDataSourc
filtering_sql += filter.field + ` = 0`;
}
// If value is undefined, null or empty, and operator =, set to is null
else if (filter.value == undefined || filter.value == null || filter.value == "") {
else if (filter.value == "null") {
if (filter.operator == "=") {
filtering_sql += filter.field + ` IS NULL`;
} else if (filter.operator == "!=") {
Expand Down
4 changes: 2 additions & 2 deletions src/data/data-sources/sqlite/sqlite-privilege-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class SQLitePrivilegeDataSource implements PrivilegeDataSource {
filtering_sql += "privilege." + filter.field + ` = 0`;
}
// If value is undefined, null or empty, and operator =, set to is null
else if (filter.value == undefined || filter.value == null || filter.value == "") {
else if (filter.value == "null") {
if (filter.operator == "=") {
filtering_sql += "privilege." + filter.field + ` IS NULL`;
} else if (filter.operator == "!=") {
Expand Down Expand Up @@ -216,7 +216,7 @@ export class SQLitePrivilegeDataSource implements PrivilegeDataSource {
// remove last AND
placeholders = placeholders.slice(0, -4);
// form final sql
const sql = `SELECT privilege.*, user.first_name, user.last_name, user.email, FROM privilege LEFT JOIN user ON privilege.user_id = user.user_id WHERE ` + placeholders + `LIMIT 1;`;
const sql = `SELECT privilege.*, user.first_name, user.last_name, user.email FROM privilege LEFT JOIN user ON privilege.user_id = user.user_id WHERE ` + placeholders + `LIMIT 1;`;
return await new Promise((resolve, reject) => {
this.db.get(sql, params, (err, row) => {
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion src/data/data-sources/sqlite/sqlite-project-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class SQLiteProjectDataSource implements ProjectDataSource {
filtering_sql += filter.field + ` = 0`;
}
// If value is undefined, null or empty, and operator =, set to is null
else if (filter.value == undefined || filter.value == null || filter.value == "") {
else if (filter.value == "null") {
if (filter.operator == "=") {
filtering_sql += filter.field + ` IS NULL`;
} else if (filter.operator == "!=") {
Expand Down
2 changes: 1 addition & 1 deletion src/data/data-sources/sqlite/sqlite-user-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class SQLiteUserDataSource implements UserDataSource {
filtering_sql += filter.field + ` = 0`;
}
// If value is undefined, null or empty, and operator =, set to is null
else if (filter.value == undefined || filter.value == null || filter.value == "") {
else if (filter.value == "null") {
if (filter.operator == "=") {
filtering_sql += filter.field + ` IS NULL`;
} else if (filter.operator == "!=") {
Expand Down

0 comments on commit 7bf005b

Please sign in to comment.