sqlparser

package
v0.48.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package sqlparser contains SQL parsing functionality for SQLite.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractTableIdentFromCreateTableStmt

func ExtractTableIdentFromCreateTableStmt(stmt string, unescape bool) (schema, table string, err error)

ExtractTableIdentFromCreateTableStmt extracts table name (and the table's schema if specified) from a CREATE TABLE statement. If err is nil, table is guaranteed to be non-empty. If arg unescape is true, any surrounding quotation chars are trimmed from the returned values.

CREATE TABLE "sakila"."actor" ( actor_id INTEGER NOT NULL)  -->  sakila, actor, nil

Types

type ColDef added in v0.48.2

type ColDef struct {
	// DefCtx is the antlr context for the column definition.
	DefCtx *sqlite.Column_defContext

	// Raw is the raw text of the entire column definition.
	Raw string

	// RawName is the raw text of the column name as it appeared in the input.
	// It may be double-quoted.
	RawName string

	// Name is the column name, stripped of any double-quotes.
	Name string

	// RawType is the raw text of the column type as it appeared in the input.
	RawType string

	// Type is the canonicalized column type.
	Type string

	// InputOffset is the character start index of the column definition in the
	// input. The def ends at InputOffset+len(Raw).
	InputOffset int
}

ColDef represents a column definition in a CREATE TABLE statement.

func ExtractCreateTableStmtColDefs added in v0.48.2

func ExtractCreateTableStmtColDefs(stmt string) ([]*ColDef, error)

ExtractCreateTableStmtColDefs extracts the column definitions from a CREATE TABLE statement.

func (*ColDef) String added in v0.48.2

func (cd *ColDef) String() string

String returns the raw text of the column definition.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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