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

Add flexible schema mapping POC #3635

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

nirinchev
Copy link
Member

@nirinchev nirinchev commented Jun 26, 2024

Notes doc

TODO:
Must-have

  • (NI) Implement the RealmValue.As conversion
  • (LJ) Write the generated MyModel code by hand
  • (LJ) Write some tests that use MyModel and read/write data using the strongly-typed properties

Nice to have

  • (NI) Wire up notification mapping for properties and add some tests
  • (NI+LJ) Write the generator that emits the IDynamicObject implementation
    • Code generator
    • Fody weaver part (if we use .NET)
  • Add support for nested links (embedded document/dictionary - i.e. not links to another collection)
  • Add support for proxying list/dictionary (e.g. List instead of List)
  • Error handling/missing property strategies

Copy link

coveralls-official bot commented Jun 26, 2024

Pull Request Test Coverage Report for Build 9681982895

Details

  • 5 of 10 (50.0%) changed or added relevant lines in 1 file are covered.
  • 7 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.05%) to 81.304%

Changes Missing Coverage Covered Lines Changed/Added Lines %
Realm/Realm/DatabaseTypes/RealmValue.cs 5 10 50.0%
Files with Coverage Reduction New Missed Lines %
Realm/Realm/Handles/SessionHandle.cs 7 84.55%
Totals Coverage Status
Change from base Build 9661237267: -0.05%
Covered Lines: 6838
Relevant Lines: 8257

💛 - Coveralls

Copy link

coveralls-official bot commented Jul 1, 2024

Pull Request Test Coverage Report for Build 9742975006

Details

  • 12 of 15 (80.0%) changed or added relevant lines in 2 files are covered.
  • 7 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.03%) to 81.384%

Changes Missing Coverage Covered Lines Changed/Added Lines %
Realm/Realm/Extensions/CollectionExtensions.cs 0 3 0.0%
Files with Coverage Reduction New Missed Lines %
Realm/Realm/Handles/SessionHandle.cs 7 84.55%
Totals Coverage Status
Change from base Build 9661237267: 0.03%
Covered Lines: 6846
Relevant Lines: 8262

💛 - Coveralls

Comment on lines +601 to +612
if (getValueLines.Length == 0)
{
getValueBody = @"throw new MissingMemberException($""The object does not have a gettable Realm property with name {propertyName}"");";
}
else
{
getValueBody = $@"return propertyName switch
{{
{getValueLines.Indent(trimNewLines: true)}
_ => throw new MissingMemberException($""The object does not have a gettable Realm property with name {{propertyName}}""),
}};";
}

Check notice

Code scanning / CodeQL

Missed ternary opportunity Note

Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.
Comment on lines +617 to +629
if (setValueLines.Length == 0)
{
setValueBody = @"throw new MissingMemberException($""The object does not have a settable Realm property with name {propertyName}"");";
}
else
{
setValueBody = $@"switch (propertyName)
{{
{setValueLines.Indent(trimNewLines: true)}
default:
throw new MissingMemberException($""The object does not have a settable Realm property with name {{propertyName}}"");
}}";
}

Check notice

Code scanning / CodeQL

Missed ternary opportunity Note

Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.
Comment on lines +640 to +651
if (getListValueLines.Length == 0)
{
getListValueBody = @"throw new MissingMemberException($""The object does not have a Realm list property with name {propertyName}"");";
}
else
{
getListValueBody = $@"return propertyName switch
{{
{getListValueLines.Indent(trimNewLines: true)}
_ => throw new MissingMemberException($""The object does not have a Realm list property with name {{propertyName}}""),
}};";
}

Check notice

Code scanning / CodeQL

Missed ternary opportunity Note

Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.
Comment on lines +656 to +667
if (getSetValueLines.Length == 0)
{
getSetValueBody = @"throw new MissingMemberException($""The object does not have a Realm set property with name {propertyName}"");";
}
else
{
getSetValueBody = $@"return propertyName switch
{{
{getSetValueLines.Indent(trimNewLines: true)}
_ => throw new MissingMemberException($""The object does not have a Realm set property with name {{propertyName}}""),
}};";
}

Check notice

Code scanning / CodeQL

Missed ternary opportunity Note

Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.
Comment on lines +672 to +683
if (getDictionaryValueLines.Length == 0)
{
getDictionaryValueBody = @"throw new MissingMemberException($""The object does not have a Realm dictionary property with name {propertyName}"");";
}
else
{
getDictionaryValueBody = $@"return propertyName switch
{{
{getDictionaryValueLines.Indent(trimNewLines: true)}
_ => throw new MissingMemberException($""The object does not have a Realm dictionary property with name {{propertyName}}""),
}};";
}

Check notice

Code scanning / CodeQL

Missed ternary opportunity Note

Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.
Comment on lines +746 to +759
if (property.TypeInfo.IsBacklink)
{
getFieldString = "GetBacklinks";
}
else
{
getFieldString = property.TypeInfo.CollectionType switch
{
CollectionType.List => "GetListValue",
CollectionType.Set => "GetSetValue",
CollectionType.Dictionary => "GetDictionaryValue",
_ => throw new NotImplementedException(),
};
}

Check notice

Code scanning / CodeQL

Missed ternary opportunity Note

Both branches of this 'if' statement write to the same variable - consider using '?' to express intent better.
Copy link

Pull Request Test Coverage Report for Build 9875518284

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 12 of 15 (80.0%) changed or added relevant lines in 2 files are covered.
  • 7 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.03%) to 81.384%

Changes Missing Coverage Covered Lines Changed/Added Lines %
Realm/Realm/Extensions/CollectionExtensions.cs 0 3 0.0%
Files with Coverage Reduction New Missed Lines %
Realm/Realm/Handles/SessionHandle.cs 7 84.55%
Totals Coverage Status
Change from base Build 9661237267: 0.03%
Covered Lines: 6846
Relevant Lines: 8262

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant