Version: Newyork
適当に確認
ServiceNowでString Typeで文字列長40のColumnに値を入れます
ServiceNowで文字列長が40の場合40byteではなく40文字として扱われるようです全角は40文字まで入りました半角41文字は入りませんでしたまたUTF-8で4byte必要な文字は扱えないのか文字化けしました
ServiceNowの文字コードはdefaultでutf-8だったと思いますDiagnostics Pageで確認するとDBはMaria5.6.21のようです
Database overview
Type mysql
Version 5.6.21-MariaDB-log
Driver mariadb-jdbc
JDBC 1.1
因みにString Typeの最大文字列長は試したところMySQLのLONGTEXTの最大長(4,294,967,295)の半分の2,147,483,647文字の様です(2,147,483,648に変更しようとするとエラーが出ます)
Stringで256以上のmax lengthだとDB的にmediumtext型になるらしくて16,777,215 bytesまで入るらしい
あとすっごいびっくりしたのですがStringで256以上のmax lengthだとDB的にmediumtext型になるらしくて16,777,215 bytesまで入るらしいとIncidentのDescriotionとか4,000なので16,777,215 bytes入るはず
[Fields in ServiceNow accept string inputs greater than the sys_dictionary max_length value - Support and Troubleshooting]
https://hi.service-now.com/kb_view.do?sysparm_article=KB0685779
Fields in ServiceNow accept string inputs greater than the sys_dictionary max_length value.
This is expected behavior of the product.
When you create a string field in ServiceNow, the underlying column in database is created with a default data type based in part on the specified max_length value.
Small (40) = varchar(40)
Medium (100) = varchar(100)
Large (1000) = mediumtext
Extra Large (4000) = mediumtext
Any string field that is larger than varchar(255) is given the mediumtext data type. In the client, it will be represented as HTML textarea, instead of an HTML input. The maximum length of mediumtext is 16,777,215 bytes.
ServiceNowでLength 40の項目に41文字以上の値でInsertするとエラーも出ずに40文字で切れて挿入される
最初この仕様にびっくりしました このSQLモードが指定されていないんだろうなと想像しています
STRICT_TRANS_TABLES
値を指定したとおりにトランザクションテーブルに挿入できない場合、ステートメントを中止します。 非トランザクションテーブルの場合、値が単一行ステートメントで発生するか、複数行ステートメントの先頭行で発生した場合、ステートメントを中止します。 詳細については、このセクションのあとの方で説明します。