<commit_before>package kfs.kfsDbi;

import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 * @author pavedrim
 */
public class kfsIntAutoInc extends kfsInt {

    public static final int idMaxLen = 18;
    private boolean sequenceCycle = false;
    
    public kfsIntAutoInc(final String name, final String label, final int position) {
        super(name, label, idMaxLen, position, false);
    }
    
    @Override
    public String getColumnCreateTable(kfsDbServerType serverType) {
        switch (serverType) {
            case kfsDbiOracle:
                return super.getColumnName() + " NUMBER("+super.getColumnMaxLength()+") PRIMARY KEY ENABLE ";
            case kfsDbiMysql:
                return super.getColumnName() + " BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY ";
            case kfsDbiPostgre:
                return super.getColumnName() + " BIGSERIAL UNIQUE ";
            case kfsDbiSqlite:
                return super.getColumnName() + " PRIMARY KEY ";
        }
        return super.getColumnCreateTable(serverType);
    }    

    public boolean isSequenceCycle() {
        return sequenceCycle;
    }
    
    public kfsIntAutoInc setsequenceCycle(boolean newVal) {
        this.sequenceCycle = newVal;
        return this;
    }
    
    @Override
    public String []getCreateTableAddons(kfsDbServerType serverType, String table_name) {
        if (serverType == kfsDbServerType.kfsDbiOracle) {
        return new String[] {
            "create sequence "+ table_name + "_"+ this.getColumnName() +"_seq start with 1 increment by 1 maxvalue 999999999999999999 " + (sequenceCycle?"CYCLE":"NOCYCLE"),
            "create trigger "+ table_name + "_"+ this.getColumnName() +"_triger before insert on "+table_name+" for each row begin select "+ table_name + "_"+ this.getColumnName() +"_seq.nextval into :new."+ this.getColumnName() +" from dual; end;"
        };
        }
        return null;
    }

    @Override
    public void setParam(int inx, PreparedStatement ps, kfsRowData row) throws SQLException {
        Integer d = getInt(row);
        if ((d == null) || (d < 0)) {
            ps.setNull(inx, java.sql.Types.INTEGER);
        }
        super.setParam(inx, ps, row);
    }

}
<commit_msg>correct autoincrement sqlite <commit_after>package kfs.kfsDbi;

import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 *
 * @author pavedrim
 */
public class kfsIntAutoInc extends kfsInt {

    public static final int idMaxLen = 18;
    private boolean sequenceCycle = false;
    
    public kfsIntAutoInc(final String name, final String label, final int position) {
        super(name, label, idMaxLen, position, false);
    }
    
    @Override
    public String getColumnCreateTable(kfsDbServerType serverType) {
        switch (serverType) {
            case kfsDbiOracle:
                return super.getColumnName() + " NUMBER("+super.getColumnMaxLength()+") PRIMARY KEY ENABLE ";
            case kfsDbiMysql:
                return super.getColumnName() + " BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY ";
            case kfsDbiPostgre:
                return super.getColumnName() + " BIGSERIAL UNIQUE ";
            case kfsDbiSqlite:
                return super.getColumnName() + " INTEGER PRIMARY KEY AUTOINCREMENT ";
        }
        return super.getColumnCreateTable(serverType);
    }    

    public boolean isSequenceCycle() {
        return sequenceCycle;
    }
    
    public kfsIntAutoInc setsequenceCycle(boolean newVal) {
        this.sequenceCycle = newVal;
        return this;
    }
    
    @Override
    public String []getCreateTableAddons(kfsDbServerType serverType, String table_name) {
        if (serverType == kfsDbServerType.kfsDbiOracle) {
        return new String[] {
            "create sequence "+ table_name + "_"+ this.getColumnName() +"_seq start with 1 increment by 1 maxvalue 999999999999999999 " + (sequenceCycle?"CYCLE":"NOCYCLE"),
            "create trigger "+ table_name + "_"+ this.getColumnName() +"_triger before insert on "+table_name+" for each row begin select "+ table_name + "_"+ this.getColumnName() +"_seq.nextval into :new."+ this.getColumnName() +" from dual; end;"
        };
        }
        return null;
    }

    @Override
    public void setParam(int inx, PreparedStatement ps, kfsRowData row) throws SQLException {
        Integer d = getInt(row);
        if ((d == null) || (d < 0)) {
            ps.setNull(inx, java.sql.Types.INTEGER);
        }
        super.setParam(inx, ps, row);
    }

}

{'fraction_non_alphanumeric': 0.10026501766784453, 'fraction_numerical': 0.010159010600706713, 'mean_word_length': 2.5944444444444446, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7537371', 'n_tokens_mistral': 1406, 'n_tokens_neox': 1326, 'n_words': 337}