37 Commits

Author SHA1 Message Date
Alexander Medvednikov
7d57a19d7e checker: do not allow &u8(0), force nil like we do with &Type(0) 2025-05-03 22:37:51 +03:00
kbkpbot
af947f1af5
db: mysql,pg,sqlite add transaction support (fix #24290) (#24352) 2025-04-29 09:10:13 +03:00
Hitalo Souza
bab3f23189
db: connection pool (#24161) 2025-04-10 03:17:32 +03:00
Delyan Angelov
a80bc23314
tools: cleanup entries from the hardcoded skip_files list in common.v (used by v test, v test-self etc); use the new // vtest build: syntax to mark the tests instead (#23918) 2025-03-13 19:51:51 +02:00
Delyan Angelov
124927ba96
db.sqlite: add tracing for more calls, when using -d trace_sqlite, not just for the ORM 2025-01-07 16:43:10 +02:00
Delyan Angelov
e9bdfa1dd7
db.sqlite: reduce memory usage in common db.exec() methods (#23286) 2024-12-27 18:36:40 +02:00
Rodrigo Abt
e0a63dba62
db.sqlite: add an exec_map function, returning []map[string]string, given an SQL query (#23246) 2024-12-23 16:06:36 +02:00
Felipe Pena
b0772193f8
vlib: enable more satnitized memleak detection runs without false positives on the CI (#23200) 2024-12-20 16:09:16 +02:00
yuyi
da3112e545
all: replace fn name '@xxx' with 'xxx' (#22506) 2024-10-12 22:17:02 +03:00
Felipe Pena
6f97ced860
orm: allow comptime field.name as field name (fix #22329) (#22344) 2024-09-29 07:53:47 +03:00
Delyan Angelov
f890566199
db.sqlite: add instructions for installing SQLite's amalgamation or development package, if it is missing 2024-09-10 17:20:29 +03:00
yuyi
008aaad999
fmt: remove the prefixed module name of const names, that are in the same module (related #22183) (#22185) 2024-09-10 11:25:56 +03:00
yuyi
c51d30bf53
fmt: fix alignment of struct init fields (#22025) 2024-08-11 09:11:24 +03:00
yuyi
ddb6685d8a
fmt: fix and simplify align of struct fields (#21995) 2024-08-05 20:23:39 +03:00
yuyi
209063ffd0
fmt: implement wrapping function's super long arguments (fix #15545, fix #21643) (#21782) 2024-07-02 23:10:00 +03:00
Felipe Pena
1e86e06eb6
orm: fix subquery without where expr (#21598) 2024-06-04 13:22:06 +03:00
Turiiya
1363cc85fd
time: update unix time acces, fix issues related to deviating unix times (#21293) 2024-04-17 00:33:37 +03:00
Felipe Pena
24af002249
v,breaking: add ability to read enum, fn, interface and sumtype attributes in compile-time, change builtin StructAttribute to VAttribute (#21149) 2024-03-31 09:14:33 +03:00
jacksonmowry
8ec990eed8
db.sqlite: fix exec_param_many bug (#21008) 2024-03-13 14:39:15 +02:00
Alexander Medvednikov
f09826e928 all: unwrap const() blocks 2023-11-25 10:02:51 +03:00
Joe C
757929392e
all: update attributes to use new syntax 2023-11-15 16:16:01 +11:00
JalonSolov
24befa0ba6
pg: hande C calls, move to .c.v files (#19739) 2023-11-03 20:43:44 +02:00
Turiiya
690ec7d3a5
all: fix typos (#19693) 2023-10-30 03:28:34 +02:00
Larpon
95509cf8fb
all: make all struct C.XYZ -> pub struct C.XYZ (#19651) 2023-10-25 15:01:50 +03:00
Tim Marston
756075380b
orm: add null handling and option fields (#19379)
* orm: added is none and !is none handling

* orm: added NullType, support option fields and deprecate [nonull]

Nullable DB fields are now determined by corresponding option struct field.  The
[nonull] attribute is deprecated and fields are all NOT NULL now, unless they
are option fields. New orm primitive, NullType, added to support passing none
values to db backends, which have been updated to support it.  Also, empty
string and 0 numberic values are no longer skipped during insert (since they may
be valid values).

* orm: fix [nonull] deprecation warning

* orm: add null handling to update and select

also, improved formatting for orm cgen, and removed optimised operand handling
of orm `is` and `!is` operators

* sqlite: read/report NULLs using new orm NullType

* postgres: returning data primitives now returns new orm.NullType

* orm: initialise NullType Primitives properly

* orm: do not smart cast operands inside sql

* orm: fix bad setting of option value

* orm: improve orm_null_test.v, adding/fixing selects

* orm: cleanup: rename NullType->Null, use serial const, cgen output

* orm: handle automatically generated fields more explicitly

During insert, fields which are
* [sql: serial]
* [default: whatever]
and where the data is a default value (e.g., 0, ""), those fields are not sent
to the db, so that the db can generate auto-increment or default values.  (This
was previously done only for [primary] fields, and not in all circumstances, but
that is not correct -- primary and serial/auto-increment fields are differnet.)

* orm: udpated README

* orm: select cgen fixes: read from uninit res; fail to init res

* orm: udpated tests

* orm: fix option sub-struct fields

* orm: fixed joins to option structs

Changed orm.write_orm_select() so that you pass to it the name of a resut
variable which it populates with the result (or not) and changed use of it in
sql_select_expr() and calls in write_orm_select() to populate substructs.

* orm: fix pg driver handling of NULL results

* orm: move runtime checks to comptime checker; cache checked tables

* orm: vfmt :(

* orm: markdown formatting

* orm: renamed orm.time_ and orm.enum_; updated db drivers

* checker: updated orm tests

* orm: fix issue setting up ast option values as orm primitives

* checker: ORM use of none/options and operations (added tests)

* orm: fixed tests

* db: clean code

* examples: remove orm nonull attributes

* orm: skip test memory santisation for orm_null_test.v

* orm: make the type-to-primitive converstion fns not public

* orm: mv object var c-code from checker->cgen; fix memory corruption

Code in checker/orm.v used the SqlStmtLine object field name to store c-specific
referenecs to option and array fields (for arrays of children).  I moved this
logic to cgen.  And fixed an issue introduced with option fields, where an array
of children was unpacked into a non-array result which could corrupt memory.

* orm: fixed vast error

* orm: skip 2 tests on ubuntu-musl which require sqlite3.h

* cgen: prevent casting a struct (string)

* v fmt orm_fkey_attribute.vv, orm_multidim_array.vv, orm_table_attributes.vv; run `VAUTOFIX=1 ./v vlib/v/compiler_errors_test.v`
2023-10-05 19:09:03 +03:00
yuyi
55ca8d8d8e
fmt: align the custom values of the enum fields (#19331) 2023-09-12 14:44:38 +03:00
jacksonmowry
76b4c92848
db.sqlite: make functions return results, breaking change (#19093) 2023-08-10 05:39:32 +03:00
jacksonmowry
07b36d69f3
db.sqlite: add exec_param_many and exec_param methods (#19071) 2023-08-07 09:00:03 +03:00
Felipe Pena
a7f84e79f8
cgen: fix option unwrap from ovoid function (#18173) 2023-05-14 14:38:14 +03:00
Swastik Baranwal
3d99f1f2c2
checker: disallow struct int to ptr outside unsafe (#17923) 2023-04-13 07:38:21 +02:00
walking devel
8452644ec3
orm: enforce that queries always return a Result, a query-resulting array can be used as a V array in place. (#17871) 2023-04-04 08:23:06 +03:00
walking devel
d0e78b1da6
parser: breaking change, let V ORM queries return arrays for *all* non-count queries, including limit = 1 (#17719) 2023-03-22 09:48:01 +02:00
walking devel
580dbc3f0e
orm: allow inserting empty objects with db.sqlite (SQLite uses a slightly different SQL dialect) (#17334) 2023-02-16 11:34:16 +02:00
walking devel
4747e70d9d
orm: make last_id() return int, instead of orm.Primitive (fix #12110) (#17151) 2023-01-29 16:00:23 +02:00
yuyi
64558df764
vlib: move the mysql/sqlite/pg/mssql modules under vlib/db (#16820) 2023-01-13 17:02:32 +02:00
Alexander Medvednikov
ec4be80bcc Revert "db: increase db module level in vlib "
This reverts commit cd6d17518096a53cc8dbcba276117ed47d95ea41.
2020-03-26 09:23:54 +01:00
yuyi
cd6d175180
db: increase db module level in vlib 2020-03-26 09:21:34 +01:00