surrealdb / surrealist

Surrealist is the ultimate way to visually manage your SurrealDB database
https://surrealist.app/
MIT License
1.06k stars 81 forks source link

Updating in Explorer not work #205

Closed lkwr closed 4 months ago

lkwr commented 4 months ago

Describe the bug

Updating a record in the explorer does not work.

To Reproduce

  1. Create a new record (CREATE test;)
  2. Navigate to Explorer -> Table: test -> (click newly created record)
  3. Modify the record and save.

The changes are not saved.

Expected behavior

The changes to the record in the explorer save successful.

Cause (in my opinion)

It seems the problem is caused by the badly formatted record id.

Record ids look like this in the explorer:

{
  "id": {
    "tb": "test",
    "id": "77bn3tf5vkgccnwc1goz"
  }
}

But when changing the record id format to the following, it saved as expected.

{
  "id": "test:77bn3tf5vkgccnwc1goz"
}

Environment:

Platform: Desktop
OS: Darwin
Architecture: aarch64
WebView: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko)
Version: 2.0.1
Flags: featureFlags: false, models_view: true, apidocs_view: true, themes: false, newsfeed: true
louisescher commented 4 months ago

Can reproduce on my end as well. The IDs are the issue. Environment:

Platform: Desktop
OS: Windows_NT
Architecture: x86_64
WebView: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.0.0
Version: 2.0.0
Flags: featureFlags: false, models_view: true, apidocs_view: true, themes: false, newsfeed: true

Edit: Running SurrealDB Version 1.4.2 for windows on x86_64

lkwr commented 4 months ago

I did some research and found out that the origin of the problem comes from the RecordId.prototype.toJSON function from surrealdb.js or more precisely when converting a RecordId to json.

By changing the function above to something like the following, thinks work as expected in surrealist: https://github.com/lkwr/surrealdb.js/commit/664d74cb9914b6c0b14328064bf2e66f6176b301


At this line, when converting the query result to json, the RecordId instances get formatted badly which cause this bug. Maybe this helps fixing the bug.

macjuul commented 4 months ago

We are aware of this issue and are working on an improved solution including the option to represent the editor in SurrealQL

macjuul commented 4 months ago

This will be fixed in the next patch release