Source code for relstorage.adapters.postgresql.batch
################################################################################ Copyright (c) 2019 Zope Foundation and Contributors.# All Rights Reserved.## This software is subject to the provisions of the Zope Public License,# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS# FOR A PARTICULAR PURPOSE.###############################################################################"""Batch table row insert/delete support."""from__future__importabsolute_importfrom..batchimportRowBatcher
[docs]classPostgreSQLRowBatcher(RowBatcher):""" Applies array operations to DELETE and SELECT for single column filters. """def_make_single_column_query(self,command,table,filter_column,filter_value,rows_need_flattened):ifnotcommand.startswith("UPDATE"):stmt="%s FROM %s WHERE %s = ANY (%s)"%(command,table,filter_column,self.delete_placeholder)else:stmt='%s WHERE %s = ANY (%s)'%(command,filter_column,self.delete_placeholder)# We only pass a single parameter, and it doesn't need further# flattening.# It does have to be an actual list, thoughparams=filter_valueifrows_need_flattened:# This is guaranteed to return a listparams=self._flatten_params(params)elifnotisinstance(params,list):params=list(params)returnstmt,(params,),False