"create temporary table #{temptable} on commit drop " +
"as select * from project_subtree_with_trash_at($1, LEAST($2, $3)::timestamp)",
"Group.update_trash.select",
- [[nil, self.uuid],
- [nil, TrashedGroup.find_by_group_uuid(self.owner_uuid).andand.trash_at],
- [nil, self.trash_at]])
+ [self.uuid,
+ TrashedGroup.find_by_group_uuid(self.owner_uuid).andand.trash_at,
+ self.trash_at])
frozen_descendants = ActiveRecord::Base.connection.exec_query(
"select uuid from frozen_groups, #{temptable} where uuid = target_uuid",
"Group.update_trash.check_frozen")
ActiveRecord::Base.connection.exec_query(
"create temporary table #{temptable} on commit drop as select * from project_subtree_with_is_frozen($1,$2)",
"Group.update_frozen.select",
- [[nil, self.uuid],
- [nil, !self.frozen_by_uuid.nil?]])
+ [self.uuid,
+ !self.frozen_by_uuid.nil?])
if frozen_by_uuid
rows = ActiveRecord::Base.connection.exec_query(
"select cr.uuid, cr.state from container_requests cr, #{temptable} frozen " +
"where cr.owner_uuid = frozen.uuid and frozen.is_frozen " +
"and cr.state not in ($1, $2) limit 1",
"Group.update_frozen.check_container_requests",
- [[nil, ContainerRequest::Uncommitted],
- [nil, ContainerRequest::Final]])
+ [ContainerRequest::Uncommitted,
+ ContainerRequest::Final])
if rows.any?
raise ArgumentError.new("cannot freeze project containing container request #{rows.first['uuid']} with state = #{rows.first['state']}")
end
ActiveRecord::Base.connection.exec_delete(
"delete from trashed_groups where group_uuid=$1",
"Group.clear_permissions_trash_frozen",
- [[nil, self.uuid]])
+ [self.uuid])
ActiveRecord::Base.connection.exec_delete(
"delete from frozen_groups where uuid=$1",
"Group.clear_permissions_trash_frozen",
- [[nil, self.uuid]])
+ [self.uuid])
end
def assign_name
LIMIT 1',
# query label:
'Node.available_slot_number',
- # [col_id, val] for $1 vars:
- [[nil, MAX_VMS]],
+ # bind vars:
+ [MAX_VMS],
).rows.first.andand.first
end
},
# "name" arg is a query label that appears in logs:
"user_can_query",
- [[nil, self.uuid],
- [nil, target_uuid],
- [nil, VAL_FOR_PERM[action]],
- [nil, target_owner_uuid]]
+ [self.uuid,
+ target_uuid,
+ VAL_FOR_PERM[action],
+ target_owner_uuid]
).any?
return false
end
# "name" arg is a query label that appears in logs:
"User.group_permissions",
# "binds" arg is an array of [col_id, value] for '$1' vars:
- [[nil, uuid]]).
+ [uuid]).
rows.each do |group_uuid, max_p_val|
@group_perms[group_uuid] = PERMS_FOR_VAL[max_p_val.to_i]
end
Collection.select(:portable_data_hash, :manifest_text).where(portable_data_hash: pdhs).distinct(:portable_data_hash).each do |c|
ActiveRecord::Base.connection.exec_query("update collections set file_names=$1 where portable_data_hash=$2",
"update file_names index",
- [[nil, c.manifest_files], [nil, c.portable_data_hash]])
+ [c.manifest_files, c.portable_data_hash])
end
ActiveRecord::Base.connection.exec_query('COMMIT')
end
ActiveRecord::Base.connection.exec_query(
"update links set name=$1 where link_class=$2 and name=$3 and tail_uuid like $4 and head_uuid = $5",
"migrate", [
- [nil, to],
- [nil, "permission"],
- [nil, from],
- [nil, "_____-tpzed-_______________"],
- [nil, all_users_group_uuid],
+ to,
+ "permission",
+ from,
+ "_____-tpzed-_______________",
+ all_users_group_uuid,
])
end
end
# "name" arg is a query label that appears in logs:
"descendant_project_uuids for #{self.uuid}",
# "binds" arg is an array of [col_id, value] for '$1' vars:
- [[nil, self.uuid], [nil, 'project']],
+ [self.uuid, 'project'],
).rows.map do |project_uuid,|
project_uuid
end
n = conn.update(
"UPDATE #{table} SET #{column}=$1 WHERE #{column}=$2",
"#{table}.#{column} convert YAML to JSON",
- [[nil, "{}"], [nil, "--- {}\n"]])
+ ["{}", "--- {}\n"])
Rails.logger.info("#{table}.#{column}: #{n} rows updated using empty hash")
finished = false
while !finished
conn.exec_query(
"SELECT id, #{column} FROM #{table} WHERE #{column} LIKE $1 LIMIT 100",
"#{table}.#{column} check for YAML",
- [[nil, '---%']],
+ ['---%'],
).rows.map do |id, yaml|
n += 1
json = SafeJSON.dump(YAML.safe_load(yaml))
conn.exec_query(
"UPDATE #{table} SET #{column}=$1 WHERE id=$2 AND #{column}=$3",
"#{table}.#{column} convert YAML to JSON",
- [[nil, json], [nil, id], [nil, yaml]])
+ [json, id, yaml])
end
Rails.logger.info("#{table}.#{column}: #{n} rows updated")
finished = (n == 0)
as select * from compute_permission_subgraph($1, $2, $3, $4)
},
'update_permissions.select',
- [[nil, perm_origin_uuid],
- [nil, starting_uuid],
- [nil, perm_level],
- [nil, edge_id]]
+ [perm_origin_uuid,
+ starting_uuid,
+ perm_level,
+ edge_id]
ActiveRecord::Base.connection.exec_query "SET LOCAL enable_mergejoin to true;"
and container_requests.requesting_container_uuid is not NULL
)
order by containers.uuid for update
- }, 'select_for_update_priorities', [[nil, container_uuid]]
+ }, 'select_for_update_priorities', [container_uuid]
end
def update_priorities starting_container_uuid
ActiveRecord::Base.connection.exec_query %{
update containers set priority=computed.upd_priority from container_tree_priorities($1) as computed
where containers.uuid = computed.pri_container_uuid and priority != computed.upd_priority
-}, 'update_priorities', [[nil, starting_container_uuid]]
+}, 'update_priorities', [starting_container_uuid]
end