001package io.ebean.config.dbplatform.sqlite;
002
003import io.ebean.annotation.Platform;
004import io.ebean.config.dbplatform.DatabasePlatform;
005import io.ebean.config.dbplatform.DbPlatformType;
006import io.ebean.config.dbplatform.DbType;
007import io.ebean.config.dbplatform.IdType;
008
009import java.sql.Types;
010
011public class SQLitePlatform extends DatabasePlatform {
012
013  public SQLitePlatform() {
014    super();
015    this.platform = Platform.SQLITE;
016    this.dbIdentity.setIdType(IdType.IDENTITY);
017    this.dbIdentity.setSupportsGetGeneratedKeys(false);
018    this.dbIdentity.setSupportsSequence(false);
019    this.dbIdentity.setSelectLastInsertedIdTemplate("select last_insert_rowid()");
020    this.truncateTable = "delete from %s";
021    this.booleanDbType = Types.INTEGER;
022    this.likeClauseRaw = "like ?";
023    this.likeClauseEscaped = "like ?";
024    this.dbDefaultValue.setFalse("0");
025    this.dbDefaultValue.setTrue("1");
026    this.dbDefaultValue.setNow("CURRENT_TIMESTAMP");
027
028    dbTypeMap.put(DbType.BIT, new DbPlatformType("int"));
029    dbTypeMap.put(DbType.BOOLEAN, new DbPlatformType("int"));
030    dbTypeMap.put(DbType.BIGINT, new DbPlatformType("integer"));
031    dbTypeMap.put(DbType.SMALLINT, new DbPlatformType("integer"));
032  }
033
034  @Override
035  protected void escapeLikeCharacter(char ch, StringBuilder sb) {
036    sb.append(ch);
037  }
038
039}