{"modulePath":"github.com/mevdschee/pathsqlx","version":"v0.2.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package pathsqlx\n\n## Functions\n\n```go\nfunc SetMetadataFilename(filename string)\n```\nSetMetadataFilename configures the metadata source. If filename is empty (default), metadata will be read from the database. If filename is non-empty, metadata will be loaded from that YAML file.\n\n## Types\n\n```go\ntype ByRevLen []string\n```\nByRevLen is for reverse length-based sort.\n\n```go\nfunc (a ByRevLen) Len() int\n```\n\n```go\nfunc (a ByRevLen) Less(i, j int) bool\n```\n\n```go\nfunc (a ByRevLen) Swap(i, j int)\n```\n\n```go\ntype DB struct {\n\t*sqlx.DB\n\t// contains filtered or unexported fields\n}\n```\nDB is a wrapper around sqlx.DB\n\n```go\nfunc Connect(driverName, dataSourceName string) (*DB, error)\n```\nConnect opens a database connection and verifies with a ping.\n\n```go\nfunc ConnectContext(ctx context.Context, driverName, dataSourceName string) (*DB, error)\n```\nConnectContext opens a database connection and verifies with a ping, using the provided context.\n\n```go\nfunc MustConnect(driverName, dataSourceName string) *DB\n```\nMustConnect is the same as Connect, but panics on error.\n\n```go\nfunc MustOpen(driverName, dataSourceName string) *DB\n```\nMustOpen is the same as Open, but panics on error.\n\n```go\nfunc NewDb(db *sql.DB, driverName string) *DB\n```\nNewDb returns a new pathsqlx.DB wrapper for an existing sql.DB.\n\n```go\nfunc Open(driverName, dataSourceName string) (*DB, error)\n```\nOpen opens a database connection. This is analogous to sql.Open, but returns a \\*pathsqlx.DB instead.\n\n```go\nfunc (db *DB) PathQuery(query string, arg interface{}, hints map[string]string) (interface{}, error)\n```\nPathQuery is the query that returns nested paths hints parameter allows specifying path overrides for table aliases (e.g., {\"posts\": \"$.posts\", \"$\": \"$.statistics\"})\n\n```go\nfunc (db *DB) PathQueryContext(ctx context.Context, query string, arg interface{}, hints map[string]string) (interface{}, error)\n```\nPathQueryContext behaves exactly like PathQuery but runs the named query context-aware on the connection pool.\n\n```go\nfunc (db *DB) PathQueryTx(ctx context.Context, tx *sqlx.Tx, query string, arg interface{}, hints map[string]string) (interface{}, error)\n```\nPathQueryTx behaves exactly like PathQuery but runs the named query on the supplied transaction, so any prior SET LOCAL on that same transaction/ connection applies to the query.\n\n```go\ntype JoinColumn struct {\n\tLeftAlias   string\n\tLeftColumn  string\n\tRightAlias  string\n\tRightColumn string\n}\n```\nJoinColumn represents column information in a join condition\n\n```go\ntype JoinInfo struct {\n\tLeftAlias  string\n\tLeftTable  string\n\tRightAlias string\n\tRightTable string\n\tJoinType   string // \"LEFT\", \"INNER\", \"RIGHT\", etc.\n\tCondition  string\n\tOnColumns  []JoinColumn\n}\n```\nJoinInfo represents information about a JOIN clause\n\n```go\ntype NamedStmt = sqlx.NamedStmt\n```\nType aliases for sqlx types to enable drop-in replacement\n\n```go\ntype PathHint struct {\n\tAlias string\n\tPath  string\n}\n```\nPathHint represents a path hint from SQL comments\n\n```go\ntype PathInferenceEngine struct {\n\t// contains filtered or unexported fields\n}\n```\nPathInferenceEngine infers JSON paths from query structure\n\n```go\nfunc NewPathInferenceEngine(metadata metadata.MetadataReader) *PathInferenceEngine\n```\nNewPathInferenceEngine creates a new path inference engine\n\n```go\nfunc (e *PathInferenceEngine) InferPaths(analysis *QueryAnalysis, columns []string) (map[string]string, error)\n```\nInferPaths generates JSON paths for query columns based on metadata and query structure\n\n```go\nfunc (e *PathInferenceEngine) InferPathsWithFallback(analysis *QueryAnalysis, columns []string) map[string]string\n```\nInferPathsWithFallback is a helper that provides fallback behavior\n\n```go\nfunc (e *PathInferenceEngine) ValidatePaths(paths map[string]string) error\n```\nValidatePaths checks if inferred paths are valid\n\n```go\ntype QueryAnalysis struct {\n\tTables    map[string]string // alias -\u003e table name\n\tJoins     []JoinInfo\n\tPathHints map[string]string // alias -\u003e path override\n}\n```\nQueryAnalysis contains the parsed query structure\n\n```go\nfunc AnalyzeQuery(sql string, hints map[string]string) (*QueryAnalysis, error)\n```\nAnalyzeQuery parses a SQL query to extract structure information Uses Vitess SQL parser to correctly handle subqueries, CTEs, and complex expressions Falls back to regex parsing if SQL parsing fails (e.g., for non-standard SQL) hints parameter provides path overrides for table aliases\n\n```go\nfunc (a *QueryAnalysis) GetJoinForTable(alias string) *JoinInfo\n```\nGetJoinForTable returns join information for a table alias\n\n```go\nfunc (a *QueryAnalysis) GetTableForAlias(alias string) (string, bool)\n```\nGetTableForAlias returns the table name for a given alias\n\n```go\ntype Result = sql.Result\n```\nType aliases for sqlx types to enable drop-in replacement\n\n```go\ntype Row = sqlx.Row\n```\nType aliases for sqlx types to enable drop-in replacement\n\n```go\ntype Rows = sqlx.Rows\n```\nType aliases for sqlx types to enable drop-in replacement\n\n```go\ntype Stmt = sqlx.Stmt\n```\nType aliases for sqlx types to enable drop-in replacement\n\n```go\ntype Tx = sqlx.Tx\n```\nType aliases for sqlx types to enable drop-in replacement\n\n","path":"github.com/mevdschee/pathsqlx","name":"pathsqlx","synopsis":"","isRedistributable":true}
