<commit_before>Arbiter.FeatureTableHelper = (function(){
	
	var wktFormatter = new OpenLayers.Format.WKT();
	var loadedCount = 0;
	var layersCount = 0;
		
	var incrementLoadedCount = function(){
		loadedCount++;
	};
	
	var doneLoadingSchemas = function(){
		return layersCount === loadedCount;
	};
	
	var getFeatures = function(tx, schema, context, onSuccess, onFailure){
		
		var sql = "select * from " + schema.getFeatureType() + ";";
		
		tx.executeSql(sql, [], function(tx, res){
			if(res.rows.length > 0){
				for(var i = 0; i < res.rows.length; i++){
					onSuccess.call(context, res.rows.item(i), i, res.rows.length);
				}
			}else{
				onSuccess.call(context, null, null, 0);
			}
		}, function(tx, e){
			console.log("ERROR: Arbiter.FeatureTableHelper.getFeatures", e);
			if(Arbiter.Util.funcExists(onFailure)){
				onFailure.call(context, e);
			}
		});
	};
	
	return {
		ID : "arbiter_id",
		FID : "fid",
		SYNC_STATE: "sync_state",
		MODIFIED_STATE: "modified_state",
		
		MODIFIED_STATES: {
			NONE: 0,
			INSERTED: 1,
			MODIFIED: 2,
			DELETED: 3
		},
		
		SYNC_STATES: {
			NOT_SYNCED: 0,
			SYNCED: 1
		},
		
		/**
    	 * Create the table
    	 */
    	createFeatureTable: function(schema, onSuccess, onFailure){
    		var db = Arbiter.FeatureDbHelper.getFeatureDatabase();
    		var context = this;
    		
    		db.transaction(function(tx){
    			context.createTable(tx, schema, onSuccess, onFailure);
    		}, function(e){
    			console.log("ERROR: Arbiter.FeatureTableHelper"
    					+ ".createFeatureTable", e);
    			
    			if(Arbiter.Util.funcExists(onFailure)){
    				onFailure(e);
    			}
    		});
    	},
    	
    	createTable: function(tx, schema, onSuccess, onFailure){
    		var sql = "CREATE TABLE IF NOT EXISTS "
    			+ schema.getFeatureType() + " ("
    			+ this.ID + " integer primary key, "
    			+ this.FID + " text, "
    			+ this.SYNC_STATE + " integer not null, "
    			+ this.MODIFIED_STATE + " integer not null, "
    			+ schema.getGeometryName() + " text not null";
    		
    		var attributes = schema.getAttributes();
    		
    		for(var i = 0; i < attributes.length; i++){
    			sql += ", '" + attributes[i].getName() + "' " + attributes[i].getType();
    			
    			if(!attributes[i].isNillable()){
    				sql += " not null";
    			}
    		}
    		
    		sql += ");";
    		
    		tx.executeSql(sql, [], function(tx, res){
    			
    			if(Arbiter.Util.funcExists(onSuccess)){
    				onSuccess();
    			}
    		}, function(e){
    			console.log("ERROR: create table - " + sql);
    			if(Arbiter.Util.funcExists(onFailure)){
    				onFailure(e);
    			}
    		});
    	},
    	<commit_msg>Only set not null restriction if nillable === false.  If for some reason nillable isn’t defined, we don’t want to set a constraint that may not need to be there<commit_after>Arbiter.FeatureTableHelper = (function(){
	
	var wktFormatter = new OpenLayers.Format.WKT();
	var loadedCount = 0;
	var layersCount = 0;
		
	var incrementLoadedCount = function(){
		loadedCount++;
	};
	
	var doneLoadingSchemas = function(){
		return layersCount === loadedCount;
	};
	
	var getFeatures = function(tx, schema, context, onSuccess, onFailure){
		
		var sql = "select * from " + schema.getFeatureType() + ";";
		
		tx.executeSql(sql, [], function(tx, res){
			if(res.rows.length > 0){
				for(var i = 0; i < res.rows.length; i++){
					onSuccess.call(context, res.rows.item(i), i, res.rows.length);
				}
			}else{
				onSuccess.call(context, null, null, 0);
			}
		}, function(tx, e){
			console.log("ERROR: Arbiter.FeatureTableHelper.getFeatures", e);
			if(Arbiter.Util.funcExists(onFailure)){
				onFailure.call(context, e);
			}
		});
	};
	
	return {
		ID : "arbiter_id",
		FID : "fid",
		SYNC_STATE: "sync_state",
		MODIFIED_STATE: "modified_state",
		
		MODIFIED_STATES: {
			NONE: 0,
			INSERTED: 1,
			MODIFIED: 2,
			DELETED: 3
		},
		
		SYNC_STATES: {
			NOT_SYNCED: 0,
			SYNCED: 1
		},
		
		/**
    	 * Create the table
    	 */
    	createFeatureTable: function(schema, onSuccess, onFailure){
    		var db = Arbiter.FeatureDbHelper.getFeatureDatabase();
    		var context = this;
    		
    		db.transaction(function(tx){
    			context.createTable(tx, schema, onSuccess, onFailure);
    		}, function(e){
    			console.log("ERROR: Arbiter.FeatureTableHelper"
    					+ ".createFeatureTable", e);
    			
    			if(Arbiter.Util.funcExists(onFailure)){
    				onFailure(e);
    			}
    		});
    	},
    	
    	createTable: function(tx, schema, onSuccess, onFailure){
    		var sql = "CREATE TABLE IF NOT EXISTS "
    			+ schema.getFeatureType() + " ("
    			+ this.ID + " integer primary key, "
    			+ this.FID + " text, "
    			+ this.SYNC_STATE + " integer not null, "
    			+ this.MODIFIED_STATE + " integer not null, "
    			+ schema.getGeometryName() + " text not null";
    		
    		var attributes = schema.getAttributes();
    		
    		var nillable = null;
    		
    		for(var i = 0; i < attributes.length; i++){
    			sql += ", '" + attributes[i].getName() + "' " + attributes[i].getType();
    			
    			nillable = attributes[i].isNillable();
    			
    			if(nillable === false 
    					|| nillable === "false"){
    				
    				sql += " not null";
    			}
    		}
    		
    		sql += ");";
    		
    		tx.executeSql(sql, [], function(tx, res){
    			
    			if(Arbiter.Util.funcExists(onSuccess)){
    				onSuccess();
    			}
    		}, function(e){
    			console.log("ERROR: create table - " + sql);
    			if(Arbiter.Util.funcExists(onFailure)){
    				onFailure(e);
    			}
    		});
    	},
    	
{'fraction_non_alphanumeric': 0.14895517056617252, 'fraction_numerical': 0.0042864797285229505, 'mean_word_length': 2.3734939759036147, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '144373', 'n_tokens_mistral': 2275, 'n_tokens_neox': 2004, 'n_words': 376}