Given a hash and parametric sql string, swap all of the @vars into $N args
and create an array
@param {string} sql Parametric sql string
@param {object} hash All of the named arguments
@return {{sql:string, args:array.<any>}}
340501
function sqlParams(sql, params)
{
  var args = [];

  var keys = sql.match(/@\w+/g);
  var aKeys = sql.match(/\$\d+/g);

  if (keys && aKeys)
    throw new Error(
      'Cannot use both array-style and object-style parametric values');

  // Array-style (native)
  if (aKeys) {
    return { text: sql, values: params };
  }

  // No params
  if (!keys) {
    return { text: sql, values: [] };
  }

  var n = 1;
  keys.forEach(function(key) {
    key = key.substr(1);
    var val = params[key];
    if (val === undefined)
      throw new Error('No value for @' + key + ' provided');
    args.push(val);
    sql = sql.replace('@' + key, '$' + n++);
  });

  return { text: sql, values: args };
}
1084211
private static String hashQuads(String id, Map<String, Object> bnodes, UniqueNamer namer) {
        // return cached hash
        if (((Map<String, Object>) bnodes.get(id)).containsKey("hash")) {
            return (String) ((Map<String, Object>) bnodes.get(id)).get("hash");
        }

        // serialize all of bnode's quads
        final List<Map<String, Object>> quads = (List<Map<String, Object>>) ((Map<String, Object>) bnodes
                .get(id)).get("quads");
        final List<String> nquads = new ArrayList<String>();
        for (int i = 0; i < quads.size(); ++i) {
            nquads.add(toNQuad((RDFDataset.Quad) quads.get(i),
                    quads.get(i).get("name") != null
                            ? (String) ((Map<String, Object>) quads.get(i).get("name")).get("value")
                            : null,
                    id));
        }
        // sort serialized quads
        Collections.sort(nquads);
        // return hashed quads
        final String hash = sha1hash(nquads);
        ((Map<String, Object>) bnodes.get(id)).put("hash", hash);
        return hash;
    }
574596
def replace data_hash = {}
    sql, *binds = SQLHelper.replace :table => name,
                                    :data => @query_default.merge(data_hash),
                                    :prepared => true
    pstmt = prepare :insert, sql
    pstmt.send @update_method, *binds
  end
965194
def flatten_nested_hash(hash, brackets = true)
      f = {}
      hash.each do |key, value|
        _key = brackets ? "[#{key}]" : key.to_s
        if value.class == Hash
          flatten_nested_hash(value).each do |k, v|
            f["#{_key}#{k}"] = v
          end
        elsif value.class == Array
          temp_hash = {}
          value.each_with_index do |v, i|
             temp_hash[i.to_s] = v
          end
          flatten_nested_hash(temp_hash).each do |k, v|
            f["#{_key}#{k}"] = v
          end

        else
          f[_key] = value
        end
      end
      return f
    end
1274991
protected ExposedParsedSql getParsedSql(String sql) {
		if (getCacheLimit() <= 0) {
			return new ExposedParsedSql( NamedParameterUtils.parseSqlStatement(sql) );
		}
		synchronized (this.parsedSqlCache) {
			ExposedParsedSql parsedSql = this.parsedSqlCache.get(sql);
			if (parsedSql == null) {
				parsedSql = new ExposedParsedSql( NamedParameterUtils.parseSqlStatement(sql) );
				this.parsedSqlCache.put(sql, parsedSql);
			}
			return parsedSql;
		}
	}
488938
public List<Object> querySingleRowResults(String sql, String[] args) {
		return db.querySingleRowResults(sql, args);
	}
930245
def flatten_hash hash
      hash.flat_map do |key, value|
        case value
        when Hash
          value.map do |inner_key, inner_value|
            "#{key}[#{inner_key}]=#{inner_value}"
          end
        when Array
          value.map { |inner_value| "#{key}[]=#{inner_value}" }
        else
          "#{key}=#{value}"
        end
      end
    end
870079
def string_hash(hash)
      hash.map { |k, v| [k.to_s, v.to_s] }.to_h
    end
796448
public static Map<String, Object> queryForMap(String sql, Object... args) {
		Map<String, Object> result = new HashMap<String, Object>();
		List<Map<String, Object>> list = queryForList(sql, args);
		if (list.size() > 0) {
			result = list.get(0);
		}
		return result;
	}
329760
def to_hash(args = {}) # :nodoc:
      args ||= {}

      if args[:nested]
        {'url' => self[:@url] || self[:url]}
      else
        hash = super
        hash.merge!('@version' => self['@version']) unless new_record?
        {self.class.json_name => hash}
      end
    end
610712
def prepare_params p
      results = {}
      # Build a new hash with string keys
      p.each { |k, v| results[k.to_s] = v }
      # Sort nested structures
      results.sort.to_h
    end
1246710
private static ImmutableMap<String, Integer> invariableHashes(
      ImmutableMap<String, Member> members, ImmutableSet<String> parameters) {
    ImmutableMap.Builder<String, Integer> builder = ImmutableMap.builder();
    for (String element : members.keySet()) {
      if (!parameters.contains(element)) {
        Member member = members.get(element);
        AnnotationValue annotationValue = member.method.getDefaultValue();
        Optional<Integer> invariableHash = invariableHash(annotationValue);
        if (invariableHash.isPresent()) {
          builder.put(element, (element.hashCode() * 127) ^ invariableHash.get());
        }
      }
    }
    return builder.build();
  }
187731
def hash_to_rets_query_string(hash)
      [].tap do |str|
        hash.each_pair do |k,v|
          val = value_map(v)
          str << "(#{k.to_s.camelize}=#{val})"
        end
      end.join(',')
    end
549323
function _hash() {
    var set = Array.prototype.map.call(arguments, function(v) {
        return typeof v === 'string' ? v : Object.keys(v).join(' ');
    }).join(' ');

    return set.split(/\s+/)
        .reduce(function(res, keyword) {
            res[keyword] = true;
            return res;
        }, {});
}
503216
function query (query, params) {
        let rows = [];
        let stmt = sql.prepare(query);
        params = normalizeParams(params);
        stmt.bind(params);
        while(stmt.step()) {
            rows.push(stmt.getAsObject());
        }
        stmt.free();
        return rows;
    }
640996
function(hash) {
	return function(row) {
		var testValue = function(value, rowValue) {
			if (value === '*' || value === '' || !value) {
				return true;
			}
			if (_.isString(rowValue)) {
				return (rowValue.toLowerCase() === value.toLowerCase());
			}
			if (_.isArray(rowValue)) {
				return (_.contains(_.map(rowValue, function(tag) {
					return _.isString(tag) && tag.toLowerCase();
				}), value.toLowerCase()) && true);
			}
			return false;				
		};
		
		// _.all makes sure all members of the hash pass
		return _.all(hash, function(value, key) {
			var rowValue = row.getAlias(key);
			
			if (rowValue) {
				
				// if the filter value is an array, then the rowValue must also be an array
				if (_.isArray(value) && _.isArray(rowValue)) {
					
					// expression is true if rowValue intersects completely with requested value.
					return _.intersection(value, rowValue).length === value.length;
				}

				// if the value is an array, but not the rowValue, only test the first index;
				return testValue(_.isArray(value) ? value[0] : value, rowValue)
			}
			return false;
		});
	};
}
1233898
def to_hash(args = {}) # :nodoc:
      args ||= {}
      hash = {}

      self.attributes.each do |name, value|
        hash[name] = if value.is_a?(::Array)
          value.map {|x| x.respond_to?(:to_hash) ? call_method_with_optional_parameters(x, :to_hash, :nested => true) : x}
        elsif value.respond_to?(:to_hash)
          call_method_with_optional_parameters(value, :to_hash, :nested => true)
        elsif value.respond_to?(:as_json)
          value.as_json(:nested => true)
        else
          value
        end
      end

      hash
    end