//used internally to normalize the column name if passed in as a string it should be turned into an identifier
356551
func colFunc(name string, col interface{}) SqlFunctionExpression {
	if s, ok := col.(string); ok {
		col = I(s)
	}
	return Func(name, col)
}
648909
func (db *DB) ColNames() ([]string, error) {
	files, err := ioutil.ReadDir(db.path)
	if err != nil {
		return nil, err
	}
	var names []string
	for _, file := range files {
		if strings.ToLower(path.Ext(file.Name())) == Ext {
			names = append(names, file.Name()[0:len(file.Name())-len(Ext)])
		}
	}
	return names, nil
}
416948
func (r *Rows) ColumnTypeDatabaseTypeName(index int) string {
	return strings.ToUpper(r.rows.FieldDescriptions()[index].DataTypeName)
}
1100490
func GtNamed(column, name string) Cmp {
	return Cmp{
		op:     gt,
		column: column,
		value:  param(name),
	}
}
122304
func (w *Writer) WriteColNames(st interface{}) error {
	cols, err := w.e.GetColNames(st)
	if err != nil {
		return err
	}
	w.r++
	return w.w.Write(cols)
}
1130119
func (n *SimpleNameNormalizer) Normalize(name string) string {
	var retMe []byte
	nameBytes := []byte(name)
	for i, b := range nameBytes {
		if n.safeByte(b) {
			if retMe != nil {
				retMe[i] = b
			}
		} else {
			if retMe == nil {
				retMe = make([]byte, len(nameBytes))
				copy(retMe[0:i], nameBytes[0:i])
			}
			retMe[i] = n.Replacement
		}
	}
	if retMe == nil {
		return name
	}
	return string(retMe)
}
743623
func (m *ResultColumn) SourceName() string {
	if m.Col != nil && m.Col.SourceField != "" {
		return m.Col.SourceField
	}
	return m.Name
}
865612
func (ident Identifier) Sanitize() string {
	parts := make([]string, len(ident))
	for i := range ident {
		parts[i] = `"` + strings.Replace(ident[i], `"`, `""`, -1) + `"`
	}
	return strings.Join(parts, ".")
}
1181346
func (table *Table) GetColumnIdx(name string, idx int) *Column {
	if c, ok := table.columnsMap[strings.ToLower(name)]; ok {
		if idx < len(c) {
			return c[idx]
		}
	}
	return nil
}
420824
func (me identifier) Table(table string) IdentifierExpression {
	ret := me.clone()
	if s, ok := me.col.(string); ok && s != "" && me.table == "" && me.schema == "" {
		ret.schema = s
		ret.col = nil
	}
	ret.table = table
	return ret
}
1049230
func DoubleColumn(name string, nullable NullableColumn) NonAliasColumn {
	if !validIdentifierName(name) {
		panic("Invalid column name in int column")
	}
	ic := &doubleColumn{}
	ic.name = name
	ic.nullable = nullable
	return ic
}
637803
func columnNamesCover(normalColNames map[string]struct{}, dependColNames map[string]struct{}) error {
	for name := range dependColNames {
		if _, ok := normalColNames[name]; !ok {
			return errBadField.GenWithStackByArgs(name, "generated column function")
		}
	}
	return nil
}
664300
func SanitizeFieldName(name string) string {
	name = codegen.Goify(name, true)
	if strings.HasSuffix(name, "Id") {
		name = strings.TrimSuffix(name, "Id")
		name = name + "ID"
	}

	return name
}
269988
func SingularizeIdentifier(s string) string {
	if i := reverseIndexRune(s, '_'); i != -1 {
		s = s[:i] + "_" + inflector.Singularize(s[i+1:])
	} else {
		s = inflector.Singularize(s)
	}

	return snaker.SnakeToCamelIdentifier(s)
}
759330
func InNamed(column, name string) Cmp {
	return Cmp{
		op:     in,
		column: column,
		value:  param(name),
	}
}
1008939
func NormalizeNamesInTLF(g *libkb.GlobalContext, writerNames, readerNames []string,
	extensionSuffix string) (string, error) {
	sortedWriterNames := make([]string, len(writerNames))
	var err error
	for i, w := range writerNames {
		sortedWriterNames[i], err = NormalizeAssertionOrName(g, w)
		if err != nil {
			return "", err
		}
	}
	sort.Strings(sortedWriterNames)
	normalizedName := strings.Join(sortedWriterNames, ",")
	if len(readerNames) > 0 {
		sortedReaderNames := make([]string, len(readerNames))
		for i, r := range readerNames {
			sortedReaderNames[i], err = NormalizeAssertionOrName(g, r)
			if err != nil {
				return "", err
			}
		}
		sort.Strings(sortedReaderNames)
		normalizedName += ReaderSep + strings.Join(sortedReaderNames, ",")
	}
	if len(extensionSuffix) != 0 {
		// This *should* be normalized already but make sure.  I can see not
		// doing so might surprise a caller.
		normalizedName += TlfHandleExtensionSep + strings.ToLower(extensionSuffix)
	}

	return normalizedName, nil
}
402111
func columnsToLower(s []string, e error) ([]string, error) {
	if e != nil {
		return nil, e
	}
	d := make([]string, len(s))

	for i := range s {
		d[i] = strings.ToLower(s[i])
	}
	return d, nil
}