INSERT failed because the following SET options have incorrect settings: 'ANSI_PADDING'. Verify that

执行加字段的语句报错:

INSERT failed because the following SET options have incorrect settings: 'ANSI_PADDING'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or filtered indexes and/or query notifications and/or XML data type methods and/or spatial index operations.

Invalid column name 'ProductPropertyCode'.

出错原因:ANSI_PADDING为ON;

解决办法:设为OFF

SET ANSI_PADDING OFF;

Here's an optimized version of the code: ``` def network_planes_check(self): LOG.info('start network_planes_check...') err_msgs = [] with open(self.JSON_PATH, 'r') as f: data = json.load(f) ip_versions = set() # Use set to avoid duplicates for vxlan_plane in data["vxlan_planes"]: for info in vxlan_plane["ip_ranges"]: cidr, start, end = info.get("cidr"), info.get("start"), info.get("end") if cidr and start and end: # Check if cidr format is correct try: ip_network = ipaddress.ip_network(cidr) except ValueError: err_msgs.append("Error: cidr format is incorrect") continue ip_versions.add(ip_network.version) if (ipaddress.ip_address(start) not in ip_network or ipaddress.ip_address(end) not in ip_network): err_msgs.append('start_ip %s or end_ip %s is not in cidr %s' % (start, end, cidr)) elif ipaddress.ip_address(start) > ipaddress.ip_address(end): err_msgs.append('start_ip %s is not less than end_ip %s' % (start, end)) else: err_msgs.append('IP is valid') else: err_msgs.append("Error: cidr/start/end is not configured") if len(ip_versions) > 1: err_msgs.append("Error: cidr is mixed ipv4/ipv6") return err_msgs ``` Here are the changes I made: - Used `info.get("cidr")` instead of `info["cidr"]` to avoid a `KeyError` if `cidr` is missing. - Used `set()` to keep track of the IP versions encountered, so we can check if there's a mix of IPv4 and IPv6. - Moved the check for `cidr/start/end` outside the `try` block, since we don't need to catch a `ValueError` for that. - Simplified the checks for `start` and `end` being in the CIDR range, and for `start` being less than `end`. - Used `continue` to skip to the next iteration of the loop if the CIDR format is incorrect.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值