Commit Graph

2256 Commits

Author SHA1 Message Date
Pekka Enberg
e66648beb8 Merge 'Add support for offset in select queries' from Ben Li
#739
Started adding support for `LIMIT...OFFSET...`
- New `OffsetLimit` opcode
- `OFFSET` is now supported for:
    - `SELECT...LIMIT...OFFSET`
    - `SELECT...GROUP BY...LIMIT...OFFSET`
    - `SELECT...ORDER BY...LIMIT...OFFSET`
    - Subqueries for `SELECT` statements
**In progress/todo**
- [x] Testing
- [x] Handle negative offset value
- **(will make in separate PR)** Add support for
`DELETE...LIMIT...OFFSET`
- **(will make in separate PR)** Use `limit + offset` sum register from
`OffsetLimit` to constrain number of records inserted into sorter

Closes #779
2025-01-30 13:29:49 +02:00
Pekka Enberg
5614a7751c Merge 'implement isnull / not null for filter expressions' from Glauber Costa
Allow us to write queries like:
        SELECT name, type, sql FROM sqlite_schema where sql isnull
and
        SELECT name, type, sql FROM sqlite_schema where sql not null

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

Closes #829
2025-01-30 13:28:53 +02:00
Pekka Enberg
a2ac3132c4 Merge 'Fix SELECT ABS(-9223372036854775808) causes limbo to panic. ' from Krishna Vishal
Now we return `RuntimeError`.  Matches SQLite behavior.
SQLite:
```sql
sqlite> SELECT ABS(-9223372036854775808);
Runtime error: integer overflow
```
Limbo after this fix:
```sql
limbo> SELECT ABS(-9223372036854775808);
Runtime error: integer overflow
```
Closes https://github.com/tursodatabase/limbo/issues/815

Closes #818
2025-01-30 13:25:39 +02:00
Pekka Enberg
4673ac969e Merge 'Fix SELECT -9223372036854775808 result differs from SQLite' from Krishna Vishal
Closes #812
`-9223372036854775808` is `MIN_INT64`. So when we extract out the minus
and try to parse the remainder it becomes greater than MAX_INT64
(9223372036854775807) and will trigger overflow, which converts the
literal into `Real`. So we have to handle it as a special case.

Reviewed-by: Kim Seon Woo (@seonWKim)

Closes #814
2025-01-30 13:25:27 +02:00
Pekka Enberg
4a0701794c Merge 'json_remove() function implementation' from Ihor Andrianov
Uses already implemented json path parser so shares limitations with
json_extract()

Closes #828
2025-01-30 13:24:59 +02:00
Pekka Enberg
c4bab1297d Merge 'Fix labeler.yml ' from Kim Seon Woo
## Changes
- labeler@v4 -> labeler@v5
- GH_TOKEN -> GITHUB_TOKEN
- add sparse checkout action(to properly read `.github/labeler.yml`)
- fix `.github/labeler.yml` which is where the configurations go
## Reference
- Tests in my forked repository
![image](https://github.com/user-
attachments/assets/49ed8e96-7bc9-419b-beca-e838c86fb2d7)
![image](https://github.com/user-
attachments/assets/cab87024-933c-4eb6-a025-c2f8faf0af2f)

Closes #825
2025-01-30 13:24:15 +02:00
Ihor Andrianov
8a01b842a5 fix function import 2025-01-30 04:05:05 +02:00
Glauber Costa
effde1cc04 implement isnull / not null for filter expressions
Allow us to write queries like:

	SELECT name, type, sql FROM sqlite_schema where sql isnull

and

	SELECT name, type, sql FROM sqlite_schema where sql not null
2025-01-29 20:58:04 -05:00
Ihor Andrianov
d968b314ed fix bug for 1 arg 2025-01-30 03:44:33 +02:00
Ihor Andrianov
c500c16eca fix COMPAT.md message 2025-01-30 03:32:39 +02:00
Ihor Andrianov
7455d9718a update COMPAT.md 2025-01-30 03:28:55 +02:00
Ihor Andrianov
ee52192cd8 add unit tests 2025-01-30 03:13:58 +02:00
Ihor Andrianov
ccf51cae80 moved is_json_valid above tests 2025-01-30 02:47:11 +02:00
Ihor Andrianov
d66329343b add tests 2025-01-30 02:41:05 +02:00
Ihor Andrianov
5cf80d8cef cargo clippy 2025-01-30 02:40:35 +02:00
Ihor Andrianov
52eab0544a add Target discrete type to handle array and obj changes 2025-01-30 02:09:01 +02:00
김선우
0101946d67 Fix configuration file 2025-01-30 08:01:50 +09:00
김선우
0c2b774714 Add spare-checkout
- Related issue: https://github.com/actions/labeler/issues/814#issuecomment-2478374811
2025-01-30 08:01:44 +09:00
김선우
79da888c45 Fix labeler.yml 2025-01-30 07:38:58 +09:00
Ihor Andrianov
30d810bfe5 add utility function to get mut ref by path 2025-01-30 00:05:53 +02:00
Ihor Andrianov
305e86ec39 allow path parser accept numbers as keys 2025-01-29 22:39:35 +02:00
Ihor Andrianov
d57d9bef6f add function definition 2025-01-29 22:37:04 +02:00
Pekka Enberg
f086c1b32f Update COMPAT.md 2025-01-29 19:57:04 +02:00
Pekka Enberg
06edf33878 Merge 'json_patch() function implementation' from Ihor Andrianov
First review #820
The function follows RFC 7386 JSON Merge Patch semantics:
* If the patch is null, the target is replaced with null
* If the patch contains a scalar value, the target is replaced with that
value
* If both target and patch are objects, the patch is recursively applied
* null values in the patch result in property removal from the target

Closes #821
2025-01-29 19:54:12 +02:00
Pekka Enberg
db72756d2a Merge 'Changes to json serialization/deserialization' from Ihor Andrianov
Change JSON deserialization to enable json_patch implementation with
SQLite-compatible behavior:
* Preserves duplicate keys in JSON objects
* Applies patches only to the first occurrence of each key
* Trade-off: Changes key lookup from O(1) to O(n) to support duplicate
keys
* Have to be merged before json_patch() function

Closes #820
2025-01-29 19:53:41 +02:00
Pekka Enberg
ffb692b4a1 github: Configure a single Github actions token 2025-01-29 19:49:39 +02:00
krishvishal
f8c1828ddf Matched on i64::checked_abs and changed RuntimeError to IntegerOverflow 2025-01-29 22:34:19 +05:30
Pekka Enberg
4af6eb2f71 Merge 'Refactor Json serialization to accommodate formatters for pretty printing' from Pedro Muniz
Json serialization logic was pulled from serde_json. Google's json5
serialization code was not flexible enough to allow for pretty printing
json, so I believe that the formatter design is a good layer to abstract
this logic. This refactor will trivially enable the implementation of
json_pretty function from sqlite. My other PR for json_quote, #763,
depends a tiny bit on a helper utility from the previous serialization
implementation. If this PR is considered first, I will change the code
in my other PR to account for this.

Reviewed-by: Diego Reis (@diegoreis42)
Reviewed-by: Kacper Madej (@madejejej)

Closes #771
2025-01-29 19:03:14 +02:00
Ihor Andrianov
0048f77b45 add unit tests 2025-01-29 18:05:41 +02:00
Ihor Andrianov
4e7c4e7ced fixes to pass tests 2025-01-29 18:05:41 +02:00
Ihor Andrianov
166d0a7165 add more tests and fixed test for latest sqlite v 2025-01-29 18:05:41 +02:00
Ihor Andrianov
0714ab64af add tests for tricky edge cases 2025-01-29 18:05:40 +02:00
Ihor Andrianov
2407a29e90 refactored into patcher struct and made code more modular and readable 2025-01-29 18:05:40 +02:00
Ihor Andrianov
f164dbdb1e fix case where first patched value applied wins 2025-01-29 18:05:40 +02:00
Ihor Andrianov
8ba43bfc17 add tests for duplicate preservation and first-one-win behavior 2025-01-29 18:05:40 +02:00
Ihor Andrianov
6a605939e6 naming refine 2025-01-29 18:05:39 +02:00
Ihor Andrianov
3f7458faef add general tests 2025-01-29 18:05:39 +02:00
Ihor Andrianov
846a73188a add json_patch implementation 2025-01-29 18:05:39 +02:00
Ihor Andrianov
98be735f5a add json_patch to expr and vm 2025-01-29 18:05:39 +02:00
Ihor Andrianov
70396d7425 add function definition 2025-01-29 18:05:38 +02:00
Ihor Andrianov
5c55615896 add Removed enum type to discard removed fields on parsing stage 2025-01-29 17:59:48 +02:00
Ihor Andrianov
f97d085934 add deserialization patch to represent obj as ordered Vec and preserve duplicates 2025-01-29 17:59:48 +02:00
Pekka Enberg
489e3242c9 Merge 'Add github workflow labeler to automatically add labels ' from Kim Seon Woo
## Purpose of this PR
- Automatically add labels to PRs for easy classification
- We can add useful rules as needed
## Changes
- Add 2 files to configure labeler
- For now, changes under certain directory will add labels
## ETC
- workflow repo: https://github.com/marketplace/actions/labeler

Closes #817
2025-01-29 17:14:36 +02:00
krishvishal
84d47eb582 Fix SELECT ABS(-9223372036854775808) causes limbo to panic. now returns RuntimeError. Fixes https://github.com/tursodatabase/limbo/issues/815 2025-01-29 18:13:58 +05:30
김선우
4e4d7b2805 Add labeler 2025-01-29 20:50:00 +09:00
Pekka Enberg
e47240705c Merge 'bindings/go: Progress on Go driver, first working incremental state' from Preston Thorpe
This PR brings the Go database/sql driver to it's first working state
and adds a Go package to demonstrate.
The example pkg demonstrates (in it's most bare/naive form at this
point):
1. Open database (memory, in this case)
2. Create connection
3. Prepare statement (Create table)
4. `Exec`
5. Prepare statement (Insert, bind 3 arguments (int, string, blob) (
6. `Exec`
7. Prepare statement (Select *)
8. `Columns` -> print columns
9. `Query` -> print rows
10. Close db connection
![image](https://github.com/user-
attachments/assets/b59ec9f5-9ac6-4a59-9cad-fbb57893fbf8)
still tons of work to do but I at least wanted to get it to a state
where it's not totally broken.
I'll add some actual tests tomorrow

Closes #796
2025-01-29 13:10:52 +02:00
krishvishal
39b4122ddd chore: cargo fmt 2025-01-29 15:19:05 +05:30
krishvishal
a4a1ff2b6d Handle special case -9223372036854775808 and prevent conversion to Real 2025-01-29 15:13:57 +05:30
Pekka Enberg
aec7f1ddd2 Merge 'bindings/java: Implement methods in JDBC4ResultSet' from Kim Seon Woo
## Purpose of this PR
- Implement `JDBC4ResultSet`'s `getXXX(columnIndex)` methods
## Changes
- `JDBC4ResultSet`'s `getXXX(columnIndex)` methods are implemented
- Add some docs for clarification(+ leaving history)
## Reference
- [Issue](https://github.com/tursodatabase/limbo/issues/615)

Closes #813
2025-01-29 09:45:26 +02:00
Pekka Enberg
cfc585813b Merge 'implement sqlite_source_id function' from Glauber Costa
Closes #811
2025-01-29 09:45:00 +02:00