Commit graph

170 commits

Author SHA1 Message Date
Jussi Saurio
c7672b952b Use Cow for Value::Blob to prevent copies in op_column 2025-12-06 12:08:27 +02:00
Martin Mauch
71695a66da fix: escape backslashes in json_object string values
When json_object received a string containing an unescaped backslash
(e.g., "Hello\World"), it would fail with "malformed JSON" because
the backslash was not escaped before wrapping the string in quotes.

Fix by escaping backslashes before double quotes in both
convert_ref_dbtype_to_jsonb (Conv::NotStrict) and
Jsonb::from_str_with_mode (Conv::ToString).
2025-12-03 21:30:59 +01:00
Pekka Enberg
437d790e88 core/json: Improve error handling in path.rs 2025-11-23 14:12:09 +02:00
Pekka Enberg
f02045f6b6 core/json: Improve error handling in vtab.rs 2025-11-23 14:12:09 +02:00
Pekka Enberg
d415ef3289 core/json: Improve error handling in mod.rs 2025-11-23 14:12:09 +02:00
Pekka Enberg
f46ea475d2 core/json: Improve error handling in ops.rs 2025-11-23 14:12:09 +02:00
Pekka Enberg
85a034ec82 core/json: Improve error handling in jsonb.rs 2025-11-23 14:12:09 +02:00
pedrocarlo
e1d36a2221 clippy fix 2025-11-11 16:11:46 -03:00
pedrocarlo
84268c155b convert json functions to use AsValueRef 2025-11-11 16:11:46 -03:00
pedrocarlo
4a94ce89e3 Change ValueRef::Text to use a &str instead of &[u8] 2025-11-11 16:11:46 -03:00
pedrocarlo
1db13889e3 Change Value::Text to use a Cow<'static, str> instead of Vec<u8> 2025-11-11 16:11:46 -03:00
Pekka Enberg
2be515247f
Merge 'Create AsValueRef trait to allow us to be agnostic over ownership of Value or ValueRef' from Pedro Muniz
Depends on #3919
Also change `op_compare` to reuse the same compare_immutable logic
First step to finish #2304

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #3920
2025-11-10 09:01:59 +02:00
pedrocarlo
9f350f7fd9 change Text variant in ValueRef to hold a TextRef that can automatically convert to &str avoiding string allocations everywhere 2025-11-07 12:47:39 -03:00
Duy Dang
8fba4659c8
Stop blob json parsing at null terminator 2025-11-04 23:04:33 +07:00
Levy A.
77a412f6af refactor: remove unsafe reference semantics from RefValue
also renames `RefValue` to `ValueRef`, to align with rusqlite and other
crates
2025-10-07 10:43:44 -03:00
Mikaël Francoeur
3e915d9868
implement json_tree 2025-09-23 14:22:02 -04:00
Samuel Marks
e333f151ba
[*.rs] Resolve warnings (mostly "hiding a lifetime that's elided elsewhere is confusing") 2025-09-18 22:47:43 -05:00
Pekka Enberg
5ebf6cd128 core/vtab: Wrap InternalVirtualTable with RwLock 2025-09-17 15:43:33 +03:00
Pekka Enberg
a3d23c2738
Merge 'Fix jsonb functions check valid json string binary' from
closes: #2820
```
turso> select user->>'age' as age from json_user;
┌─────┐
│ age │
├─────┤
│  30 │
└─────┘
```

Closes #2821
2025-09-10 14:44:54 +03:00
Mikaël Francoeur
b480b526bc
implement 2-args json_each 2025-09-08 11:34:17 -04:00
Mikaël Francoeur
cf034dbabd
fix rebase 2025-09-05 14:56:09 -04:00
Mikaël Francoeur
54719f4eac
use new internal virtual table type 2025-09-05 14:56:05 -04:00
Mikaël Francoeur
e6d3d6ea54
1-arg json_each implementation 2025-09-05 14:47:40 -04:00
themixednuts
b6e64587cb fix: jsonb functions to check if binary is json string
chore: match sqlite error

chore: use existing slice variable

add better parsing logic, and validation

see sqlite source code @ sqlite/src/json.c -> static int jsonArgIsJsonb

chore: clippy
2025-09-01 19:52:57 -05:00
Mikaël Francoeur
5ed2abf23f
remove Result from signature 2025-08-21 14:45:00 -04:00
Mikaël Francoeur
2ee0132afe
rename functions 2025-08-15 17:08:53 -04:00
Mikaël Francoeur
4a986080d2
add documentation 2025-08-15 14:59:37 -04:00
Nikita Sivukhin
c9e7271eaf properly pass subtype 2025-07-14 11:20:49 +04:00
Nikita Sivukhin
bf25a0e3f1 fix clippy 2025-07-14 11:20:16 +04:00
Nikita Sivukhin
81cd04dd65 add bin_record_json_object and table_columns_json_array functions 2025-07-14 11:19:45 +04:00
Nils Koch
828d4f5016 fix clippy errors for rust 1.88.0 (auto fix) 2025-07-12 18:58:41 +03:00
Nils Koch
2827b86917
chore: fix clippy warnings 2025-06-23 19:52:13 +01:00
Pekka Enberg
e3f71259d8 Rename OwnedValue -> Value
We have not had enough merge conflicts for a while so let's do a
tree-wide rename.
2025-05-15 09:59:46 +03:00
Pekka Enberg
5a60815484 core/json: Remove redundant conditional compilation
The top-level `json` module declaration is already conditional on "json"
feature so no need to do it here.
2025-03-31 09:40:01 +03:00
Pekka Enberg
6258dda5f1 core/json: Rename json_path.rs to path.rs 2025-03-31 09:40:01 +03:00
Pekka Enberg
4a91988755 core/json: Rename json_operations.rs to ops.rs 2025-03-31 09:33:30 +03:00
Pekka Enberg
4b77f52bac core/json: Rename json_cache.rs to cache.rs 2025-03-31 09:32:34 +03:00
Ihor Andrianov
db5e364210
made json an optional module again 2025-03-30 19:01:03 +03:00
Ihor Andrianov
6c126dcd97
add jsonb_set 2025-03-30 18:58:40 +03:00
Ihor Andrianov
dba82b40e3
add compat tests 2025-03-30 18:58:40 +03:00
Ihor Andrianov
92a745ca49
fix tests 2025-03-30 18:58:39 +03:00
Ihor Andrianov
101dd51d7c
add jsonb_group_object and array 2025-03-30 18:58:39 +03:00
Ihor Andrianov
c426c13763
make tests pass 2025-03-30 18:58:38 +03:00
Ihor Andrianov
568dc54b9e
big cleanup 2025-03-30 18:58:33 +03:00
Ihor Andrianov
a983c979c6
jsonb_merge, json_group_array, json_group_object 2025-03-30 18:47:33 +03:00
Pere Diaz Bou
a13b33fec9 clippy again 2025-03-29 22:07:43 +01:00
Pere Diaz Bou
d9f5cd870d clippy 2025-03-29 22:04:08 +01:00
Pere Diaz Bou
5b7fcd27bd make column reuse blob/text fields 2025-03-29 22:02:49 +01:00
Pere Diaz Bou
9291f60722 Introduce Register struct
OwnedValue has become a powerhouse of madness, mainly because I decided
to do it like that when I first introduced AggContext. I decided it was
enough and I introduced a `Register` struct that contains `OwnedValue`,
`Record` and `Aggregation`, this way we don't use `OwnedValue` for
everything make everyone's life harder.

This is the next step towards making ImmutableRecords the default
because I want to remove unnecessary allocations. Right now we clone
OwnedValues when we generate a record more than needed.
2025-03-27 17:53:02 +01:00
Ihor Andrianov
59f00ff0c3
fix not removing lock if cache did not exist 2025-03-24 15:09:18 +02:00