database

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Copyright © 2025 Jose Clavero Anderica (jose.clavero.anderica@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindTablesWithAliases

func FindTablesWithAliases(query string) map[string]string

FindTablesWithAliases extracts table names and their corresponding aliases from a SQL query.

It analyzes the FROM clause, storing table aliases as keys in the returned map. If a table has no alias, its actual name is used as the key.

Parameters:

  • query: The SQL query string to analyze.

Returns:

  • A map where the key is the table alias (or the table name if no alias is used), and the value is the actual table name.

func ManipulateAST

func ManipulateAST(query string, aliasToTable map[string]string) string

ManipulateAST modifies the SQL query by transforming column references to use the `json_extract` function in SQLite3, using the table name as the key.

SQLite3's `json_extract` function is used to extract values from JSON columns efficiently. It allows querying nested JSON fields directly within SQL queries.

Parameters:

  • query: The original SQL query string to be modified.
  • aliasToTable: A map that associates table aliases with their actual table names. If a table has no alias, its name is used as the alias.

Returns:

  • A modified SQL query string with column references wrapped in `json_extract`.

Types

type DbConf

type DbConf interface {
	CreateTable(string)
	Insert([]unstructured.Unstructured, string)
	EvaluateSelect(string) SelectResult
	Destroy()
}

func Load

func Load() DbConf

type SelectResult

type SelectResult struct {
	Columns []string
	Rows    []map[string]any
}

Jump to

Keyboard shortcuts

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