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

Support Arithmetic function SIZE #626

Merged
merged 5 commits into from
Feb 7, 2024
Merged

Support Arithmetic function SIZE #626

merged 5 commits into from
Feb 7, 2024

Conversation

jbl428
Copy link
Contributor

@jbl428 jbl428 commented Feb 5, 2024

Motivation

  • Support an arithmetic function SIZE.

Modifications

  • Add jpql model and serializer for SIZE

Commit Convention Rule

Commit type Description
feat New Feature
fix Fix bug
docs Documentation only changed
ci Change CI configuration
refactor Not a bug fix or add feature, just refactoring code
test Add Test case or fix wrong test case
style Only change the code style(ex. white-space, formatting)
chore It refers to minor tasks such as library version upgrade, typo correction, etc.
  • If you want to add some more commit type please describe it on the Pull Request

Result

  • The arithmetic function size is added.

Closes

@codecov-commenter
Copy link

codecov-commenter commented Feb 5, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (d257997) 66.40% compared to head (6f94980) 66.47%.

Files Patch % Lines
.../render/jpql/serializer/impl/JpqlSizeSerializer.kt 83.33% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #626      +/-   ##
===========================================
+ Coverage    66.40%   66.47%   +0.06%     
===========================================
  Files          465      467       +2     
  Lines         4748     4760      +12     
  Branches       277      277              
===========================================
+ Hits          3153     3164      +11     
- Misses        1538     1539       +1     
  Partials        57       57              

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


@Internal
data class JpqlSize internal constructor(
val path: Path<*>,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can not sure that this class should take Path or Expression

SIZE(collection_valued_path_expression)

Copy link
Member

Choose a reason for hiding this comment

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

I think Path is a better fit than Expression, and I think we should limit the generic type of Path to Collection.

When I checked the Criteria API, it takes an Expression, but only takes into account the Path.
image

Comment on lines 638 to 707
@SinceJdsl("3.4.0")
fun <T : Any, V> size(expr: KProperty1<T, @Exact V>): Expression<Int> {
return Expressions.size(Paths.path(expr))
}

/**
* Creates an expression that the number of elements of the collection.
*/
@SinceJdsl("3.4.0")
fun <T : Any> size(path: Pathable<T>): Expression<Int> {
return Expressions.size(path.toPath())
}
Copy link
Contributor

@waahhh waahhh Feb 5, 2024

Choose a reason for hiding this comment

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

Sorry😓, this was already mentioned in another comment.

Using a non-collection type as an argument value to the size(..) function results in a runtime error.
For developer experience, why not add a collection type constraint to the generic type parameter so that a compilation error can occur instead of a runtime error?

@shouwn shouwn merged commit 9da2399 into line:develop Feb 7, 2024
4 checks passed
@jbl428 jbl428 deleted the feat/size branch February 7, 2024 01:10
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.

5 participants