Skip to content

3.0 features#127

Merged
kearfy merged 37 commits intomainfrom
micha/fixes
Feb 13, 2026
Merged

3.0 features#127
kearfy merged 37 commits intomainfrom
micha/fixes

Conversation

@kearfy
Copy link
Member

@kearfy kearfy commented Feb 5, 2026

Summary

This PR brings the Java client in line with SurrealDB 3.0: new credential types, run()/export()/import(), live queries, client-side transactions, RecordIdRange and related overloads, and value types (FileRef, Range, Table). It also includes CI/test improvements, input validation, Javadoc, and extra tests to make the PR reviewable.


Breaking changes – credentials

  • Removed: Root, Namespace, Database (in com.surrealdb.signin).
  • Replaced by: RootCredential, NamespaceCredential, DatabaseCredential (same constructors and getters).
  • New: Credential marker interface; Surreal.signin(Credential) accepts all credential types. Signin is deprecated in favour of Credential.
  • Token: getAccess() and getRefresh() added; getToken() kept for compatibility.

New features and API

  • Auth: RecordCredential (record signup/signin), BearerCredential (use existing JWT), Token(access, refresh).
  • Surreal: version(), health(), run(name, args...), export(path), import_(path), beginTransaction()Transaction, selectLive(table)LiveStream, useNs/useDb/useDefaults() storing server ns/db in NsDb-style response.
  • RecordId: Rename from Thing; RecordId with array/object keys; RecordIdRange for range select/update/delete/upsert.
  • Value types: FileRef (isFile/getFile, createFile), Range (getRangeStart/getRangeEnd), Table (isTable/getTable, createTable). Regex dropped as a value type (serialization boundary).
  • Transaction: query(), commit(), cancel().
  • LiveStream: next(), close(); implements AutoCloseable for try-with-resources.

CI, build, and tests

  • Workflows: Test and reports workflows start SurrealDB (v3.0.0-beta.3) before running tests. Cross workflow: macOS runner updates (e.g. macos-13 → macos-14/macos-15-intel).
  • Build: Spotless (Java 11+ only, so Java 8 still builds), cargoBuild/cargoBuildRelease in Gradle, test depends on cargoBuild, 15s per-test timeout, single fork. build.rs reads SurrealDB version from Cargo.lock. test-with-timeout.sh for local runs.
  • Integration test: SurrealKV test skipped on Windows (@EnabledOnOs(LINUX, MAC)) with TODO due to “Access is denied (os error 5)” on Windows CI.

Code quality and reviewability (this PR)

  • Validation: RecordCredential requires non-null access; BearerCredential requires non-null token. Params may be null (documented).
  • Docs: Javadoc for Transaction commit/cancel (native throws on failure), LiveNotification.getValue() nullable, Native/FileRef lifetime, and MIGRATION.md for credentials.
  • LiveStream: Implements AutoCloseable; tests use try-with-resources.
  • Tests added: RecordCredential null access, BearerCredential null token, export/import missing file, transaction double-commit/cancel, LiveStream try-with-resources; disabled placeholder test for future kill(liveQueryId).

@kearfy kearfy marked this pull request as draft February 5, 2026 13:01
Copy link
Member

@macjuul macjuul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also required

  • Update value classes
  • Potentially update class mappers

kearfy and others added 25 commits February 5, 2026 14:14
Java: Value, ValueMut, RecordId, Surreal, ValueClassConverter, ValueBuilder. Rust: value, valuemut, recordid, surreal, id. Tests and VALUE_TYPES_VALIDATION.md.
Co-authored-by: Cursor <cursoragent@cursor.com>
Add RecordId(String table, Array id) and RecordId(String table, Object id). Rust: newRecordIdWithArray, newRecordIdWithObject.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add Surreal.version() and Surreal.health(). Build script injects SURREALDB_VERSION from Cargo.lock; version() falls back to it for embedded.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add Surreal.run(name, args...) to run a SurrealDB function via RETURN query. Rust: Java_com_surrealdb_Surreal_run.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add Surreal.export(path) and Surreal.import_(path). Supported by HTTP and local engines.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add Surreal.selectLive(table) returning LiveStream. Blocking next() via LiveStream.next(), close() releases. LiveNotification has getAction(), getValue(), getQueryId(). Rust: spawn thread for stream, channel to Java.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Add RecordIdRange (table + optional start/end Id) for range queries
- Rust: build_range_value(), value_to_record_id_key(), selectRecordIdRange,
  deleteRecordIdRange, updateRecordIdRangeValue, upsertRecordIdRangeValue
- Surreal: select(RecordIdRange), select(Class, RecordIdRange),
  update(RecordIdRange, UpType, T), delete(RecordIdRange),
  upsert(RecordIdRange, UpType, T)
- Update VALUE_TYPES_VALIDATION.md for record ID ranges

Co-authored-by: Cursor <cursoragent@cursor.com>
- File: Value.isFile(), Value.getFile() -> FileRef (getBucket, getKey);
  ValueMut.createFile(bucket, key). New FileRef.java and fileref.rs.
- Range: Value.isRange(), Value.getRangeStart(), Value.getRangeEnd()
  (Optional<Value> for bounds). Read-only.
- Table: Value.isTable(), Value.getTable() -> String;
  ValueMut.createTable(name).
- Regex: Value.isRegex(), Value.getRegex() -> pattern String;
  ValueMut.createRegex(pattern).
- Set not implemented (no Value::Set in SDK).
- Update VALUE_TYPES_VALIDATION.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
Regex semantics differ by language and are not transferrable across
the boundary (same as other SDKs). Remove isRegex/getRegex/createRegex;
encountering a regex value can result in a serialization error.
Update VALUE_TYPES_VALIDATION.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Record ID: document array/object creation (RecordId(table, Array/Object)).
- Remove resolved minor issue (isBigDecimal fixed in Stage 0).
- Summary: record ID create path supports all key types.

Co-authored-by: Cursor <cursoragent@cursor.com>
Tests:
- ApiTests: version(), health()
- RunTests: run() no-arg, single-arg, multi-arg (string args)
- ExportImportTests: export/import round-trip
- LiveQueryTests: selectLive(), next(), close()
- RecordIdRangeTests: select/update/delete/upsert by RecordIdRange
- ValueTypesTests: FileRef, Table, Range, BigDecimal (query + ValueMut)
- TypeTests: RecordId with array key, RecordId with object key

Fix: Surreal.run(String name, Object... args) now uses java.lang.Object
so run() accepts any Java object (String, Number, etc.) in package
com.surrealdb where Object is the SurrealDB Object type.

Co-authored-by: Cursor <cursoragent@cursor.com>
This reverts commit e00c87c.
@kearfy kearfy marked this pull request as ready for review February 11, 2026 10:55
@kearfy kearfy merged commit 41efcec into main Feb 13, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants