We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import strutils, hashes, os # UTF8 でのバイト数を返す補助関数 proc byteCount(s: string): int = return s.encodeUtf8.len # 識別子を 63 バイト以下に調整する関数 proc adjustIdentifier(id: string): string = const maxBytes = 63 let idBytes = id.encodeUtf8 if idBytes.len <= maxBytes: return id else: # ハッシュ値(例: SHA-256 の先頭 6 桁の16進文字列) let hashSuffix = sha256(id).toHex[0..5] # 区切り用の "_" を含めるので、利用可能な長さは maxBytes - (hashSuffix.len + 1) let allowedBytes = maxBytes - (hashSuffix.len + 1) # 単純に文字単位で切るとバイト数がずれる可能性があるので、 # UTF8 バイト列として allowedBytes だけ取り出し、そこから再度文字列に戻す(ここは実装依存) let truncated = idBytes[0..<allowedBytes].reinterpret(string) return truncated & "_" & hashSuffix
let rawIndexName = tableName & "_" & columnName & "_key" let indexName = adjustIdentifier(rawIndexName)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: