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

fix(entity-generator): include all entity options in EntitySchema definitions #5674

Merged
merged 1 commit into from
Jun 5, 2024

Conversation

boenrobot
Copy link
Collaborator

The getEmbeddableDeclOptions() and getEntityDeclOptions() methods from SourceFile are now reused in EntitySchemaSourceFile, thus ensuring they remain in sync.

Serialization of EntitySchema options had to be adjusted a bit for this reuse, which results in different decisions regarding whitespace in EntitySchema.

Specifically, previously, all options would always be on their own line, while property definitions would always be on their own line each, and then word wrapped at 80 characters each.
Now, instead, 80 character limit is applied on the entirety of the entity options, at every level, with the initial call taking into account the line where the object starts. Whenever a level as a whole would be more than 80 characters, each value is put on its own line, and the limit is applied recursively, taking into account the space before the value.

@boenrobot boenrobot force-pushed the entitySchemaSerialier branch 2 times, most recently from 3bca415 to e0e9530 Compare June 4, 2024 15:39
@boenrobot boenrobot marked this pull request as ready for review June 4, 2024 15:50
Copy link

codecov bot commented Jun 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.74%. Comparing base (ad347e7) to head (189e954).

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #5674    +/-   ##
========================================
  Coverage   99.74%   99.74%            
========================================
  Files         261      261            
  Lines       18121    18122     +1     
  Branches     4437     4213   -224     
========================================
+ Hits        18074    18075     +1     
  Misses         47       47            

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

properties: {
age: { primary: true, type: 'smallint', autoincrement: false },
},
properties: { age: { primary: true, type: 'smallint', autoincrement: false } },
Copy link
Member

Choose a reason for hiding this comment

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

ideally we would keep this as it was, the line breaks for the properties are a good idea, but having this inline with the properties object itself feels rather confusing

Copy link
Collaborator Author

@boenrobot boenrobot Jun 5, 2024

Choose a reason for hiding this comment

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

Fair, I guess...

I've added a bit of a "hack" whereby if an object has the "Config" symbol added (with whatever value), it will force indents, even if the line could otherwise fit into less than 80 characters. I could make it so that depending on the value, we may instead force no indenting even if the value is over 80 characters (rather than unconditionally force indent), but we probably don't need that anywhere for now.

There's still differences from before, but the differences are now the places where the line was over 80 characters even before - it is now properly accounted for... Except in the top level and properties, where I now force indents.

EDIT: And the other amends after that one were about the trailing array comma... I noticed I had accidentally removed that. Now it's back in.

@boenrobot boenrobot force-pushed the entitySchemaSerialier branch 2 times, most recently from d9158eb to c2ae159 Compare June 5, 2024 07:41
…initions

The getEmbeddableDeclOptions() and getEntityDeclOptions() methods
from SourceFile are now reused in EntitySchemaSourceFile, thus ensuring they remain in sync.

Serialization of EntitySchema options had to be adjusted a bit for this reuse,
which results in different decisions regarding whitespace in EntitySchema.

Specifically, previously, all options would always be on their own line,
while property definitions would always be on their own line each, and then
word wrapped at 80 characters each.
Now, instead, 80 character limit is applied on the entirety of the entity options, at every level,
with the initial call taking into account the line where the object starts.
Whenever a level as a whole would be more than 80 characters, each value is put on its own line,
and the limit is applied recursively, taking into account the space before the value.
Comment on lines +77 to +78
entitySchemaOptions.indexes = [];
entitySchemaOptions.indexes = this.meta.indexes.map(index => {
Copy link
Member

Choose a reason for hiding this comment

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

whats the point of the empty array initializer when you override the value on the next line?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops. Oversight from an earlier, never pushed version... I thought I cleaned that up.

@B4nan B4nan merged commit 94ef44e into master Jun 5, 2024
11 checks passed
@B4nan B4nan deleted the entitySchemaSerialier branch June 5, 2024 09:52
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.

None yet

2 participants