ExampleExtractColumns demonstrates extracting column names from a query.
()
| 162 | |
| 163 | // ExampleExtractColumns demonstrates extracting column names from a query. |
| 164 | func ExampleExtractColumns() { |
| 165 | sql := "SELECT u.name, u.email FROM users u WHERE u.active = true ORDER BY u.created_at" |
| 166 | |
| 167 | ast, err := gosqlx.Parse(sql) |
| 168 | if err != nil { |
| 169 | log.Fatal(err) |
| 170 | } |
| 171 | |
| 172 | columns := gosqlx.ExtractColumns(ast) |
| 173 | fmt.Printf("Found %d columns\n", len(columns)) |
| 174 | // Output: Found 4 columns |
| 175 | } |
| 176 | |
| 177 | // ExampleExtractFunctions demonstrates extracting function names from a query. |
| 178 | func ExampleExtractFunctions() { |
nothing calls this directly
no test coverage detected