v icon indicating copy to clipboard operation
v copied to clipboard

sqlite: Functions thats returns the values resulting from a 'SELECT' query and name of column - Feature ISSUE #20565

Open viniciusfdasilva opened this issue 2 years ago • 0 comments

This pull request addresses the feature mentioned in issue #20565 and implements a function that returns the values resulting from a 'SELECT' query and the name of each column. If an alias is provided either through the 'as' command or not, the returned value becomes the alias.

'SELECT SYNTAX' - Documentation 'JOIN SYNTAX' - Documentation

Source code

Examples:

All fields

r := db.get_queryset('SELECT * FROM repository')! 

query1

All names with explicit names

r := db.get_queryset('SELECT name, id FROM repository')!

query2

All fields with alias

r := db.get_queryset('SELECT name as n, id i FROM repository')!

query3

Specific field

r := db.get_queryset('SELECT name FROM repository')! 

query4

Specific field with alias and 'as'

r := db.get_queryset('SELECT name as n FROM repository')! 

query5e6

Specific field with alias without 'as'

r := db.get_queryset('SELECT name n FROM repository')! 

query5e6

All tests are in: vlib/db/sqlite/sqlite_test.v

OUTPUT TESTS

test

viniciusfdasilva avatar Jan 25 '24 03:01 viniciusfdasilva