@function requireValidIndexes

validate indexes argument

@param {object} database

@returns {object}

@throws {Error}
541840
function requireValidIndexes (indexes) {
    // throw error on invalid indexes option
    assert.ok(Array.isArray(indexes), 'indexes must be array')
    // validate each index spec
    _.each(indexes, index => {
        // require columns to be array
        assert.ok(Array.isArray(index.columns), 'index columns must be array')
        // require multiple columns
        assert.ok(index.columns.length > 1, 'index must have at least 2 columns')
    })
    // return validated indexes
    return indexes
}
1082566
function requireValidArgsModel (args) {
    // do not check if strict mode not set
    if (!this.strict) {
        return
    }
    // require valid session
    this.requireValidSession(args.session)
    // require specific model and action to be defined for request
    assert.ok(typeof args.model === 'string' && typeof args.action === 'string', 'model and action required to request access for model')
    // require valid scope on actions other than create
    assert.ok(args.action === 'create' || args.scope === 'any' || args.scope === 'own' || args.accessId, 'scope required for actions except create to request access for model')
}
1372363
function (index) {
        validateListIndex(this, index);

        var i = index,
            len = --this.length;

        for (; i < len; i++) {
            this[i] = this[i + 1];
        }

        delete this[len];
    }
907647
def _validate_index(self, index):
        """"""
        if isinstance(index, slice):
            if index.step and index.step != 1:
                raise IndexError('Step is not allowed.')
            indexes = (index.start, index.stop)
        else:
            indexes = (index,)
        for index in indexes:
            if index is not None and index < 0:
                raise IndexError('Negative indexes are not allowed.')
1034251
function(query) {
	//	console.log(query);
	// Loop over all sources
	// Todo: make this loop smaller and more graspable
	for (var k = 0, klen = query.sources.length; k < klen; k++) {
		var source = query.sources[k];
		delete source.ix;
		// If there is indexation rule
		//console.log('preIndex', source);
		//console.log(source);
		if (k > 0 && source.optimization == 'ix' && source.onleftfn && source.onrightfn) {
			// If there is no table.indices - create it
			if (source.databaseid && alasql.databases[source.databaseid].tables[source.tableid]) {
				if (!alasql.databases[source.databaseid].tables[source.tableid].indices)
					query.database.tables[source.tableid].indices = {};
				// Check if index already exists
				var ixx =
					alasql.databases[source.databaseid].tables[source.tableid].indices[
						hash(source.onrightfns + '`' + source.srcwherefns)
					];
				if (!alasql.databases[source.databaseid].tables[source.tableid].dirty && ixx) {
					source.ix = ixx;
				}
			}

			if (!source.ix) {
				source.ix = {};
				// Walking over source data
				var scope = {};
				var i = 0;
				var ilen = source.data.length;
				var dataw;
				//				while(source.getfn i<ilen) {

				while (
					(dataw = source.data[i]) ||
					(source.getfn && (dataw = source.getfn(i))) ||
					i < ilen
				) {
					if (source.getfn && !source.dontcache) source.data[i] = dataw;
					//					scope[tableid] = dataw;

					//				for(var i=0, ilen=source.data.length; i<ilen; i++) {
					// Prepare scope for indexation
					scope[source.alias || source.tableid] = dataw;

					// Check if it apply to where function
					if (source.srcwherefn(scope, query.params, alasql)) {
						// Create index entry for each address
						var addr = source.onrightfn(scope, query.params, alasql);
						var group = source.ix[addr];
						if (!group) {
							group = source.ix[addr] = [];
						}
						group.push(dataw);
					}
					i++;
				}

				if (
					source.databaseid &&
					alasql.databases[source.databaseid].tables[source.tableid]
				) {
					// Save index to original table
					alasql.databases[source.databaseid].tables[source.tableid].indices[
						hash(source.onrightfns + '`' + source.srcwherefns)
					] =
						source.ix;
				}
			}
			//console.log(38,274,source.ix);

			// Optimization for WHERE column = expression
		} else if (source.wxleftfn) {
			if (!alasql.databases[source.databaseid].engineid) {
				// Check if index exists
				ixx =
					alasql.databases[source.databaseid].tables[source.tableid].indices[
						hash(source.wxleftfns + '`')
					];
			}
			if (!alasql.databases[source.databaseid].tables[source.tableid].dirty && ixx) {
				// Use old index if exists
				source.ix = ixx;
				// Reduce data (apply filter)
				source.data = source.ix[source.wxrightfn(null, query.params, alasql)];
			} else {
				// Create new index
				source.ix = {};
				// Prepare scope
				scope = {};
				// Walking on each source line
				i = 0;
				ilen = source.data.length;
				dataw;
				//				while(source.getfn i<ilen) {

				while (
					(dataw = source.data[i]) ||
					(source.getfn && (dataw = source.getfn(i))) ||
					i < ilen
				) {
					if (source.getfn && !source.dontcache) source.data[i] = dataw;
					//					for(var i=0, ilen=source.data.length; i<ilen; i++) {
					scope[source.alias || source.tableid] = source.data[i];
					// Create index entry
					addr = source.wxleftfn(scope, query.params, alasql);
					group = source.ix[addr];
					if (!group) {
						group = source.ix[addr] = [];
					}
					group.push(source.data[i]);
					i++;
				}
				//					query.database.tables[source.tableid].indices[hash(source.wxleftfns+'`'+source.onwherefns)] = source.ix;
				if (!alasql.databases[source.databaseid].engineid) {
					alasql.databases[source.databaseid].tables[source.tableid].indices[
						hash(source.wxleftfns + '`')
					] =
						source.ix;
				}
			}
			// Apply where filter to reduces rows
			if (source.srcwherefns) {
				if (source.data) {
					scope = {};
					source.data = source.data.filter(function(r) {
						scope[source.alias] = r;
						return source.srcwherefn(scope, query.params, alasql);
					});
				} else {
					source.data = [];
				}
			}
			//			}
			// If there is no any optimization than apply srcwhere filter
		} else if (source.srcwherefns && !source.dontcache) {
			if (source.data) {
				var scope = {};
				// TODO!!!!! Data as Function

				source.data = source.data.filter(function(r) {
					scope[source.alias] = r;
					//					console.log(288,source);
					return source.srcwherefn(scope, query.params, alasql);
				});

				scope = {};
				i = 0;
				ilen = source.data.length;
				//var dataw;
				var res = [];
				//				while(source.getfn i<ilen) {

				while (
					(dataw = source.data[i]) ||
					(source.getfn && (dataw = source.getfn(i))) ||
					i < ilen
				) {
					if (source.getfn && !source.dontcache) source.data[i] = dataw;
					scope[source.alias] = dataw;
					if (source.srcwherefn(scope, query.params, alasql)) res.push(dataw);
					i++;
				}
				source.data = res;
			} else {
				source.data = [];
			}
		}
		// Change this to another place (this is a wrong)
		if (source.databaseid && alasql.databases[source.databaseid].tables[source.tableid]) {
			//query.database.tables[source.tableid].dirty = false;
		} else {
			// this is a subquery?
		}
	}
}
265525
function validateReQL (reql, reqlOpts, whitelist) {
  var args = assertArgs(arguments, {
    'reql': '*',
    '[reqlOpts]': 'object',
    'whitelist': 'array'
  })
  reql = args.reql
  reqlOpts = args.reqlOpts
  whitelist = args.whitelist
  var firstErr
  var errCount = 0
  var promises = whitelist.map(function (reqlValidator) {
    return validate(reql, reqlOpts, reqlValidator)
      .catch(function (err) {
        firstErr = firstErr || err
        errCount++
      })
  })
  return Promise.all(promises).then(function () {
    if (errCount === whitelist.length) {
      throw firstErr
    } else {
      return true
    }
  })
}
978966
function validateQuery(query) {
        Validate.isObject(query);
        Validate.notNull(query);
        
        var components = query.getComponents();
        
        for (var i in components.ordering) {
            throw new Error('orderBy and orderByDescending clauses are not supported in the pull query');
        }
        
        if (components.skip) {
            throw new Error('skip is not supported in the pull query');
        }

        if (components.take) {
            throw new Error('take is not supported in the pull query');
        }

        if (components.selections && components.selections.length !== 0) {
            throw new Error('select is not supported in the pull query');
        }

        if (components.includeTotalCount) {
            throw new Error('includeTotalCount is not supported in the pull query');
        }
    }
1235861
@Override
    protected void validate(List<TableInfo> tableInfos)
    {
        try
        {
            if (!checkForDBExistence())
            {
                throw new SchemaGenerationException("Database " + databaseName + " not exist");
            }

            for (TableInfo tableInfo : tableInfos)
            {
                Map<String, MapReduce> views = new HashMap<String, MapReduce>();
                String id = CouchDBConstants.DESIGN + tableInfo.getTableName();
                CouchDBDesignDocument designDocument = getDesignDocument(id);
                designDocument.setLanguage(CouchDBConstants.LANGUAGE);
                views = designDocument.getViews();
                if (views == null)
                {
                    logger.warn("No view exist for table " + tableInfo.getTableName()
                            + "so any query will not produce any result");
                    return;
                }
                for (IndexInfo indexInfo : tableInfo.getColumnsToBeIndexed())
                {
                    if (views.get(indexInfo.getColumnName()) == null)
                    {
                        logger.warn("No view exist for column " + indexInfo.getColumnName() + " of table "
                                + tableInfo.getTableName() + "so any query on column " + indexInfo.getColumnName()
                                + "will not produce any result");
                    }
                }

                // for id column.
                if (views.get(tableInfo.getIdColumnName()) == null)
                {
                    logger.warn("No view exist for id column " + tableInfo.getIdColumnName() + " of table "
                            + tableInfo.getTableName() + "so any query on id column " + tableInfo.getIdColumnName()
                            + "will not produce any result");
                }

                // for select all.
                if (views.get("all") == null)
                {
                    logger.warn("No view exist for select all for table " + tableInfo.getTableName()
                            + "so select all query will not produce any result");
                }
            }
        }
        catch (Exception e)
        {
            throw new SchemaGenerationException("Database " + databaseName + " not exist");
        }
    }
1025282
function (database, callback) {
        var s = this,
            querier = s._querier;
        querier.connect();
        async.waterfall([
            function (callback) {
                querier.showTables(database, function (err, tables) {
                    callback(err, tables);
                });
            },
            function (tables, callback) {
                var tableNames = s._parseTableNames(tables);
                async.map(tableNames, function (table, callback) {
                    querier.selectKeyColumnUsage(database, table, function (err, data) {
                        callback(err, {
                            name: table,
                            keyColumnUsage: s._parseTableKeyColumnUsageData(data)
                        });
                    });
                }, callback);
            },
            function (data, callback) {
                var database = {};
                data.forEach(function (data) {
                    database[data.name] = data.keyColumnUsage;
                });
                callback(null, database);
            }
        ], function (err, result) {
            querier.disconnect();
            callback(err, result);
        });
        return s;
    }
195573
function getDatabase(index, opts) {
  var db;
  if(!this._databases[index]) {
    db = new Database(this, opts);
    this._databases[index] = db;
  }
  return this._databases[index];
}
372643
function validate( opts, options ) {
	if ( !isObject( options ) ) {
		return new TypeError( 'invalid argument. Options argument must be an object. Value: `' + options + '`.' );
	}
	if ( options.hasOwnProperty( 'radix' ) ) {
		opts.radix = options.radix;
		if ( !isInteger( opts.radix ) ) {
			return new TypeError( 'invalid option. Radix must be an integer. Option: `' + opts.radix + '`.' );
		}
		if ( opts.radix < 2 || opts.radix > 36 ) {
			return new RangeError( 'invalid option. Radix must be an integer on the interval [2,36]. Option: `' + opts.radix + '`.' );
		}
	}
	return null;
}
114155
public void execute(IDocumentStore store, DocumentConventions conventions, String database) {
        DocumentConventions oldConventions = getConventions();
        try {
            setConventions(ObjectUtils.firstNonNull(conventions, getConventions(), store.getConventions()));

            IndexDefinition indexDefinition = createIndexDefinition();
            indexDefinition.setName(getIndexName());

            if (lockMode != null) {
                indexDefinition.setLockMode(lockMode);
            }

            if (priority != null) {
                indexDefinition.setPriority(priority);
            }

            store.maintenance().forDatabase(ObjectUtils.firstNonNull(database, store.getDatabase())).send(new PutIndexesOperation(indexDefinition));
        } finally {
            setConventions(oldConventions);
        }
    }
556151
function requireValidColumns (model, extraColumns) {
    assert.equal(typeof extraColumns, 'object', 'columns must be object')
    // clone arg since it may be modified
    extraColumns = _.cloneDeep(extraColumns)
    // validate each column definition
    _.each(extraColumns, (spec, name) => {
        // check if name is a default column name
        var defaultColumnName = model.columnName(name)
        // spec is for default column
        if (defaultColumnName) {
            // if spec is false then remove default column
            if (spec === false) {
                // delete all entries for default column
                delete model.columns[defaultColumnName]
                delete model.defaultColumnsInverse[model.defaultColumns[defaultColumnName]]
                delete model.defaultColumns[defaultColumnName]
                // delete original entry in extra columns
                delete extraColumns[name]
            }
            // otherwise override default values with spec
            else {
                // merge spec over default
                _.merge(model.columns[defaultColumnName], spec)
                // delete original entry in extra columns
                delete extraColumns[name]
            }
        }
        // spec is for extra column
        else {
            // get validated spec
            extraColumns[name] = requireValidColumn(name, spec)
        }
    })

    // return validated columns
    return extraColumns
}
1323475
def ensure_table(self, cls):
        """"""
        coll_name = cls.get_table_name()
        try:
            db = self.mongo_client.get_default_database()
            db.create_collection(coll_name)
        except CollectionInvalid:
            pass  # Expected if collection already exists

        # Make sure we have indexes
        coll = self.get_collection(coll_name)
        for idx_name in cls.index_names():
            coll.ensure_index(idx_name)
318948
protected function validateDatabase()
    {
        $databaseConfig = DB::getConfig();
        // Gracefully fail if no DB is configured
        if (empty($databaseConfig['database'])) {
            $this->detectLegacyEnvironment();
            $this->redirectToInstaller();
        }
    }
1086898
function validateQuery(query) {
		Assert.ok(((query) && ((typeof query) === 'object')),
			'The Query object was not set?');
		Assert.ok(((query.QueryString) && ((typeof query.QueryString) === 'string')),
			'The query string was not set?');
		Assert.ok(((query.ResultConfiguration) && ((typeof query.ResultConfiguration) === 'object')),
			'The result configuation in the query object was not set?');
		Assert.ok(((query.ResultConfiguration.OutputLocation) && ((typeof query.ResultConfiguration.OutputLocation) === 'string')),
			'The output location of the result configuration in the query object was not set?');
		return query;
}
63293
function requireValidArgsModule (args) {
    // do not check if strict mode not set
    if (!this.strict) {
        return
    }
    // require valid session
    this.requireValidSession(args.session)
    // require module and method
    assert.ok(typeof args.module === 'string' && typeof args.method === 'string', 'module and method required to request access for module')
}