tursoNativeColumnType function

String tursoNativeColumnType(
  1. String type
)

共通schemaのVECTOR列をTursoDBのnative vector列へ対応付ける。

Implementation

String tursoNativeColumnType(String type) {
  final normalized = type.trim().toUpperCase();
  final match = RegExp(r"^VECTOR\(([1-9][0-9]*)\)$").firstMatch(normalized);
  if (match == null) {
    return type;
  }
  if (int.parse(match.group(1)!) > 16383) {
    throw ArgumentError("VECTOR dimensionsは1〜16383です。");
  }
  return normalized.replaceFirst("VECTOR", "F32_BLOB");
}