在类定义中ABAP“SET EXTENDED CHECK”语句(ABAP “SET EXTENDED CHECK” statement inside class definition)
在客户对象中,我看到以下ABAP代码:
CLASS lcl_detail DEFINITION FINAL. SET EXTENDED CHECK OFF. PUBLIC SECTION. [...] ENDCLASS.
我已经在SAP 7.40系统上执行了语法检查,这很好。 但是,如果我检查CLASS DEFINITION的7.40 ABAP关键字文档,它并没有说在这个地方允许SET EXTENDED CHECK。 另外,我认为CLASS DEFINITION部分和第一部分之间不应该有任何关系。
In a customer object, I see the following ABAP code:
CLASS lcl_detail DEFINITION FINAL. SET EXTENDED CHECK OFF. PUBLIC SECTION. [...] ENDCLASS.
I've performed a syntax check on an SAP 7.40 system and it is fine. But if I check the 7.40 ABAP Keyword documentation of CLASS DEFINITION, it does not say that SET EXTENDED CHECK is allowed in this place. Also, I though there shouldn't be anything between the CLASS DEFINITION part and the first SECTION part.
原文:https://stackoverflow.com/questions/32352410
最满意答案
首先,我强烈建议不要过滤这样的警告:这个错误是由MySQL生成的,它绝对意味着你正在丢失数据。
首先要做的就是使用MySQL describe命令来确保数据库列的实际定义与您期望的大小相同:如果您更改列的长度,那么Django不支持数据库迁移,因此如果您的slug字段比现在更短,您需要手动更改表以设置新长度:
mysql> DESCRIBE my_table slug; +-------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+-------+ | slug | varchar(255) | NO | UNI | NULL | | +-------+--------------+------+-----+---------+-------+ 1 row in set (0.00 sec)
如果该字段不是您所期望的,则可以通过更新列长来简单地解决问题:
mysql> ALTER TABLE my_table MODIFY slug VARCHAR(255) NOT NULL;
如果允许在你的slu Unicode中使用Unicode字符,那么也可以解释它,因为上面的转储似乎使用
latin1
字符集而不是UTF-8 - 单个UTF-8字符最多可以有4个字节的数据,这意味着只要17个字节的值就可以溢出一个VARCHAR(64)
。下一个调试步骤是对您正在进行的调用进行简单的变化,以过滤警告以准确找出错误发生的位置:
warnings.simplefilter("error", category=MySQLdb.Warning)
这会使警告致命,这将会停止你的程序,但更重要的是也会产生堆栈跟踪。 用这样的东西,你会看到下面的输出:
#!/usr/bin/env python import warnings def foo(): warnings.warn("uhoh") def bar(): foo() def main(): warnings.simplefilter("error", UserWarning) bar() if __name__ == "__main__": main()
没有simplefilter调用:
cadams@Io:~ $ python test_warnings.py test_warnings.py:5: UserWarning: uhoh warnings.warn("uhoh")
通过simplefilter调用:
cadams@Io:~ $ python test_warnings.py Traceback (most recent call last): File "test_warnings.py", line 15, in <module> main() File "test_warnings.py", line 12, in main bar() File "test_warnings.py", line 8, in bar foo() File "test_warnings.py", line 5, in foo warnings.warn("uhoh") UserWarning: uhoh
First, I'd strongly recommend against filtering warnings like this: this error is generated by MySQL and it absolutely means you are losing data.
The first thing to do would be using the MySQL describe command to make sure that your database column is actually defined to the same size you're expecting: Django has no support for database migrations if you change the length of a column so if your slug field was ever shorter than it is now you'd need to manually alter the table to set the new length:
mysql> DESCRIBE my_table slug; +-------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+-------+ | slug | varchar(255) | NO | UNI | NULL | | +-------+--------------+------+-----+---------+-------+ 1 row in set (0.00 sec)
If that field wasn't what you expected you could simply solve the problem by updating the column length:
mysql> ALTER TABLE my_table MODIFY slug VARCHAR(255) NOT NULL;
If you allow Unicode characters in your slugs, that could also explain it as your dump above appears to be using the
latin1
character set rather than UTF-8 – a single UTF-8 character can be up to 4 bytes of data, meaning that a value as short as 17 bytes could overflow aVARCHAR(64)
.One next debugging step is a simple variation on the call you're making to filter warnings to figure out exactly where your errors are happening:
warnings.simplefilter("error", category=MySQLdb.Warning)
This will make the warning fatal, which will halt your program, but more importantly will also produce a stacktrace. With something like this, you'll see the output below:
#!/usr/bin/env python import warnings def foo(): warnings.warn("uhoh") def bar(): foo() def main(): warnings.simplefilter("error", UserWarning) bar() if __name__ == "__main__": main()
Without the simplefilter call:
cadams@Io:~ $ python test_warnings.py test_warnings.py:5: UserWarning: uhoh warnings.warn("uhoh")
With the simplefilter call:
cadams@Io:~ $ python test_warnings.py Traceback (most recent call last): File "test_warnings.py", line 15, in <module> main() File "test_warnings.py", line 12, in main bar() File "test_warnings.py", line 8, in bar foo() File "test_warnings.py", line 5, in foo warnings.warn("uhoh") UserWarning: uhoh