150 Commits

Author SHA1 Message Date
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
Alexander Mandrikov
dd063faf65
orm,cgen: fix @[sql: serial] and @[serial] are not the same (fix #23346) (#23678) 2025-02-09 10:54:45 +02:00
Felipe Pena
7078a2e185
orm: fix codegen for option fk (fix #23383) (#23400) 2025-01-07 17:53:37 +02:00
Swastik Baranwal
f089ba9ff2
cgen, checker: allow using smartcasted sumtype variant values in the ORM queries (fix #23239) (#23241) 2024-12-23 16:19:27 +02:00
Elsie
f3d0c53671
orm: fix list generation and escape loose backtick (#23039) 2024-12-02 00:26:16 +02:00
Alexander Mandrikov
e1a5acc1ef
orm: support plain @[serial] attribute for marking struct fields (#22814) 2024-11-09 17:26:22 +02:00
Felipe Pena
fad49da199
orm: fix order by with custom column name (#22813) 2024-11-09 08:24:59 +03:00
daniel-le97
5d76ee4603
orm: fix orm.Connection only allowing immutable Connections (#22684) 2024-10-28 22:29:47 +02:00
Alexander Medvednikov
4ed9d13803 veb: translations via %translation_key 2024-10-20 21:35:27 +03:00
Delyan Angelov
380500a76b
cgen: fix hardcoded db__pg__DB_last_id for x := sql db { insert address into Address } (fix #22583) (#22582) 2024-10-19 11:07:06 +03:00
yuyi
da3112e545
all: replace fn name '@xxx' with 'xxx' (#22506) 2024-10-12 22:17:02 +03:00
yuyi
acf6b344f7
fmt: fix formating a file in an oscillating manner (fix #22223, fix #22026) (#22232) 2024-09-17 09:47:38 +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
79ee4ae046
fmt: fix alignment of enumeration types (#21999) 2024-08-07 15:46:50 +03:00
yuyi
ddb6685d8a
fmt: fix and simplify align of struct fields (#21995) 2024-08-05 20:23:39 +03:00
Felipe Pena
769e9147c3
v: change old attr syntax mention to new one in comments too (#21860) 2024-07-14 09:39:37 +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
Skylear
aaa23bb058
orm: update readme with more specifics (#21697) 2024-06-19 06:53:21 +03:00
Alexander Medvednikov
b5b57a2e07 orm: ilike for case insensitive text search 2024-06-10 11:54:25 +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
Alexander Medvednikov
acf0107493 builtin: str.last_index(); pref: hide-auto-str; 2024-03-28 18:26:30 +03:00
Turiiya
b98dca585c
checker, orm: add error for unchecked option multi return types, fix undefined behavior (#21106) 2024-03-28 07:31:32 +02:00
Delyan Angelov
59a8690dbd
orm: fix orm_option_time_test.v after 2d0ed2c made insert in parent tables with child ones missing fail 2024-02-11 10:02:36 +02:00
GGRei
2d0ed2c1d6
orm: fix orm insert issue if table missing [Issue : #20017] (#20580) 2024-02-10 05:52:09 +03:00
Elliot Chance
b3eae7831e
orm: fix the generated SQL for the "not equal" operator (#20321) 2024-01-01 13:11:23 +02:00
xjzh123
7b04476683
orm: fix the old attribute syntax in the README's example, to the new @[attr] form (#20305) 2023-12-29 19:00:37 +02:00
Delyan Angelov
033d72093a
ci: mark all orm tests as flaky (mainly to reduce the false positives on windows+MSVC, due to 'cannot open file' sqlite3.obj, when it is rebuilt in parallel) 2023-12-12 12:11:19 +02:00
Felipe Pena
dfab24b936
orm: fix code generated for fields of ?[]Type (#20032) 2023-11-30 23:36:50 +02:00
Felipe Pena
00b1ce5760
orm: fix code generation for an option time.Time field (#20031) 2023-11-29 19:30:34 +02:00
Alexander Medvednikov
f09826e928 all: unwrap const() blocks 2023-11-25 10:02:51 +03:00
Delyan Angelov
f7b9e4eafd
vfmt: automate transition from the old [attribute] to the new @[attribute] syntax (#19912) 2023-11-17 17:43:29 +02:00
Turiiya
b347f546f2
all: update remaining deprecated attr syntax (#19908) 2023-11-17 12:03:51 +02:00
Joe C
757929392e
all: update attributes to use new syntax 2023-11-15 16:16:01 +11:00
Turiiya
e465f7490c
tests: cleanup legacy temp path (#19716) 2023-10-31 15:16:19 +02:00
Tim Marston
6974b113e4
orm: make is_null/is_not_null unary ops; don't bind null in where (#19635) 2023-10-24 12:40:03 +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
asvln
6d56639cc1
orm: quote table and field name in [references] (#19387) 2023-09-20 08:56:58 +03:00
Casper Küthe
74d80a5120
orm: add support for V enum struct fields (#19374) 2023-09-18 16:06:26 +03:00
Casper Küthe
2002db703a
orm: support different foreign key types, not just an integer id (#19337) 2023-09-17 07:58:56 +03:00
asvln
2cce907dcb
orm: add references attribute to allow foreign key declarations on fields (#19349) 2023-09-16 12:04:32 +03:00
Casper Küthe
e8d133d548
orm: fix cgen inserting wrong array index (#19324) 2023-09-12 14:50:13 +03:00
Turiiya
1e38cc0986
checker: disallow module name duplicates in local names (#18118) 2023-09-08 23:33:35 +03:00
Casper Küthe
6b3ffe8574
orm: add OR in where on update and delete (#19172) 2023-08-19 19:31:55 +03:00
jacksonmowry
76b4c92848
db.sqlite: make functions return results, breaking change (#19093) 2023-08-10 05:39:32 +03:00
Delyan Angelov
aa61fcb3dc
orm: fix inserting sequential values (id=0), in tables with an i64 primary field (#18791) 2023-07-05 23:25:22 +03:00
Daniel Daudysh
f0fb86f76e
checker,orm: skip compile-time error msg for fields tagged with [skip] and [sql: '-'] (#18700) 2023-06-29 06:43:24 +03:00
Mark aka walkingdevel
6ac09e605e
orm: allow structs without the id field, more flexible primary keys (#18140) 2023-05-09 00:21:42 +03:00
Mark aka walkingdevel
40a97aed1a
docs, orm: update examples (#18106) 2023-05-03 20:33:16 +03:00