Skip to content

Commit

Permalink
Update SQL type casts to use bigint where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
tomka committed Jun 22, 2019
1 parent c29747e commit ac97500
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions django/applications/catmaid/control/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ def _update_neuron_annotations(project_id:Union[int,str], neuron_id, annotation_
cursor.execute('''
UPDATE class_instance_class_instance
SET class_instance_a = %s, user_id = missing.u_id
FROM UNNEST(%s::integer[], %s::integer[]) AS missing(cici_id, u_id)
FROM UNNEST(%s::bigint[], %s::integer[]) AS missing(cici_id, u_id)
WHERE id = missing.cici_id;
''', (neuron_id, cici_ids, u_ids))

Expand Down Expand Up @@ -616,12 +616,12 @@ def _update_neuron_annotations(project_id:Union[int,str], neuron_id, annotation_
cursor.execute("""
UPDATE class_instance_class_instance
SET creation_time = to_update.creation_time
FROM UNNEST(%s::integer[], %s::timestamptz[])
FROM UNNEST(%s::bigint[], %s::timestamptz[])
AS to_update(cici_id, creation_time)
WHERE id = to_update.cici_id;
UPDATE class_instance_class_instance
SET edition_Time = to_update.edition_time
FROM UNNEST(%s::integer[], %s::timestamptz[])
FROM UNNEST(%s::bigint[], %s::timestamptz[])
AS to_update(cici_id, edition_time)
WHERE id = to_update.cici_id;
""", (to_update_ids,
Expand Down
8 changes: 4 additions & 4 deletions django/applications/catmaid/control/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ def _many_to_many_synapses(skids1, skids2, relation_name, project_id) -> Tuple:
treenode t1,
treenode t2,
connector c
WHERE tc1.skeleton_id = ANY(%(skeleton_ids_1)s::int[])
WHERE tc1.skeleton_id = ANY(%(skeleton_ids_1)s::bigint[])
AND tc1.connector_id = c.id
AND tc2.skeleton_id = ANY(%(skeleton_ids_2)s::int[])
AND tc2.skeleton_id = ANY(%(skeleton_ids_2)s::bigint[])
AND tc1.connector_id = tc2.connector_id
AND tc1.relation_id = %(relation_id)s
AND (tc1.relation_id != tc2.relation_id
OR tc1.relation_id = ANY(%(undir_rel_ids)s::int[]))
OR tc1.relation_id = ANY(%(undir_rel_ids)s::bigint[]))
AND tc1.id != tc2.id
AND tc1.treenode_id = t1.id
AND tc2.treenode_id = t2.id
Expand Down Expand Up @@ -1038,7 +1038,7 @@ def get_connectors_in_bb_postgis3d(params) -> List:
JOIN (
SELECT DISTiNCT tc2.connector_id
FROM treenode_connector tc2
JOIN UNNEST(%(skeleton_ids)s::int[]) skeleton(id)
JOIN UNNEST(%(skeleton_ids)s::bigint[]) skeleton(id)
ON tc2.skeleton_id = skeleton.id
) allowed_connector(id)
ON allowed_connector.id = c.id
Expand Down
2 changes: 1 addition & 1 deletion django/applications/catmaid/control/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def label_update(request:HttpRequest, project_id, location_id, ntype:str) -> Jso
class_instance ci,
treenode_class_instance tci,
treenode tn,
unnest(%s::text[], %s::integer[]) AS ll (name, max)
unnest(%s::text[], %s::bigint[]) AS ll (name, max)
WHERE ci.name = ll.name
AND ci.project_id = %s
AND ci.class_id = %s
Expand Down
6 changes: 3 additions & 3 deletions django/applications/catmaid/control/landmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ def get_landmark_group_locations(project_id, landmarkgroup_ids, with_names:bool=
FROM (
SELECT pci.point_id, pci.class_instance_id, array_agg(l.name) as names
FROM point_class_instance pci
JOIN UNNEST(%(landmarkgroup_ids)s::integer[]) landmarkgroup(id)
JOIN UNNEST(%(landmarkgroup_ids)s::bigint[]) landmarkgroup(id)
ON pci.class_instance_id = landmarkgroup.id
LEFT JOIN point_class_instance pci_l
ON pci_l.point_id = pci.point_id
Expand Down Expand Up @@ -942,7 +942,7 @@ def get_landmark_group_locations(project_id, landmarkgroup_ids, with_names:bool=
SELECT pci.point_id, pci.class_instance_id, p.location_x,
p.location_y, p.location_z
FROM point_class_instance pci
JOIN UNNEST(%(landmarkgroup_ids)s::integer[]) landmarkgroup(id)
JOIN UNNEST(%(landmarkgroup_ids)s::bigint[]) landmarkgroup(id)
ON pci.class_instance_id = landmarkgroup.id
JOIN point p
ON p.id = pci.point_id
Expand Down Expand Up @@ -971,7 +971,7 @@ def make_landmark_relation_index(project_id, landmarkgroup_ids) -> Tuple[Default
SELECT cici.id, lg.id, cici.relation_id, r.relation_name,
cici.class_instance_a, cici.class_instance_b
FROM class_instance_class_instance cici
JOIN UNNEST(%(landmarkgroup_ids)s::integer[]) lg(id)
JOIN UNNEST(%(landmarkgroup_ids)s::bigint[]) lg(id)
ON lg.id = cici.class_instance_a
OR lg.id = cici.class_instance_b
JOIN relation r
Expand Down
2 changes: 1 addition & 1 deletion django/applications/catmaid/control/similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def compute_random_and_add_delayed(self, project_id, user_id, name,
cursor.execute("""
SELECT css.skeleton_id
FROM catmaid_skeleton_summary css
JOIN UNNEST(%(skeleton_ids)s::int[]) skeleton(id)
JOIN UNNEST(%(skeleton_ids)s::bigint[]) skeleton(id)
ON css.skeleton_id = skeleton.id
WHERE project_id = %(project_id)s
AND cable_length >= %(min_cable)s
Expand Down
16 changes: 8 additions & 8 deletions django/applications/catmaid/control/skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ def connectivity_counts(request:HttpRequest, project_id=None) -> JsonResponse:
cursor.execute("""
SELECT tc.skeleton_id, tc.relation_id, COUNT(tc)
FROM treenode_connector tc
JOIN UNNEST(%(skeleton_ids)s::int[]) skeleton(id)
JOIN UNNEST(%(skeleton_ids)s::bigint[]) skeleton(id)
ON skeleton.id = tc.skeleton_id
{extra_select}
WHERE tc.project_id = %(project_id)s
Expand Down Expand Up @@ -1276,7 +1276,7 @@ def newPartner():
t1.treenode_id, t2.treenode_id
FROM treenode_connector t1,
treenode_connector t2
WHERE t1.skeleton_id = ANY(%s::integer[])
WHERE t1.skeleton_id = ANY(%s::bigint[])
AND t1.relation_id = %s
AND t1.connector_id = t2.connector_id
AND t1.id != t2.id
Expand Down Expand Up @@ -1311,7 +1311,7 @@ def newPartner():
cursor.execute('''
SELECT skeleton_id, num_nodes
FROM catmaid_skeleton_summary
WHERE skeleton_id = ANY(%s::integer[])
WHERE skeleton_id = ANY(%s::bigint[])
GROUP BY skeleton_id
''', (partner_skids,))
for row in cursor.fetchall():
Expand All @@ -1321,7 +1321,7 @@ def newPartner():
cursor.execute('''
SELECT DISTINCT reviewer_id
FROM review
WHERE skeleton_id = ANY(%s::integer[])
WHERE skeleton_id = ANY(%s::bigint[])
''', (partner_skids,))
reviewers = [row[0] for row in cursor]

Expand Down Expand Up @@ -1641,8 +1641,8 @@ def get_connectivity_matrix(project_id, row_skeleton_ids, col_skeleton_ids,
FROM treenode_connector t1,
treenode_connector t2
{extra_join}
WHERE t1.skeleton_id = ANY(%(row_skeleton_ids)s::integer[])
AND t2.skeleton_id = ANY(%(col_skeleton_ids)s::integer[])
WHERE t1.skeleton_id = ANY(%(row_skeleton_ids)s::bigint[])
AND t2.skeleton_id = ANY(%(col_skeleton_ids)s::bigint[])
AND t1.connector_id = t2.connector_id
AND t1.relation_id = %(pre_rel_id)s
AND t2.relation_id = %(post_rel_id)s
Expand Down Expand Up @@ -3145,7 +3145,7 @@ def skeletons_by_node_labels(request:HttpRequest, project_id=None) -> JsonRespon
ON t.id = tci.treenode_id
JOIN class_instance ci
ON tci.class_instance_id = ci.id
JOIN UNNEST(%(label_ids)s::int[]) label(id)
JOIN UNNEST(%(label_ids)s::bigint[]) label(id)
ON label.id = ci.id
WHERE ci.project_id = %(project_id)s
AND tci.relation_id = %(labeled_as)s
Expand Down Expand Up @@ -3189,7 +3189,7 @@ def get_skeletons_in_bb(params) -> List:

if skeleton_ids:
extra_joins.append("""
JOIN UNNEST(%(skeleton_ids)s::int[]) query_skeleton(id)
JOIN UNNEST(%(skeleton_ids)s::bigint[]) query_skeleton(id)
ON query_skeleton.id = skeleton.id
""")

Expand Down

0 comments on commit ac97500

Please sign in to comment.