From 9772649250016a8558fe9bf07ba94f2c812fa9ef Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 30 Sep 2025 03:22:02 +0300 Subject: [PATCH] usecache: fix duplicates; doc: minor fixes --- doc/docs.md | 2 +- examples/tetris/README.md | 8 ++------ vlib/orm/README.md | 8 ++++---- vlib/v/gen/c/cgen.v | 33 ++++++++++++++++++--------------- vlib/veb/auth/auth.v | 1 + 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/doc/docs.md b/doc/docs.md index f0bb2ae46..543e85780 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -5475,7 +5475,7 @@ println('number of all customers: ${nr_customers}') // V's syntax can be used to build queries: uk_customers := sql db { - select from Customer where country == 'uk' && nr_orders > 0 + select from Customer where country == 'uk' && nr_orders > 0 order by id desc limit 10 }! println('We found a total of ${uk_customers.len} customers matching the query.') for c in uk_customers { diff --git a/examples/tetris/README.md b/examples/tetris/README.md index e31925228..58ee15019 100644 --- a/examples/tetris/README.md +++ b/examples/tetris/README.md @@ -1,12 +1,8 @@ -### Dependencies (Ubuntu) +### Dependencies (Ubuntu/Debian) ```sh -sudo apt install libx11-dev -sudo apt install libxi-dev -sudo apt install libxcursor-dev -sudo apt install libxrandr-dev -sudo apt install libgl-dev +sudo apt install -y libx11-dev libxi-dev libxcursor-dev libxrandr-dev libgl-dev ``` ## Compiling to JS diff --git a/vlib/orm/README.md b/vlib/orm/README.md index 66f05b3d4..a19b926c8 100644 --- a/vlib/orm/README.md +++ b/vlib/orm/README.md @@ -32,7 +32,7 @@ struct Foo { - `[sql: 'name']` sets a custom column name for the field - `[sql_type: 'SQL TYPE']` explicitly sets the type in SQL - `[default: 'raw_sql']` inserts `raw_sql` verbatim in a "DEFAULT" clause when - creating a new table, allowing for SQL functions like `CURRENT_TIME`. For raw strings, + creating a new table, allowing for SQL functions like `CURRENT_TIME`. For raw strings, surround `raw_sql` with backticks (\`). - `[fkey: 'parent_id']` sets foreign key for an field which holds an array @@ -166,7 +166,7 @@ result := sql db { ```v ignore result := sql db { - select from Foo where id > 1 order by id + select from Foo where id > 1 order by id desc }! ``` @@ -198,8 +198,8 @@ sql db { ### time.Time Fields It's definitely useful to cast a field as `time.Time` so you can use V's built-in time functions; -however, this is handled a bit differently than expected in the ORM. `time.Time` fields are -created as integer columns in the database. Because of this, the usual time functions +however, this is handled a bit differently than expected in the ORM. `time.Time` fields are +created as integer columns in the database. Because of this, the usual time functions (`current_timestamp`, `NOW()`, etc) in SQL do not work as defaults. ## Example diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 76b205217..7989f9fcc 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -1224,23 +1224,26 @@ pub fn (mut g Gen) write_typeof_functions() { g.writeln('\tif (sidx == _${sym.cname}_${sub_sym.cname}_index) return "${util.strip_main_name(sub_sym.name)}";') } g.writeln2('\treturn "unknown ${util.strip_main_name(sym.name)}";', '}') - g.definitions.writeln('u32 v_typeof_interface_idx_${sym.cname}(u32 sidx);') - g.writeln2('', 'u32 v_typeof_interface_idx_${sym.cname}(u32 sidx) {') - if g.pref.parallel_cc { - g.extern_out.writeln('extern u32 v_typeof_interface_idx_${sym.cname}(u32 sidx);') - } - for t in inter_info.types { - sub_sym := g.table.sym(ast.mktyp(t)) - if sub_sym.info is ast.Struct && sub_sym.info.is_unresolved_generic() { - continue - } - if g.pref.skip_unused && sub_sym.kind == .struct - && sub_sym.idx !in g.table.used_features.used_syms { - continue + // Avoid duplicate symbol '_v_typeof_interface_idx_IError' when using -usecache + if g.pref.build_mode != .build_module { + g.definitions.writeln('u32 v_typeof_interface_idx_${sym.cname}(u32 sidx);') + g.writeln2('', 'u32 v_typeof_interface_idx_${sym.cname}(u32 sidx) {') + if g.pref.parallel_cc { + g.extern_out.writeln('extern u32 v_typeof_interface_idx_${sym.cname}(u32 sidx);') + } + for t in inter_info.types { + sub_sym := g.table.sym(ast.mktyp(t)) + if sub_sym.info is ast.Struct && sub_sym.info.is_unresolved_generic() { + continue + } + if g.pref.skip_unused && sub_sym.kind == .struct + && sub_sym.idx !in g.table.used_features.used_syms { + continue + } + g.writeln('\tif (sidx == _${sym.cname}_${sub_sym.cname}_index) return ${u32(t.set_nr_muls(0))};') } - g.writeln('\tif (sidx == _${sym.cname}_${sub_sym.cname}_index) return ${u32(t.set_nr_muls(0))};') + g.writeln2('\treturn ${u32(ityp)};', '}') } - g.writeln2('\treturn ${u32(ityp)};', '}') } } g.writeln2('// << typeof() support for sum types', '') diff --git a/vlib/veb/auth/auth.v b/vlib/veb/auth/auth.v index 1da3225db..681ca1fd1 100644 --- a/vlib/veb/auth/auth.v +++ b/vlib/veb/auth/auth.v @@ -25,6 +25,7 @@ pub: } pub fn new[T](db T) Auth[T] { + println('creating table Token') set_rand_crypto_safe_seed() sql db { create table Token -- 2.39.5