Documentation
¶
Overview ¶
Package sqlhint is the shared SQL-error help used by gadak sql and gadak_query (MCP), and the owner of SQL comment stripping (StripComments) used by the group-query and MCP SELECT gates. Status, issue type, and priority names are localized per account; filtering on the display column is the locale trap that returns zero rows silently. A "no such column" error also gets a did-you-mean when the unknown name is close to a real column (GDK-255: issue_key → key) or a prefix of one (GDK-1899: created → created_at, description → both description_adf and description_text).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FirstKeyword ¶
FirstKeyword returns the leading ASCII identifier of s after skipping leading space. Strip comments first (StripComments); this does not.
func StripComments ¶
StripComments removes -- line comments and /* */ block comments outside of string literals and double-quoted identifiers. A block comment is replaced with a space so "SELECT/*x*/1" stays two tokens.
func WithColumnSuggestion ¶
WithColumnSuggestion appends `did you mean "col"?` to a SQLite "no such column" error when one column from hintTables is close enough. When the name exists verbatim on a hint table, the query hit the wrong table — say which one holds it (GDK-974: summary lives on issues_full, and the miss was silent). Distant names stay unadorned — a bad guess is worse than none.
A "no such column"-shaped miss is not the only silent zero: json_each in the FROM list makes `key`/`value` ambiguous against issues_full, and the bare SQLite sentence does not say the function brought its own columns (GDK-595). query is the statement that failed, so the hint can be scoped to it — an ambiguity between two ordinary tables stays unhinted.
func ZeroRowDisplayNameWarning ¶
ZeroRowDisplayNameWarning returns zeroRowWarning when rowCount is 0 and query compares a localized display-name column. Comments are stripped first so a commented example is not a filter.
Types ¶
type SingleSelectVerdict ¶ added in v0.22.0
type SingleSelectVerdict int
SingleSelectVerdict is what ClassifySingleSelect concluded.
const ( // SingleSelectOK: exactly one statement, starting with SELECT or WITH. SingleSelectOK SingleSelectVerdict = iota // SingleSelectEmpty: nothing left once comments and space are stripped. SingleSelectEmpty // SingleSelectMultiStatement: a semicolon other than one trailing. SingleSelectMultiStatement // SingleSelectNoKeyword: non-empty, but no leading keyword to read. SingleSelectNoKeyword // SingleSelectOtherKeyword: a leading keyword that is not SELECT or WITH. // The returned keyword is the one found, verbatim, for the caller's message. SingleSelectOtherKeyword )
func ClassifySingleSelect ¶ added in v0.22.0
func ClassifySingleSelect(q string) (SingleSelectVerdict, string)
ClassifySingleSelect reports whether q is a single SELECT or WITH statement. The second result is the leading keyword as written, set only for SingleSelectOtherKeyword. Callers own the error sentences.