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

Optional string in a model throws partial specializations ambiguity error #17

Closed
ahmdmhd opened this issue Oct 7, 2022 · 4 comments
Closed
Assignees

Comments

@ahmdmhd
Copy link

ahmdmhd commented Oct 7, 2022

Defining an optional string in a model throws a Ambiguous partial specializations of 'persisted_type<std::optional<std::string>>' compilation error in Xcode. I'm defining a model as such:

struct Model: realm::object {
  realm::persisted<std::optional<std::string>> optional_string;

  using schema = realm::schema<"model",
  realm::property<"optional_string", &Model::optional_string>
  >;
};

How is it possible to define an optional string? Thank you :)

@jsflax
Copy link
Collaborator

jsflax commented Oct 7, 2022

Hey @ahmdmhd,

This is a bug that will be fixed later today. I will link the PR shortly. Thanks for the catch!

@jsflax jsflax self-assigned this Oct 7, 2022
@jsflax
Copy link
Collaborator

jsflax commented Oct 7, 2022

@ahmdmhd This will be fixed by: #18

Note that we are now supporting cpp17, so the schema does have to be declared slightly differently:

struct Model: realm::object {
  realm::persisted<std::optional<std::string>> optional_string;

  static constexpr auto schema = realm::schema("model",
      realm::property<&Model::optional_string>("optional_string")
  );
};

Once the PR is passing on CI, I will merge it.

@jsflax
Copy link
Collaborator

jsflax commented Oct 7, 2022

@ahmdmhd this should work now. Please check it out and let us know.

@ahmdmhd
Copy link
Author

ahmdmhd commented Oct 13, 2022

Hi @jsflax, thank you for the updates! I tried the recent changes and it's working properly now!

I will close the issue :)

@ahmdmhd ahmdmhd closed this as completed Oct 13, 2022
@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

No branches or pull requests

2 participants