sql

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxQueryCommands caps the advertised command catalog.
	MaxQueryCommands = 512
	// MaxQueryCommandNameRunes caps one command name.
	MaxQueryCommandNameRunes = 64
	// MaxQueryCommandUsageRunes caps one usage line.
	MaxQueryCommandUsageRunes = 256
	// MaxQueryCommandSummaryRunes caps one summary line.
	MaxQueryCommandSummaryRunes = 256
)

Bounds every nonzero query language advertisement must respect, so a plugin can never force an unbounded completion list, overlay, or handshake frame.

View Source
const (
	MaxRows  = 500
	MaxRunes = 50
)
View Source
const (
	// MaxCustomWorkspaceViews caps the advertised custom tab list.
	MaxCustomWorkspaceViews = 8
	// MaxWorkspaceViewIDRunes caps one custom view id.
	MaxWorkspaceViewIDRunes = 64
	// MaxWorkspaceViewLabelRunes caps one custom view label.
	MaxWorkspaceViewLabelRunes = 32
)

Bounds every workspace capability advertisement must respect, so a plugin can never force an unbounded tab row or handshake frame. The values are conservative: a tab label renders in the tab row, and a view id travels on every workspace_view request.

Variables

View Source
var Keywords = []string{
	"ALTER", "AND", "AS", "ASC", "BETWEEN", "BY", "CASE", "CREATE", "DELETE", "DESC", "DISTINCT", "DROP",
	"FROM", "GROUP", "HAVING", "INSERT", "INTO", "JOIN", "LEFT", "LIMIT", "NOT", "NULL", "ON", "OR",
	"ORDER", "RIGHT", "SELECT", "SET", "UPDATE", "VALUES", "WHERE", "WITH",
}
View Source
var SQLQueryLanguage = QueryLanguage{
	Name:        "SQL",
	EditorLabel: "SQL",
	Placeholder: "Enter a query…",
	Lexer:       "sql",
}

SQLQueryLanguage is the legacy SQL default every driver without an explicit query language advertisement gets: the query editor presents SQL with the conventional placeholder and lexer.

Functions

func CloseRows

func CloseRows(rows *sql.Rows, action string, err error) error

func CompletionPrefix

func CompletionPrefix(value string) string

CompletionPrefix returns the word (identifier) at the end of the SQL value. This is used for real-time prefix filtering as the user types.

func DisplayRow

func DisplayRow(values []any) []*string

func ExtractBufferWords

func ExtractBufferWords(text string) []string

ExtractBufferWords extracts identifiers (>=2 chars) from text that aren't SQL keywords.

func ExtractBufferWordsTokens

func ExtractBufferWordsTokens(words []string) []string

ExtractBufferWordsTokens is ExtractBufferWords over pre-tokenized text, so callers that already tokenized the buffer (AnalyzeSQL) avoid a second pass.

func GlobToLike

func GlobToLike(pattern string) string

GlobToLike converts a shell-style wildcard pattern into a SQL LIKE pattern with backslash escapes. In the pattern, * matches any run of characters, ? matches exactly one character, and every other rune — including %, _ and \ — is literal. The result must be used with an ESCAPE '\' clause.

func GlobToRegex

func GlobToRegex(pattern string) string

GlobToRegex converts a shell-style wildcard pattern into an anchored regular expression: * matches any run of characters, ? matches exactly one character, and every other rune is literal.

func IndexColumnsEqual

func IndexColumnsEqual(left, right []string) bool

func IsNumericColumnType

func IsNumericColumnType(typeName string) bool

func IsZeroQueryLanguage

func IsZeroQueryLanguage(ql QueryLanguage) bool

IsZeroQueryLanguage reports whether ql carries no advertisement at all — every field blank and no examples or commands.

func IsZeroWorkspaceCapability

func IsZeroWorkspaceCapability(ws WorkspaceCapability) bool

IsZeroWorkspaceCapability reports whether ws carries no advertisement at all — no standard tabs and no custom views. A nil pointer is not an advertisement either; the helper exists for pointer-free callers.

func MatchColumnType

func MatchColumnType(types []ColumnType, declaration string) (int, []string, bool)

func SanitizeDisplay

func SanitizeDisplay(input string, limits ...int) string

func ValidateColumnAttributeChange

func ValidateColumnAttributeChange(changeAttributes *string, currentAttributes string) error

ValidateColumnAttributeChange returns an error when the caller does not support column-level attribute changes and a non-nil, differing value is requested.

func ValidateColumnChange

func ValidateColumnChange(change ColumnChange) error

func ValidateColumnDef

func ValidateColumnDef(col ColumnDef) error

func ValidateForeignKeyChange

func ValidateForeignKeyChange(change ForeignKeyChange) error

func ValidateIndexChange

func ValidateIndexChange(change IndexChange) error

func ValidateQueryCommands

func ValidateQueryCommands(language string, commands []QueryCommand) error

ValidateQueryCommands checks the static command catalog of one query language advertisement: the list is capped, every entry carries nonblank bounded control-free name/usage/summary, names are ASCII letters/digits/underscores (the exact charset the editor tokenizes, so every advertised name is completable), and names are unique case-insensitively — exact for ASCII, where lowercase folding is total.

func ValidateQueryLanguage

func ValidateQueryLanguage(ql QueryLanguage) error

ValidateQueryLanguage checks the invariant set every nonzero query language advertisement must hold: name, editor label, and placeholder must be nonblank after trimming, every example must be nonblank, and every optional command entry must carry nonblank bounded control-free name/usage/summary, with names unique case-insensitively within the capped list. A zero value is not an advertisement and passes. This is the single Go invariant set shared by driver registration and the plugin conformance runner.

func ValidateStatement

func ValidateStatement(input string) error

func ValidateWorkspaceCapability

func ValidateWorkspaceCapability(ws *WorkspaceCapability) error

ValidateWorkspaceCapability checks the invariant set every workspace capability advertisement must hold: standard tabs come from the fixed set with no duplicates, and the custom view list is capped with every view carrying a nonblank bounded control-free id and label, unique case-insensitively within the list, plus a nonempty scope list of valid kinds with no duplicates. A nil (or all-empty) capability is not an advertisement and passes. This is the single Go invariant set shared by driver registration and the plugin conformance runner.

Types

type BrowseFilter

type BrowseFilter struct {
	Column   string               `json:"column"`
	Operator BrowseFilterOperator `json:"operator"`
	Value    string               `json:"value"`
}

type BrowseFilterOperator

type BrowseFilterOperator string
const (
	BrowseFilterNone         BrowseFilterOperator = ""
	BrowseFilterLike         BrowseFilterOperator = "LIKE"
	BrowseFilterNotLike      BrowseFilterOperator = "NOT LIKE"
	BrowseFilterPattern      BrowseFilterOperator = "PATTERN"
	BrowseFilterNotPattern   BrowseFilterOperator = "NOT PATTERN"
	BrowseFilterEqual        BrowseFilterOperator = "="
	BrowseFilterNotEqual     BrowseFilterOperator = "!="
	BrowseFilterLess         BrowseFilterOperator = "<"
	BrowseFilterLessEqual    BrowseFilterOperator = "<="
	BrowseFilterGreater      BrowseFilterOperator = ">"
	BrowseFilterGreaterEqual BrowseFilterOperator = ">="
	BrowseFilterIsNull       BrowseFilterOperator = "IS NULL"
	BrowseFilterIsNotNull    BrowseFilterOperator = "IS NOT NULL"
)

type BrowseOptions

type BrowseOptions struct {
	Columns []string       `json:"columns"`
	Filters []BrowseFilter `json:"filters"`
	Sorts   []BrowseSort   `json:"sorts"`
	Offset  int            `json:"offset"`
	Limit   int            `json:"limit"`
}

type BrowseSort

type BrowseSort struct {
	Column     string `json:"column"`
	Descending bool   `json:"descending"`
}

type ColumnChange

type ColumnChange struct {
	PreviousName string  `json:"previous_name"`
	Name         string  `json:"name"`
	Type         string  `json:"type"`
	Nullable     bool    `json:"nullable"`
	DefaultValue *string `json:"default_value"`
	Attributes   *string `json:"attributes"`
}

type ColumnDef

type ColumnDef struct {
	Name         string  `json:"name"`
	Type         string  `json:"type"`
	Nullable     bool    `json:"nullable"`
	DefaultValue *string `json:"default_value"`
	Attributes   *string `json:"attributes"`
}

type ColumnInfo

type ColumnInfo struct {
	Name         string      `json:"name"`
	Type         string      `json:"type"`
	Attributes   string      `json:"attributes"`
	Nullable     bool        `json:"nullable"`
	DefaultValue *string     `json:"default_value"`
	PrimaryKey   int         `json:"primary_key"`
	Indexes      []IndexKind `json:"indexes"`
}

type ColumnType

type ColumnType struct {
	Name       string
	Parameters []ColumnTypeParameter
	Attributes []string
	// Label is the human-friendly picker entry, e.g. "VARCHAR — variable-length
	// string". Empty means the type name is shown as-is.
	Label string
}

func ColumnTypes

func ColumnTypes(info DatabaseInfo) []ColumnType

func (ColumnType) Declaration

func (t ColumnType) Declaration(values []string) (string, error)

type ColumnTypeParameter

type ColumnTypeParameter struct {
	Name    string
	Default string
}

type CompletionContext

type CompletionContext int

CompletionContext classifies the cursor position for context-aware suggestions.

const (
	CtxGeneric    CompletionContext = iota // fallback — suggest everything
	CtxTable                               // after FROM/JOIN/INTO — suggest tables, views, schemas, keywords
	CtxExpression                          // after SELECT/WHERE/ON — suggest columns, functions, keywords
	CtxQualified                           // schema. or table. prefix — suggest objects or columns
)

type CustomWorkspaceView

type CustomWorkspaceView struct {
	ID     string              `json:"id"`
	Label  string              `json:"label"`
	Scopes []WorkspaceViewKind `json:"scopes"`
}

CustomWorkspaceView is one plain-data tab a driver advertises: a stable nonblank id, a human label rendered in the workspace tab row, and the scopes it serves (one or more of database/schema/table). It carries no code and no UI: the workbench owns lifecycle, rendering, input, and cancellation; the driver only answers bounded table data for the view.

type DatabaseInfo

type DatabaseInfo struct {
	Product string `json:"product"`
	Version string `json:"version"`
}

type DocumentFormat

type DocumentFormat string

DocumentFormat tags a document payload's serialization so a store's dialect can evolve without breaking the contract.

const (
	// DocumentFormatMongoExtendedJSON is MongoDB relaxed extended JSON,
	// mongoexport-compatible — what the mongodb driver already renders.
	DocumentFormatMongoExtendedJSON DocumentFormat = "application/vnd.perk.mongodb.extjson+json;version=2;mode=relaxed"
)

type DocumentPayload

type DocumentPayload struct {
	Format DocumentFormat `json:"format"`
	Data   []byte         `json:"data"`
}

DocumentPayload is a tagged payload: the store's declared format plus bytes. It carries both document bodies and row identities.

type DocumentReader

type DocumentReader interface {
	ReadDocument(context.Context, string, DocumentPayload) (DocumentPayload, error)
}

DocumentReader loads one complete document by identity.

type DocumentWriteCapability

type DocumentWriteCapability struct {
	Format DocumentFormat `json:"format"`
	Text   bool           `json:"text"`
}

DocumentWriteCapability declares a document store's editor contract: Format is the only payload format the driver accepts, and Text reports whether whole-document text editing is safe. A store that cannot replace a document safely must not advertise Text; it may still expose delete when browse results supply document identities.

type DocumentWriteOperation

type DocumentWriteOperation string

DocumentWriteOperation names a document-write request.

const (
	DocumentWriteRead    DocumentWriteOperation = "read"
	DocumentWriteInsert  DocumentWriteOperation = "insert"
	DocumentWriteReplace DocumentWriteOperation = "replace"
	DocumentWriteDelete  DocumentWriteOperation = "delete"
)

type DocumentWriteRequest

type DocumentWriteRequest struct {
	Operation  DocumentWriteOperation `json:"operation"`
	Collection string                 `json:"collection"`
	ID         *DocumentPayload       `json:"id,omitempty"`
	Document   *DocumentPayload       `json:"document,omitempty"`
}

DocumentWriteRequest is the wire form of a DocumentReader/DocumentWriter call. ID carries the document identity for read/replace/delete; Document carries the body for insert/replace.

type DocumentWriteResponse

type DocumentWriteResponse struct {
	Result   WriteResult      `json:"result"`
	Document *DocumentPayload `json:"document,omitempty"`
}

DocumentWriteResponse is the wire response to a DocumentWriteRequest; Document is set for read.

type DocumentWriter

type DocumentWriter interface {
	InsertDocument(context.Context, string, DocumentPayload) (Result, error)
	ReplaceDocument(context.Context, string, DocumentPayload, DocumentPayload) (Result, error)
	DeleteDocument(context.Context, string, DocumentPayload) (Result, error)
}

DocumentWriter addresses a document store (MongoDB; future DynamoDB). Documents travel as tagged payloads; a second document store brings its own format constant rather than a contract change. ReplaceDocument is whole-document replacement: the driver translates the payload into its native replace, so mutation dialect stays driver-side.

type ForeignKeyChange

type ForeignKeyChange struct {
	Columns          []string `json:"columns"`
	ReferenceTable   string   `json:"reference_table"`
	ReferenceColumns []string `json:"reference_columns"`
	OnDelete         string   `json:"on_delete"`
	OnUpdate         string   `json:"on_update"`
}

type ForeignKeyInfo

type ForeignKeyInfo struct {
	ID               string   `json:"id"`
	Columns          []string `json:"columns"`
	ReferenceTable   string   `json:"reference_table"`
	ReferenceColumns []string `json:"reference_columns"`
	OnDelete         string   `json:"on_delete"`
	OnUpdate         string   `json:"on_update"`
}

type IndexChange

type IndexChange struct {
	Name       string   `json:"name"`
	Unique     bool     `json:"unique"`
	PrimaryKey bool     `json:"primary_key"`
	Columns    []string `json:"columns"`
}

type IndexInfo

type IndexInfo struct {
	Name       string   `json:"name"`
	Unique     bool     `json:"unique"`
	PrimaryKey bool     `json:"primary_key"`
	Columns    []string `json:"columns"`
}

type IndexKind

type IndexKind uint8
const (
	IndexPrimaryKey IndexKind = 1
	IndexUnique     IndexKind = 2
	IndexRegular    IndexKind = 3
)

type NamedValue

type NamedValue struct {
	Name  string `json:"name"`
	Value Value  `json:"value"`
}

NamedValue is one key/value pair of a ValueObject.

type Opened

type Opened struct {
	Target  string
	Service Service
	Info    DatabaseInfo
	Objects []SchemaObject
	// QueryLanguage advertises how the query editor presents this
	// connection's statements; a zero value (no advertisement) falls
	// back to the legacy SQL defaults in the UI.
	QueryLanguage QueryLanguage
	// Workspace advertises the connection's workspace tab capability:
	// the standard tabs it supports beyond Query/Browse and its custom
	// plain-data views. Nil keeps the legacy per-product tab policy
	// exactly; a non-nil advertisement is authoritative for the tab row.
	Workspace *WorkspaceCapability
}

type QueryCommand

type QueryCommand struct {
	Name    string `json:"name"`
	Usage   string `json:"usage"`
	Summary string `json:"summary"`
}

QueryCommand is one static command the query editor may complete from a driver's language advertisement: the canonical command name, a Redis-native-style usage line, and a concise summary. All three are required, nonblank, bounded, and control-free; names must be unique case-insensitively and the list is capped so a plugin can never force an unbounded completion list or handshake frame.

type QueryLanguage

type QueryLanguage struct {
	Name        string         `json:"name"`
	EditorLabel string         `json:"editor_label"`
	Placeholder string         `json:"placeholder"`
	Lexer       string         `json:"lexer,omitempty"`
	Examples    []string       `json:"examples,omitempty"`
	Commands    []QueryCommand `json:"commands,omitempty"`
}

QueryLanguage is the serializable advertisement of how the query editor presents one driver's statements: the language name, the editor tab label, the input placeholder, an optional lexer hint, optional example statements the driver's parser already accepts, and an optional static command catalog for completion. It crosses the plugin DTO boundary unchanged.

func NormalizeQueryLanguage

func NormalizeQueryLanguage(ql QueryLanguage) QueryLanguage

NormalizeQueryLanguage resolves a query language advertisement for presentation: an absent or all-zero advertisement falls back to the legacy SQL default.

type ReferencingForeignKeyInfo

type ReferencingForeignKeyInfo struct {
	Table string `json:"table"`
	ForeignKeyInfo
}

ReferencingForeignKeyInfo identifies a foreign key declared by another table.

type Result

type Result struct {
	Columns         []string      `json:"columns"`
	ColumnTypes     []string      `json:"column_types"`
	Rows            [][]*string   `json:"rows"`
	UntruncatedRows [][]*string   `json:"untruncated_rows"`
	RowsAffected    int64         `json:"rows_affected"`
	HasMore         bool          `json:"has_more"`
	Duration        time.Duration `json:"duration_ns"`
	Truncated       bool          `json:"truncated"`
	// DocumentIDs carries one stable document identity per row, parallel to
	// Rows, for document-capable browse results. Empty when the backend is
	// not document-capable or a row has no identity.
	DocumentIDs []DocumentPayload `json:"document_ids"`
	// Statement is an optional backend-native statement for the operation
	// that produced this result (external plugins return the exact command
	// they executed; compiled-in drivers leave it empty). The workbench
	// logs it in place of the generic write preview when non-blank.
	// Replayability and sensitivity are described by StatementMetadata.
	// Omitted from the wire when empty.
	Statement string `json:"statement,omitempty"`
	// StatementMetadata optionally describes Statement. It is meaningful
	// only when Statement is nonblank; orphan metadata (metadata without a
	// statement) is rejected at the plugin boundary. Omitted from the wire
	// when nil, so older plugins keep the prior shape.
	StatementMetadata *StatementMetadata `json:"statement_metadata,omitempty"`
}

func CollectRows

func CollectRows(rows *sql.Rows) (Result, error)

type RowValue

type RowValue struct {
	Name  string `json:"name"`
	Value Value  `json:"value"`
}

RowValue is one column of a row write: the column name plus its tagged value. Ordering is the caller's ordering; drivers preserve it when constructing parameter lists.

type RowWriteOperation

type RowWriteOperation string

RowWriteOperation names a row-write request.

const (
	RowWriteInsert RowWriteOperation = "insert"
	RowWriteUpdate RowWriteOperation = "update"
	RowWriteDelete RowWriteOperation = "delete"
)

type RowWriteRequest

type RowWriteRequest struct {
	Operation RowWriteOperation `json:"operation"`
	Table     string            `json:"table"`
	Key       []RowValue        `json:"key,omitempty"`
	Values    []RowValue        `json:"values,omitempty"`
}

RowWriteRequest is the wire form of a RowWriter call. Key carries the row identity for update/delete; Values carries the insert/update payload.

type RowWriteResponse

type RowWriteResponse struct {
	Result WriteResult `json:"result"`
}

RowWriteResponse is the wire response to a RowWriteRequest.

type RowWriter

type RowWriter interface {
	InsertRow(context.Context, string, []RowValue) (Result, error)
	UpdateRow(context.Context, string, []RowValue, []RowValue) (Result, error)
	DeleteRow(context.Context, string, []RowValue) (Result, error)
}

RowWriter addresses a store as rows with a primary key (SQL tables; future CQL-style stores). Key values identify the row for update/delete.

type SQLAnalysis

type SQLAnalysis struct {
	Context          CompletionContext
	Prefix           string
	Qualifier        string            // for CtxQualified: schema or table name before the dot
	Aliases          map[string]string // alias → table name (lowercase)
	ReferencedTables []string          // table names mentioned in the query
	Words            []string          // uppercased tokens of the whole value, shared with callers
}

SQLAnalysis holds the result of analyzing cursor position within SQL text.

func AnalyzeSQL

func AnalyzeSQL(value string, row, col int) SQLAnalysis

AnalyzeSQL analyzes the SQL text and cursor column position to determine the completion context.

row and col are 0-indexed cursor position within the text.

type SchemaObject

type SchemaObject struct {
	Database string `json:"database"`
	Type     string `json:"type"`
	Name     string `json:"name"`
	// RowCount is the estimated row count where the engine exposes one
	// (PostgreSQL pg_class.reltuples, MySQL information_schema.table_rows);
	// nil when unknown or when only an exact count exists (SQLite, views).
	RowCount *int64 `json:"row_count"`
}

type Service

type Service interface {
	Close() error
	Info() DatabaseInfo
	Execute(context.Context, string) (Result, error)
	ExecuteReadOnly(context.Context, string) (Result, error)
	Validate(context.Context, string) error
	ListSchema(context.Context) ([]SchemaObject, error)
	TableInfo(context.Context, string) ([]ColumnInfo, error)
	ListIndexes(context.Context, string) ([]IndexInfo, error)
	CreateIndex(context.Context, string, IndexChange) error
	ReplaceIndex(context.Context, string, string, IndexChange) error
	DropIndex(context.Context, string, string) error
	ListForeignKeys(context.Context, string) ([]ForeignKeyInfo, error)
	ListReferencingForeignKeys(context.Context, string) ([]ReferencingForeignKeyInfo, error)
	// ListForeignKeysAll returns every foreign key in the connected schema,
	// keyed by the table that declares it. Products without foreign keys
	// (MongoDB) return an empty map. The app derives inbound edges by
	// scanning for ReferenceTable.
	ListForeignKeysAll(context.Context) (map[string][]ForeignKeyInfo, error)
	// ListIndexesAll returns every index in the connected schema, keyed by
	// table name (collection name for MongoDB).
	ListIndexesAll(context.Context) (map[string][]IndexInfo, error)
	CreateForeignKey(context.Context, string, ForeignKeyChange) error
	ReplaceForeignKey(context.Context, string, string, ForeignKeyChange) error
	DropForeignKey(context.Context, string, string) error
	AlterColumn(context.Context, string, ColumnChange) error
	DropColumn(context.Context, string, string) error
	AddColumn(context.Context, string, ColumnDef) error
	BrowseTable(context.Context, string, BrowseOptions) (Result, error)
}

type StandardWorkspaceTab

type StandardWorkspaceTab string

StandardWorkspaceTab is one standard (built-in) workspace tab a driver may explicitly advertise support for. Query and Browse are never part of the advertisement: those tabs keep their existing per-scope policy for every driver.

const (
	StandardWorkspaceTabColumns     StandardWorkspaceTab = "columns"
	StandardWorkspaceTabIndexes     StandardWorkspaceTab = "indexes"
	StandardWorkspaceTabForeignKeys StandardWorkspaceTab = "foreign_keys"
	StandardWorkspaceTabDiagram     StandardWorkspaceTab = "diagram"
)

The fixed standard tab set. Drivers advertise a subset; absent metadata keeps the legacy per-product policy unchanged.

type StatementMetadata

type StatementMetadata struct {
	Language   string `json:"language"`
	Replayable bool   `json:"replayable"`
	Sensitive  bool   `json:"sensitive"`
}

StatementMetadata is optional structured metadata for a backend-native statement. It is meaningful only when the accompanying statement is nonblank. A nil StatementMetadata (the object omitted from the wire) keeps the legacy defaults — replayable, not sensitive, no language — so a nonblank legacy statement without metadata keeps exactly its current behavior. When the object is present it is authoritative: plugins send all three fields, and the zero value of an absent field decodes as false/empty.

type Value

type Value struct {
	Kind      ValueKind    `json:"kind"`
	String    string       `json:"string,omitempty"`
	Bool      bool         `json:"bool,omitempty"`
	Integer   int64        `json:"integer,omitempty"`
	Float     float64      `json:"float,omitempty"`
	Bytes     []byte       `json:"bytes,omitempty"`
	Decimal   string       `json:"decimal,omitempty"`
	Timestamp string       `json:"timestamp,omitempty"` // RFC 3339
	Array     []Value      `json:"array,omitempty"`
	Object    []NamedValue `json:"object,omitempty"`
}

Value is one tagged cell payload. Exactly the payload matching Kind is meaningful: ValueDefault and ValueNull carry none, ValueString carries String, ValueDecimal/ValueTimestamp carry exact text, and recursive kinds carry Array/Object.

type ValueKind

type ValueKind string

ValueKind tags one RowValue payload. The kind is always serialized, so false, zero, and empty payloads keep distinct representations.

const (
	ValueDefault   ValueKind = "default"
	ValueNull      ValueKind = "null"
	ValueString    ValueKind = "string"
	ValueBool      ValueKind = "bool"
	ValueInteger   ValueKind = "integer"
	ValueFloat     ValueKind = "float"
	ValueBytes     ValueKind = "bytes"
	ValueDecimal   ValueKind = "decimal"
	ValueTimestamp ValueKind = "timestamp"
	ValueArray     ValueKind = "array"
	ValueObject    ValueKind = "object"
)

type WorkspaceCapability

type WorkspaceCapability struct {
	StandardTabs []StandardWorkspaceTab `json:"standard_tabs,omitempty"`
	CustomViews  []CustomWorkspaceView  `json:"custom_views,omitempty"`
}

WorkspaceCapability is the optional workspace tab advertisement of a driver: the subset of standard tabs it supports (Columns, Indexes, Foreign Keys, Diagram) and its ordered custom plain-data views. A nil capability carries no advertisement: the workbench keeps the legacy per-product tab policy exactly, and old plugins and built-in drivers keep their current behavior unchanged. When the capability is present it is authoritative: standard tabs are filtered by the explicit advertisement, and custom views are appended after them in advertised order, filtered by their scopes.

type WorkspaceViewKind

type WorkspaceViewKind string

WorkspaceViewKind is the structured-target kind of a workspace view request, mirroring the workbench's workspace scope kinds.

const (
	WorkspaceViewDatabase WorkspaceViewKind = "database"
	WorkspaceViewSchema   WorkspaceViewKind = "schema"
	WorkspaceViewTable    WorkspaceViewKind = "table"
)

The target kinds a workspace view may serve.

type WorkspaceViewProvider

type WorkspaceViewProvider interface {
	// WorkspaceView executes one advertised custom view for the active
	// structured target. It is a session operation: the caller's context
	// cancels it like any other session call, and the result follows the
	// bounded table-result conventions (500 rows / 300 runes per cell in
	// the display path).
	WorkspaceView(context.Context, WorkspaceViewRequest) (Result, error)
}

WorkspaceViewProvider is the optional interface a service implements when its driver advertises custom workspace views. Compiled-in drivers implement it directly; plugin sessions get it wrapped over the wire only when the plugin's capabilities advertise custom views, so non-advertisers stay source- and protocol-compatible without the method.

type WorkspaceViewRequest

type WorkspaceViewRequest struct {
	ViewID string              `json:"view_id"`
	Target WorkspaceViewTarget `json:"target"`
}

WorkspaceViewRequest is one plain-data request for a custom workspace view: the advertised view id and the active structured target. The result reuses the bounded table-result conventions of Result.

type WorkspaceViewTarget

type WorkspaceViewTarget struct {
	Kind     WorkspaceViewKind `json:"kind"`
	Database string            `json:"database,omitempty"`
	Schema   string            `json:"schema,omitempty"`
	Table    string            `json:"table,omitempty"`
}

WorkspaceViewTarget is the active structured target of one workspace view request: the scope kind plus the identifiers the kind needs. It is plain data, so it crosses the plugin DTO boundary unchanged.

type WriteCapabilities

type WriteCapabilities struct {
	RowWriter bool                     `json:"row_writer"`
	Document  *DocumentWriteCapability `json:"document,omitempty"`
}

WriteCapabilities is the serializable capability descriptor, the durable plugin boundary. Compiled-in drivers are discovered in-process; plugins advertise the same descriptor and are wrapped by a shim.

type WriteCapabilitiesProvider

type WriteCapabilitiesProvider interface {
	WriteCapabilities() WriteCapabilities
}

WriteCapabilitiesProvider is implemented by drivers that can describe their write capabilities without the workbench type-asserting internals.

type WriteResult

type WriteResult struct {
	RowsAffected      int64              `json:"rows_affected"`
	Statement         string             `json:"statement,omitempty"`
	StatementMetadata *StatementMetadata `json:"statement_metadata,omitempty"`
}

WriteResult is the wire-only result envelope; compiled-in adapters return Result{RowsAffected: …} instead. Statement is optional: external plugins may return the exact backend-native command they executed for the write; the host maps it onto Result.Statement. Omitted from the wire when empty, so older plugins keep the prior shape. StatementMetadata maps onto Result.StatementMetadata with the same rules: meaningful only when Statement is nonblank.

Jump to

Keyboard shortcuts

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