package sql3util

import 

// NamedArg splits an named arg into a key and value,
// around an equals sign.
// Spaces are trimmed around both key and value.
func ( string) (,  string) {
	, , _ = strings.Cut(, "=")
	 = strings.TrimSpace()
	 = strings.TrimSpace()
	return
}

// Unquote unquotes a string.
//
// https://sqlite.org/lang_keywords.html
func ( string) string {
	if len() < 2 {
		return 
	}
	 := [0]
	 := [len()-1]
	 := [1 : len()-1]
	if  == '[' &&  == ']' {
		return 
	}
	if  !=  {
		return 
	}
	var ,  string
	switch  {
	default:
		return 
	case '`':
		,  = "``", "`"
	case '"':
		,  = `""`, `"`
	case '\'':
		,  = `''`, `'`
	}
	return strings.ReplaceAll(, , )
}

// ParseBool parses a boolean.
//
// https://sqlite.org/pragma.html#syntax
func ( string) (,  bool) {
	if len() == 0 {
		return false, false
	}
	if [0] == '0' {
		return false, true
	}
	if '1' <= [0] && [0] <= '9' {
		return true, true
	}
	switch strings.ToLower() {
	case "true", "yes", "on":
		return true, true
	case "false", "no", "off":
		return false, true
	}
	return false, false
}