schemaref

package
v1.166.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package schemaref finds the names a text qualifies with an application's schema (#2709): SQL such as "SELECT * FROM orders.invoices". Each of an application's environments runs in a schema of its own with the search path set to it, so a name written without the schema reads the environment's own table, and one qualified by the schema reaches that schema from every environment. Prepare removes the qualifier and the save gate refuses an edit that adds one; both read text through this one package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Script

func Script(source string, schemas []string) (out string, names int, loads []scriptlib.Ref)

Script is a script's or a library's source with the schema qualifier removed from every string it holds, how many names that rewrote, and the libraries it loads. Only strings are read: a Starlark name that happens to be the schema's (orders.append) is code, not SQL. A source that does not parse names nothing.

func Unqualified

func Unqualified(text string, schemas []string) (out string, n int)

Unqualified is text with every name qualified by one of schemas written without it, and how many it rewrote: each name where SQL names an object. A name inside a quoted SQL value is data and is left as written (Values lists it), as is a word that is not SQL.

func WithLoads

func WithLoads(source string, moved map[string]int, loads []scriptlib.Ref) string

WithLoads is source with each load of a library in moved pointed at its new version.

Types

type Name

type Name struct {
	Line   int
	Schema string
	Name   string
}

Name is one qualified name a source's string holds: the line of the string, the schema and the name it qualifies.

func Added

func Added(before, after string, schemas []string) (added Name, ok bool)

Added is a qualified name the strings of after hold more often than the strings of before: what an edit adds, which the save gate refuses while what a script already said is left alone. ok is false when the edit adds none; the name is the first string's.

type Value

type Value struct {
	Line int    `json:"line" example:"86"`
	Text string `json:"text" example:"orders.invoices"`
}

Value is a qualified name inside a quoted SQL value: data, such as an outbox row's source table, which prepare leaves as written for a person to change, since the right text differs per environment.

func Values

func Values(source string, schemas []string) []Value

Values is each qualified name inside a quoted SQL value of source's strings, on the line of the string's source text.

func ValuesIn

func ValuesIn(text string, schemas []string) []Value

ValuesIn is each qualified name inside a quoted SQL value of text.

Jump to

Keyboard shortcuts

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