Documentation ¶
Index ¶
- func Drop(ctx context.Context, dbc DB, schemasuffix string) error
- func Exists(ctx context.Context, dbc DB, schemasuffix string) (bool, error)
- func SchemaName(suffix string) string
- func SchemaSuffixFromHash(doc sqlparser.Document) string
- type Batch
- type DB
- type Deployable
- func (d Deployable) DropAndUpload(ctx context.Context, dbc DB) error
- func (d *Deployable) EnsureUploaded(ctx context.Context, dbc DB) error
- func (d Deployable) IntConst(s string) (int, error)
- func (d *Deployable) IsUploadedFromCache(dbc DB) bool
- func (d Deployable) MustIntConst(s string) int
- func (d Deployable) Patch(sql string) string
- func (d *Deployable) Upload(ctx context.Context, dbc DB) error
- func (d Deployable) WithSchemaSuffix(schemaSuffix string) Deployable
- type Options
- type PreprocessedFile
- type PreprocessorError
- type SQLCodeParseErrors
- type SQLUserError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SchemaName ¶
func SchemaSuffixFromHash ¶
Types ¶
type Batch ¶
func (Batch) LineNumberInInput ¶
LineNumberInInput transforms an error line number when executing the batch, into an absolute line number in StartPos.File
func (Batch) RelativeLineNumberInInput ¶
RelativeLineNumberInInput maps a line number from the output of preprocessing (`outputline)` to a line number in the input of the pre-processing. PS: StartPos must be considered *in addition* to this transform.
type DB ¶
type DB interface { ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row Conn(ctx context.Context) (*sql.Conn, error) BeginTx(ctx context.Context, txOptions *sql.TxOptions) (*sql.Tx, error) }
type Deployable ¶
type Deployable struct { SchemaSuffix string ParsedFiles []string // mainly for use in error messages etc CodeBase sqlparser.Document // contains filtered or unexported fields }
func Include ¶
func Include(opts Options, fsys ...fs.FS) (result Deployable, err error)
Include is used to package SQL code included using the `embed` go feature; constructing a Deployable of SQL code. Currently, only a single packageName is supported, but we can make string e.g. `...string` later.
func MustInclude ¶
func MustInclude(opts Options, fsys ...fs.FS) Deployable
func (Deployable) DropAndUpload ¶
func (d Deployable) DropAndUpload(ctx context.Context, dbc DB) error
UploadWithOverwrite will always drop the schema if it exists, before uploading. This is suitable for named schema suffixes.
func (*Deployable) EnsureUploaded ¶
func (d *Deployable) EnsureUploaded(ctx context.Context, dbc DB) error
EnsureUploaded checks that the schema with the suffix already exists, and if not, creates and uploads it. This is suitable for hash-based schema suffixes. A lock will be taken (globally in SQL) during the process so that multiple concurrent calls from services starting at the same time line up nicely
func (*Deployable) IsUploadedFromCache ¶
func (d *Deployable) IsUploadedFromCache(dbc DB) bool
func (Deployable) MustIntConst ¶
func (d Deployable) MustIntConst(s string) int
func (Deployable) Patch ¶
func (d Deployable) Patch(sql string) string
Patch will preprocess the sql passed in so that it will call SQL code deployed by the receiver Deployable
func (*Deployable) Upload ¶
func (d *Deployable) Upload(ctx context.Context, dbc DB) error
Upload will create and upload the schema; resulting in an error if the schema already exists
func (Deployable) WithSchemaSuffix ¶
func (d Deployable) WithSchemaSuffix(schemaSuffix string) Deployable
type Options ¶
type Options struct { IncludeTags []string // if this is set, parsing or ordering failed and it's up to the caller // to know what one is doing.. PartialParseResults bool }
Options that affect file parsing etc; pass an empty struct to get default options.
type PreprocessedFile ¶
type PreprocessedFile struct {
Batches []Batch
}
func Preprocess ¶
func Preprocess(doc sqlparser.Document, schemasuffix string) (PreprocessedFile, error)
type PreprocessorError ¶
func (PreprocessorError) Error ¶
func (p PreprocessorError) Error() string
type SQLCodeParseErrors ¶
func (SQLCodeParseErrors) Error ¶
func (e SQLCodeParseErrors) Error() string
type SQLUserError ¶
func (SQLUserError) Error ¶
func (s SQLUserError) Error() string
Directories ¶
Path | Synopsis |
---|---|
example
|
|
Simple non-performant recursive descent parser for purposes of sqlcode; currently only supports the special @Enum declarations used by sqlcode.
|
Simple non-performant recursive descent parser for purposes of sqlcode; currently only supports the special @Enum declarations used by sqlcode. |