Example_extractColumns demonstrates extracting column names from a query.
()
| 538 | |
| 539 | // Example_extractColumns demonstrates extracting column names from a query. |
| 540 | func Example_extractColumns() { |
| 541 | sql := "SELECT u.name, u.email FROM users u WHERE u.active = true ORDER BY u.created_at" |
| 542 | |
| 543 | ast, err := gosqlx.Parse(sql) |
| 544 | if err != nil { |
| 545 | log.Fatal(err) |
| 546 | } |
| 547 | |
| 548 | columns := gosqlx.ExtractColumns(ast) |
| 549 | fmt.Printf("Found %d columns\n", len(columns)) |
| 550 | // Output: Found 4 columns |
| 551 | } |
| 552 | |
| 553 | // Example_extractFunctions demonstrates extracting function names from a query. |
| 554 | func Example_extractFunctions() { |
nothing calls this directly
no test coverage detected