sqlident

package
v1.166.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sqlident reads a SQL statement lexically for what it names: every identifier outside strings and comments, and whether it selects every column of a table (a * projection). Dialect-agnostic, since it tokenizes rather than parses. Semantic enrichment narrows column context to the identifiers a statement names, and the Trino PII prompt counts only the columns it reads (#2586).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Identifiers

func Identifiers(sql string) map[string]bool

Identifiers lexes a SQL string and returns all identifiers found, lowercased. This is dialect-agnostic because it operates at the lexical level (tokenization), not at the grammar level (parsing). String literals, block comments, and line comments are skipped entirely. Double-quoted identifiers are extracted and lowercased.

The function runs in O(n) time with a single pass over the input.

func ReadsEveryColumn

func ReadsEveryColumn(sql string) bool

ReadsEveryColumn reports whether a statement selects every column of a table it reads: a `*` projection, bare (`SELECT *`, `SELECT a, *`) or qualified (`t.*`). A star inside parentheses (`count(*)`) and a multiplication (`a * b`) read no column by themselves and do not count, and a star inside a string literal, a quoted identifier or a comment is not read at all.

It is lexical, like Identifiers, and errs toward true: the PII consent check counts every PII column of a table when this holds, and a missed star would let a query read personal data without the prompt (#2586).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL