我需要寫在SQL鍊金術查詢查一些字符串參數對包含字符串數組(Postgre)如何在SQL鍊金術寫這
城市 狀態 地址行 ZIP_CODE PHONE_NUMBERS
場都是文本類型的[]
select_statement = bdb.get_select_statement(business_schema)\
.where(((text('array[:acity] <@ city')
and text('array[:astate] <@ state')
and text('array[:aaddress] <@ address_line_1'))
or
(text('array[:aaddress] <@ address_line_1') and text('array[:azip_code] <@ zip_code')))
and (text('array[:aphone] <@ phone_numbers')))\
.params(aaddress = address_line_1, acity = city, astate = state, azip_code = zip_code, aphone = phone_number)
的問題是,我收到異常當我這樣做,「這一條款的布爾值不定義」。
平原SQL寫入是:提前
select * from business where ('address_line1' = ANY (address_line_1)
and 'acity' = ANY (city)
and 'state' = ANY (state)
or
('adress_line1' = ANY (address_line_1) and 'zip' = ANY (zip_code))
and
'phone' = ANY (phone_numbers)
關於如何做到這一點的任何想法?
謝謝!
感謝yoou zzzeek,這正是我一直在尋找! –