Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realm.schemaVersion returns 18446744073709552000 instead of -1 in test #6119

Closed
Yupeng-li opened this issue Sep 7, 2023 · 5 comments · Fixed by #6126
Closed

Realm.schemaVersion returns 18446744073709552000 instead of -1 in test #6119

Yupeng-li opened this issue Sep 7, 2023 · 5 comments · Fixed by #6126

Comments

@Yupeng-li
Copy link

Yupeng-li commented Sep 7, 2023

How frequently does the bug occur?

Always

Description

I use jest to test the realm related logic. Since Realm v12, some of tests start failing because Realm.schemaVersion doesn't return -1 if realm file doesn't exist. Below is a quick test to show the issue.

expect(Realm.schemaVersion('./default.realm')).toBe(-1)

-------------------------------------
Expected: -1
Received: 18446744073709552000

It works as expected in our react-native app.

Stacktrace & log output

No response

Can you reproduce the bug?

Always

Reproduction Steps

No response

Version

12.1.0

What services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

Mac OS 13.5.1 (22G90)

Build environment

RN 0.71.13

Cocoapods version

1.12.1

@kneth
Copy link
Contributor

kneth commented Sep 8, 2023

@Yupeng-li I am surprised if the code snippet worked before v12.0.0. schemaVersion is a (read-only) property on a Realm instances, and not a static method.

We have Realm.exists() which is the static method you should use.

@sync-by-unito sync-by-unito bot added the Waiting-For-Reporter Waiting for more information from the reporter before we can proceed label Sep 8, 2023
@Yupeng-li
Copy link
Author

Hi @kneth , it's in the latest version of realm https://github.com/realm/realm-js/blob/main/packages/realm/src/Realm.ts#L378 and it's documented here

Thank you for pointing me to Realm.exists. I can call it before calling schemaVersion to bypass the issue.

@github-actions github-actions bot added Needs-Attention Reporter has responded. Review comment. and removed Waiting-For-Reporter Waiting for more information from the reporter before we can proceed labels Sep 8, 2023
@kneth
Copy link
Contributor

kneth commented Sep 8, 2023

@Yupeng-li Sorry, I was too fast to say that schemaVersion cannot be used. We need to write a couple of extra tests - and likely fix a bug.

You can still use Realm.exists.

@sync-by-unito sync-by-unito bot removed the Needs-Attention Reporter has responded. Review comment. label Sep 8, 2023
@Yupeng-li
Copy link
Author

@kneth No worries, thank you very much!

@kneth kneth mentioned this issue Sep 12, 2023
7 tasks
@kneth
Copy link
Contributor

kneth commented Sep 12, 2023

@Yupeng-li We have a bug fix in #6126

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants