Skip to content

Commit e43d910

Browse files
authored
Upper case the SQL queries. (#330)
1 parent d615b0e commit e43d910

1 file changed

Lines changed: 39 additions & 39 deletions

File tree

sz_tools/sz_snapshot

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -165,42 +165,42 @@ class SnapshotReader:
165165

166166
self.sz_dbo = SzDatabase(self.engine_config, print_import_messages=False)
167167
sql_entities = (
168-
"select "
169-
" a.RES_ENT_ID as RESOLVED_ENTITY_ID, "
170-
" a.ERRULE_ID, "
171-
" a.MATCH_KEY, "
172-
" b.DSRC_ID, "
173-
" c.RECORD_ID "
174-
"from RES_ENT_OKEY a "
175-
"join OBS_ENT b on b.OBS_ENT_ID = a.OBS_ENT_ID "
176-
"join DSRC_RECORD c on c.ENT_SRC_KEY = b.ENT_SRC_KEY and c.DSRC_ID = b.DSRC_ID "
177-
"where a.RES_ENT_ID = ?"
168+
"SELECT "
169+
" A.RES_ENT_ID AS RESOLVED_ENTITY_ID, "
170+
" A.ERRULE_ID, "
171+
" A.MATCH_KEY, "
172+
" B.DSRC_ID, "
173+
" C.RECORD_ID "
174+
"FROM RES_ENT_OKEY A "
175+
"JOIN OBS_ENT B ON B.OBS_ENT_ID = A.OBS_ENT_ID "
176+
"JOIN DSRC_RECORD C ON C.ENT_SRC_KEY = B.ENT_SRC_KEY AND C.DSRC_ID = B.DSRC_ID "
177+
"WHERE A.RES_ENT_ID = ?"
178178
)
179179
self.sql_entities = self.sz_dbo.sql_prep(sql_entities)
180180
sql_relations = (
181-
"select "
182-
" a.RES_ENT_ID as RESOLVED_ENTITY_ID, "
183-
" a.REL_ENT_ID as RELATED_ENTITY_ID, "
184-
" b.LAST_ERRULE_ID as ERRULE_ID, "
185-
" b.IS_DISCLOSED, "
186-
" b.IS_AMBIGUOUS, "
187-
" b.MATCH_KEY, "
188-
" d.DSRC_ID "
189-
"from RES_REL_EKEY a "
190-
"join RES_RELATE b on b.RES_REL_ID = a.RES_REL_ID "
191-
"join RES_ENT_OKEY c on c.RES_ENT_ID = a.REL_ENT_ID "
192-
"join OBS_ENT d on d.OBS_ENT_ID = c.OBS_ENT_ID "
193-
"where a.RES_ENT_ID = ?"
181+
"SELECT "
182+
" A.RES_ENT_ID AS RESOLVED_ENTITY_ID, "
183+
" A.REL_ENT_ID AS RELATED_ENTITY_ID, "
184+
" B.LAST_ERRULE_ID AS ERRULE_ID, "
185+
" B.IS_DISCLOSED, "
186+
" B.IS_AMBIGUOUS, "
187+
" B.MATCH_KEY, "
188+
" D.DSRC_ID "
189+
"FROM RES_REL_EKEY A "
190+
"JOIN RES_RELATE B ON B.RES_REL_ID = A.RES_REL_ID "
191+
"JOIN RES_ENT_OKEY C ON C.RES_ENT_ID = A.REL_ENT_ID "
192+
"JOIN OBS_ENT D ON D.OBS_ENT_ID = C.OBS_ENT_ID "
193+
"WHERE A.RES_ENT_ID = ?"
194194
)
195195
self.sql_relations = self.sz_dbo.sql_prep(sql_relations)
196196
# below not currently used in favor of sdk as does a better job identifying unique features
197197
sql_features = (
198-
"select "
198+
"SELECT "
199199
" FTYPE_ID "
200-
"from RES_FEAT_EKEY a "
201-
"where RES_ENT_ID = ?"
202-
"and FTYPE_ID in (" + ",".join(str(x) for x in self.esb_ftype_ids) + ")"
203-
"and SUPPRESSED = 'N'"
200+
"FROM RES_FEAT_EKEY A "
201+
"WHERE RES_ENT_ID = ?"
202+
"AND FTYPE_ID IN (" + ",".join(str(x) for x in self.esb_ftype_ids) + ")"
203+
"AND SUPPRESSED = 'N'"
204204
)
205205
self.sql_features = self.sz_dbo.sql_prep(sql_features)
206206

@@ -570,20 +570,20 @@ def database_snapshot(sz_dbo, kwargs):
570570
entity_sql = "select RES_ENT_ID from RES_ENT where RES_ENT_ID between ? and ?"
571571
else:
572572
max_sql = (
573-
"select "
574-
" min(b.RES_ENT_ID), "
575-
" max(b.RES_ENT_ID) "
576-
"from OBS_ENT a "
577-
"join RES_ENT_OKEY b on b.OBS_ENT_ID = a.OBS_ENT_ID "
578-
"where a.DSRC_ID = " + str(dsrc_id_filter)
573+
"SELECT "
574+
" MIN(B.RES_ENT_ID), "
575+
" MAX(B.RES_ENT_ID) "
576+
"FROM OBS_ENT A "
577+
"JOIN RES_ENT_OKEY B ON B.OBS_ENT_ID = A.OBS_ENT_ID "
578+
"WHERE A.DSRC_ID = " + str(dsrc_id_filter)
579579
)
580580
min_entity_id, max_entity_id = sz_dbo.fetch_row(sz_dbo.sql_exec(max_sql))
581581
entity_sql = (
582-
"select distinct"
583-
" a.RES_ENT_ID "
584-
"from RES_ENT_OKEY a "
585-
"join OBS_ENT b on b.OBS_ENT_ID = a.OBS_ENT_ID "
586-
"where a.RES_ENT_ID between ? and ? and b.DSRC_ID = " + str(dsrc_id_filter)
582+
"SELECT DISTINCT"
583+
" A.RES_ENT_ID "
584+
"FROM RES_ENT_OKEY A "
585+
"JOIN OBS_ENT B ON B.OBS_ENT_ID = A.OBS_ENT_ID "
586+
"WHERE A.RES_ENT_ID BETWEEN ? AND ? AND B.DSRC_ID = " + str(dsrc_id_filter)
587587
)
588588

589589
if not max_entity_id:

0 commit comments

Comments
 (0)