mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
tests: build vweb example
This commit is contained in:
parent
8277c976a8
commit
931cf86cc3
@ -231,7 +231,14 @@ pub fn v_build_failing_skipped(zargs string, folder string, skipped []string) bo
|
||||
mut mains := []string{}
|
||||
for f in files {
|
||||
if !f.contains('modules') && !f.contains('preludes') {
|
||||
if f.contains('life_gg') || f.contains('/graph.v') || f.contains('/vweb/') || f.contains('/pg/') || f.contains('rune.v') {
|
||||
//$if !linux {
|
||||
// run pg example only on linux
|
||||
if f.contains('/pg/') {
|
||||
continue
|
||||
}
|
||||
//}
|
||||
|
||||
if f.contains('life_gg') || f.contains('/graph.v') || f.contains('rune.v') {
|
||||
continue
|
||||
|
||||
}
|
||||
|
@ -1,55 +1,58 @@
|
||||
//import pg
|
||||
|
||||
import pg
|
||||
|
||||
struct Modules {
|
||||
id int
|
||||
user_id int
|
||||
name string
|
||||
id int
|
||||
user_id int
|
||||
name string
|
||||
url string
|
||||
//nr_downloads int
|
||||
//nr_downloads int
|
||||
}
|
||||
|
||||
fn test_orm() {
|
||||
/*
|
||||
db := pg.connect('vpm', 'alex')
|
||||
//nr_modules := db.select count from modules
|
||||
//nr_modules := db.select count from Modules where id == 1
|
||||
nr_modules := db.select count from Modules where
|
||||
name == 'Bob' && id == 1
|
||||
println(nr_modules)
|
||||
|
||||
mod := db.select from Modules where id = 1 limit 1
|
||||
println(mod)
|
||||
db := pg.connect(
|
||||
dbname:'vpm'
|
||||
user:'alex'
|
||||
)
|
||||
/*
|
||||
//nr_modules := db.select count from modules
|
||||
//nr_modules := db.select count from Modules where id == 1
|
||||
nr_modules := db.select count from Modules where
|
||||
name == 'Bob' && id == 1
|
||||
println(nr_modules)
|
||||
|
||||
mods := db.select from Modules limit 10
|
||||
for mod in mods {
|
||||
println(mod)
|
||||
}
|
||||
*/
|
||||
mod := db.select from Modules where id = 1 limit 1
|
||||
println(mod)
|
||||
|
||||
/*
|
||||
mod := db.retrieve<Module>(1)
|
||||
mods := db.select from Modules limit 10
|
||||
for mod in mods {
|
||||
println(mod)
|
||||
}
|
||||
*/
|
||||
|
||||
mod := db.update Module set name = name + '!' where id > 10
|
||||
/*
|
||||
mod := db.retrieve<Module>(1)
|
||||
|
||||
mod := db.update Module set name = name + '!' where id > 10
|
||||
|
||||
|
||||
nr_modules := db.select count from Modules
|
||||
where id > 1 && name == ''
|
||||
println(nr_modules)
|
||||
nr_modules := db.select count from Modules
|
||||
where id > 1 && name == ''
|
||||
println(nr_modules)
|
||||
|
||||
nr_modules := db.select count from modules
|
||||
nr_modules := db.select from modules
|
||||
nr_modules := db[:modules].select
|
||||
*/
|
||||
/*
|
||||
mod := select from db.modules where id = 1 limit 1
|
||||
println(mod.name)
|
||||
top_mods := select from db.modules where nr_downloads > 1000 order by nr_downloads desc limit 10
|
||||
top_mods := db.select from modules where nr_downloads > 1000 order by nr_downloads desc limit 10
|
||||
top_mods := db.select<Module>(m => m.nr_downloads > 1000).order_by(m => m.nr_downloads).desc().limit(10)
|
||||
names := select name from db.modules // []string
|
||||
nr_modules := db.select count from modules
|
||||
nr_modules := db.select from modules
|
||||
nr_modules := db[:modules].select
|
||||
*/
|
||||
/*
|
||||
mod := select from db.modules where id = 1 limit 1
|
||||
println(mod.name)
|
||||
top_mods := select from db.modules where nr_downloads > 1000 order by nr_downloads desc limit 10
|
||||
top_mods := db.select from modules where nr_downloads > 1000 order by nr_downloads desc limit 10
|
||||
top_mods := db.select<Module>(m => m.nr_downloads > 1000).order_by(m => m.nr_downloads).desc().limit(10)
|
||||
names := select name from db.modules // []string
|
||||
|
||||
|
||||
n := db.q_int('select count(*) from modules')
|
||||
println(n)
|
||||
*/
|
||||
}
|
||||
n := db.q_int('select count(*) from modules')
|
||||
println(n)
|
||||
*/
|
||||
}
|
||||
|
@ -87,8 +87,19 @@ fn (mut p Parser) vweb() ast.ComptimeCall {
|
||||
// Compile vweb html template to V code, parse that V code and embed the resulting V function
|
||||
// that returns an html string.
|
||||
mut path := p.cur_fn_name + '.html'
|
||||
// if p.pref.is_debug {
|
||||
// if p.pref.is_verbose {
|
||||
println('>>> compiling vweb HTML template "$path"')
|
||||
// }
|
||||
if !os.exists(path) {
|
||||
// Can't find the template file in current directory,
|
||||
// try looking next to the vweb program, in case it's run with
|
||||
// v path/to/vweb_app.v
|
||||
path = os.dir(p.scanner.file_path) + '/' + path
|
||||
if !os.exists(path) {
|
||||
p.error('vweb HTML template "$path" not found')
|
||||
}
|
||||
// println('path is now "$path"')
|
||||
}
|
||||
v_code := tmpl.compile_file(path)
|
||||
mut scope := &ast.Scope{
|
||||
start_pos: 0
|
||||
@ -102,17 +113,6 @@ fn (mut p Parser) vweb() ast.ComptimeCall {
|
||||
println('>>> end of vweb template END')
|
||||
println('\n\n')
|
||||
}
|
||||
/*
|
||||
if !os.exists(path) {
|
||||
// Can't find the template file in current directory,
|
||||
// try looking next to the vweb program, in case it's run with
|
||||
// v path/to/vweb_app.v
|
||||
path = os.dir(p.scanner.file_path) + '/' + path
|
||||
if !os.exists(path) {
|
||||
p.error('vweb HTML template "$path" not found')
|
||||
}
|
||||
}
|
||||
*/
|
||||
// copy vars from current fn scope into vweb_tmpl scope
|
||||
for stmt in file.stmts {
|
||||
if stmt is ast.FnDecl {
|
||||
|
Loading…
Reference in New Issue
Block a user