diff --git a/ecs/jskult-webapp/src/repositories/bio_sales_lot_repository.py b/ecs/jskult-webapp/src/repositories/bio_sales_lot_repository.py index f3cbab0b..00dc4b68 100644 --- a/ecs/jskult-webapp/src/repositories/bio_sales_lot_repository.py +++ b/ecs/jskult-webapp/src/repositories/bio_sales_lot_repository.py @@ -101,6 +101,9 @@ class BioSalesLotRepository(BaseRepository): def __build_condition(self, parameter: BioModel): where_clauses: list[SQLCondition] = [] + # 検索条件が指定されずにSQLが壊れることを予防するため、常に真の固定条件を追加しておく + where_clauses.append(SQLCondition('', '', '1 = 1', literal=True)) + # 卸(コード/サブコード) if is_not_empty(parameter.rec_whs_cd) and is_not_empty(parameter.rec_whs_sub_cd): where_clauses.append(SQLCondition('rec_whs_cd', condition.EQ, 'rec_whs_cd')) @@ -141,5 +144,6 @@ class BioSalesLotRepository(BaseRepository): where_clauses.append(SQLCondition('LENGTH(TRIM(rec_lot_num))', condition.GT, '0', literal=True)) where_clauses_str = ' AND '.join([condition.apply() for condition in where_clauses]) + logger.debug(f'条件設定終了:{where_clauses_str}') return where_clauses_str diff --git a/ecs/jskult-webapp/src/repositories/emp_chg_inst_repository.py b/ecs/jskult-webapp/src/repositories/emp_chg_inst_repository.py index ce32a244..fc362257 100644 --- a/ecs/jskult-webapp/src/repositories/emp_chg_inst_repository.py +++ b/ecs/jskult-webapp/src/repositories/emp_chg_inst_repository.py @@ -13,7 +13,7 @@ class EmpChgInstRepository(BaseRepository): def connect(self): self._database.connect() - + def to_jst(self): self._database.to_jst() @@ -179,11 +179,11 @@ class EmpChgInstRepository(BaseRepository): FROM {table_name} AS eci LEFT JOIN mst_inst AS mi - ON eci.inst_cd = mi.inst_cd + ON eci.inst_cd = mi.inst_cd LEFT JOIN emp - ON eci.emp_cd = emp.emp_cd + ON eci.emp_cd = emp.emp_cd LEFT JOIN bu - ON eci.bu_cd = bu.bu_cd + ON eci.bu_cd = bu.bu_cd WHERE {where_clause} """ @@ -206,6 +206,9 @@ class EmpChgInstRepository(BaseRepository): def __build_condition(self, parameter: MasterMainteCsvDlModel): where_clauses: list[SQLCondition] = [] + # 検索条件が指定されずにSQLが壊れることを予防するため、常に真の固定条件を追加しておく + where_clauses.append(SQLCondition('', '', '1 = 1', literal=True)) + # 領域コードが入力されていた場合 if is_not_empty(parameter.ta_cd): parameter.adapt_ta_cd = f'%{parameter.ta_cd}%' @@ -223,62 +226,43 @@ class EmpChgInstRepository(BaseRepository): # 適用期間内が入力されていた場合 if is_not_empty(parameter.adapt_apply_date_from): - where_clauses.append(SQLCondition('eci.start_date', - condition.LE, - 'adapt_apply_date_from')) - where_clauses.append(SQLCondition('eci.end_date', - condition.GE, - 'adapt_apply_date_from')) + where_clauses.append(SQLCondition('eci.start_date', condition.LE, 'adapt_apply_date_from')) + where_clauses.append(SQLCondition('eci.end_date', condition.GE, 'adapt_apply_date_from')) # 適用開始日(FROM)が入力されていた場合 if is_not_empty(parameter.adapt_start_date_from): - where_clauses.append(SQLCondition('eci.start_date', - condition.GE, - 'adapt_start_date_from')) + where_clauses.append(SQLCondition('eci.start_date', condition.GE, 'adapt_start_date_from')) # 適用開始日(TO)が入力されていた場合 if is_not_empty(parameter.adapt_start_date_to): - where_clauses.append(SQLCondition('eci.start_date', - condition.LE, - 'adapt_start_date_to')) + where_clauses.append(SQLCondition('eci.start_date', condition.LE, 'adapt_start_date_to')) # 適用終了日(FROM)が入力されていた場合 if is_not_empty(parameter.adapt_end_date_from): - where_clauses.append(SQLCondition('eci.end_date', - condition.GE, - 'adapt_end_date_from')) + where_clauses.append(SQLCondition('eci.end_date', condition.GE, 'adapt_end_date_from')) # 適用終了日(TO)が入力されていた場合 if is_not_empty(parameter.adapt_end_date_to): - where_clauses.append(SQLCondition('eci.end_date', - condition.LE, - 'adapt_end_date_to')) + where_clauses.append(SQLCondition('eci.end_date', condition.LE, 'adapt_end_date_to')) # データ作成日(FROM)が入力されていた場合 if is_not_empty(parameter.adapt_create_date_from): - where_clauses.append(SQLCondition('eci.create_date', - condition.GE, - 'adapt_create_date_from')) + where_clauses.append(SQLCondition('eci.create_date', condition.GE, 'adapt_create_date_from')) # データ作成日(TO)が入力されていた場合 if is_not_empty(parameter.adapt_create_date_to): - where_clauses.append(SQLCondition('eci.create_date', - condition.LE, - 'adapt_create_date_to')) + where_clauses.append(SQLCondition('eci.create_date', condition.LE, 'adapt_create_date_to')) # データ更新日(FROM)が入力されていた場合 if is_not_empty(parameter.adapt_update_date_from): - where_clauses.append(SQLCondition('eci.update_date', - condition.GE, - 'adapt_update_date_from')) + where_clauses.append(SQLCondition('eci.update_date', condition.GE, 'adapt_update_date_from')) # データ更新日(TO)が入力されていた場合 if is_not_empty(parameter.adapt_update_date_to): - where_clauses.append(SQLCondition('eci.update_date', - condition.LE, - 'adapt_update_date_to')) + where_clauses.append(SQLCondition('eci.update_date', condition.LE, 'adapt_update_date_to')) where_clauses_str = ' AND '.join([condition.apply() for condition in where_clauses]) + logger.debug(f'条件設定終了:{where_clauses_str}') return where_clauses_str diff --git a/ecs/jskult-webapp/src/repositories/ultmarc_doctor_repository.py b/ecs/jskult-webapp/src/repositories/ultmarc_doctor_repository.py index 498733d7..a60a3583 100644 --- a/ecs/jskult-webapp/src/repositories/ultmarc_doctor_repository.py +++ b/ecs/jskult-webapp/src/repositories/ultmarc_doctor_repository.py @@ -72,6 +72,9 @@ class UltmarcDoctorRepository(BaseRepository): def __build_condition(self, parameter: UltmarcDoctorSearchModel): where_clauses: list[SQLCondition] = [] + # 検索条件が指定されずにSQLが壊れることを予防するため、常に真の固定条件を追加しておく + where_clauses.append(SQLCondition('', '', '1 = 1', literal=True)) + # 医師コード if is_not_empty(parameter.dcf_pcf_dr_cd): # 必ず部分一致で検索 diff --git a/ecs/jskult-webapp/src/repositories/ultmarc_inst_repository.py b/ecs/jskult-webapp/src/repositories/ultmarc_inst_repository.py index 64eb0796..3b485402 100644 --- a/ecs/jskult-webapp/src/repositories/ultmarc_inst_repository.py +++ b/ecs/jskult-webapp/src/repositories/ultmarc_inst_repository.py @@ -58,6 +58,9 @@ class UltmarcInstRepository(BaseRepository): def __build_condition(self, parameter: UltmarcInstSearchModel): where_clauses: list[SQLCondition] = [] + # 検索条件が指定されずにSQLが壊れることを予防するため、常に真の固定条件を追加しておく + where_clauses.append(SQLCondition('', '', '1 = 1', literal=True)) + # ULT施設コード if is_not_empty(parameter.dcf_dsf_inst_cd): # 部分一致検索