@@ -142,33 +142,19 @@ def insert_into_new_tables():
142142 ]
143143 op .bulk_insert (meta .tables ["entity_class" ], entity_classes )
144144 # Id mappings
145- obj_cls_to_ent_cls = {
146- r .object_class_id : r .entity_class_id
147- for r in conn .execute (
148- text (
149- """
145+ obj_cls_to_ent_cls = {r .object_class_id : r .entity_class_id for r in conn .execute (text ("""
150146 SELECT object_class.id AS object_class_id, entity_class.id AS entity_class_id
151147 FROM object_class, entity_class
152148 WHERE entity_class.type_id = 1
153149 AND object_class.name = entity_class.name
154- """
155- )
156- )
157- }
158- rel_cls_to_ent_cls = {
159- r .relationship_class_id : r .entity_class_id
160- for r in conn .execute (
161- text (
162- """
150+ """ ))}
151+ rel_cls_to_ent_cls = {r .relationship_class_id : r .entity_class_id for r in conn .execute (text ("""
163152 SELECT relationship_class.id AS relationship_class_id, entity_class.id AS entity_class_id
164153 FROM relationship_class, entity_class
165154 WHERE entity_class.type_id = 2
166155 AND relationship_class.name = entity_class.name
167156 GROUP BY relationship_class_id, entity_class_id
168- """
169- )
170- )
171- }
157+ """ ))}
172158 temp_relationship_classes = [
173159 {"entity_class_id" : r .id , "type_id" : 2 , "commit_id" : r .commit_id }
174160 for r in conn .execute (text ("SELECT id, commit_id FROM entity_class WHERE type_id = 2" ))
@@ -195,33 +181,19 @@ def insert_into_new_tables():
195181 ]
196182 op .bulk_insert (meta .tables ["entity" ], entities )
197183 # Id mappings
198- obj_to_ent = {
199- r .object_id : r .entity_id
200- for r in conn .execute (
201- text (
202- """
184+ obj_to_ent = {r .object_id : r .entity_id for r in conn .execute (text ("""
203185 SELECT object.id AS object_id, entity.id AS entity_id
204186 FROM object, entity
205187 WHERE entity.type_id = 1
206188 AND object.name = entity.name
207- """
208- )
209- )
210- }
211- rel_to_ent = {
212- r .relationship_id : r .entity_id
213- for r in conn .execute (
214- text (
215- """
189+ """ ))}
190+ rel_to_ent = {r .relationship_id : r .entity_id for r in conn .execute (text ("""
216191 SELECT relationship.id AS relationship_id, entity.id AS entity_id
217192 FROM relationship, entity
218193 WHERE entity.type_id = 2
219194 AND relationship.name = entity.name
220195 GROUP BY relationship_id, entity_id
221- """
222- )
223- )
224- }
196+ """ ))}
225197 temp_relationships = [
226198 {"entity_id" : r .id , "entity_class_id" : r .class_id , "type_id" : 2 , "commit_id" : r .commit_id }
227199 for r in conn .execute (text ("SELECT id, class_id, commit_id FROM entity WHERE type_id = 2" ))
@@ -236,15 +208,11 @@ def insert_into_new_tables():
236208 "member_class_id" : obj_cls_to_ent_cls [r .object_class_id ],
237209 "commit_id" : r .commit_id ,
238210 }
239- for r in conn .execute (
240- text (
241- """
211+ for r in conn .execute (text ("""
242212 SELECT r.id, r.class_id, r.dimension, o.class_id AS object_class_id, r.object_id, r.commit_id
243213 FROM relationship AS r, object AS o
244214 WHERE r.object_id = o.id
245- """
246- )
247- )
215+ """ ))
248216 ]
249217 op .bulk_insert (meta .tables ["relationship_entity" ], relationship_entities )
250218 # Return metadata and id mappings
@@ -309,25 +277,21 @@ def update_tables(meta, obj_cls_to_ent_cls, rel_cls_to_ent_cls, obj_to_ent, rel_
309277 {"entity_class_id" : entity_class_id , "object_class_id" : object_class_id },
310278 )
311279 conn .execute (
312- text (
313- """
280+ text ("""
314281 UPDATE parameter_definition SET entity_class_id = :entity_class_id
315282 WHERE object_class_id = :object_class_id
316- """
317- ),
283+ """ ),
318284 {
319285 "entity_class_id" : entity_class_id ,
320286 "object_class_id" : object_class_id ,
321287 },
322288 )
323289 for relationship_class_id , entity_class_id in rel_cls_to_ent_cls .items ():
324290 conn .execute (
325- text (
326- """
291+ text ("""
327292 UPDATE parameter_definition SET entity_class_id = :entity_class_id
328293 WHERE relationship_class_id = :relationship_class_id
329- """
330- ),
294+ """ ),
331295 {
332296 "entity_class_id" : entity_class_id ,
333297 "relationship_class_id" : relationship_class_id ,
@@ -343,12 +307,10 @@ def update_tables(meta, obj_cls_to_ent_cls, rel_cls_to_ent_cls, obj_to_ent, rel_
343307 )
344308 entity_class_id = ent_to_ent_cls [entity_id ]
345309 conn .execute (
346- text (
347- """
310+ text ("""
348311 UPDATE parameter_value SET entity_id = :entity_id, entity_class_id = :entity_class_id
349312 WHERE object_id = :object_id
350- """
351- ),
313+ """ ),
352314 {
353315 "entity_id" : entity_id ,
354316 "entity_class_id" : entity_class_id ,
@@ -358,12 +320,10 @@ def update_tables(meta, obj_cls_to_ent_cls, rel_cls_to_ent_cls, obj_to_ent, rel_
358320 for relationship_id , entity_id in rel_to_ent .items ():
359321 entity_class_id = ent_to_ent_cls [entity_id ]
360322 conn .execute (
361- text (
362- """
323+ text ("""
363324 UPDATE parameter_value SET entity_id = :entity_id, entity_class_id = :entity_class_id
364325 WHERE relationship_id = :relationship_id
365- """
366- ),
326+ """ ),
367327 {
368328 "entity_id" : entity_id ,
369329 "entity_class_id" : entity_class_id ,
@@ -383,8 +343,7 @@ def update_tables(meta, obj_cls_to_ent_cls, rel_cls_to_ent_cls, obj_to_ent, rel_
383343 user = "alembic"
384344 date = datetime .now (timezone .utc )
385345 conn .execute (
386- text (
387- """
346+ text ("""
388347 UPDATE next_id
389348 SET
390349 user = :user,
@@ -393,8 +352,7 @@ def update_tables(meta, obj_cls_to_ent_cls, rel_cls_to_ent_cls, obj_to_ent, rel_
393352 entity_type_id = 3,
394353 entity_class_id = :entity_class_id,
395354 entity_id = :entity_id
396- """
397- ),
355+ """ ),
398356 {
399357 "user" : user ,
400358 "date" : date ,
0 commit comments