001package com.avaje.ebean.config.dbplatform;
002
003/**
004 * Support for text, mediumtext or longtext selection based on the deployment
005 * length.
006 * <p>
007 * If no deployment length is defined longtext is used.
008 * </p>
009 */
010public class MySqlClob extends DbType {
011
012  private static final int POWER_2_16 = 65536;
013  private static final int POWER_2_24 = 16777216;
014
015  public MySqlClob() {
016    super("text");
017  }
018
019  @Override
020  public String renderType(int deployLength, int deployScale) {
021
022    if (deployLength >= POWER_2_24) {
023      return "longtext";
024    }
025    if (deployLength >= POWER_2_16) {
026      return "mediumtext";
027    }
028    if (deployLength < 1) {
029      // length not explicitly defined
030      return "longtext";
031    }
032    return "text";
033  }
034
035}