-
Notifications
You must be signed in to change notification settings - Fork 1
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 seed data (java.util.UUID/java.util.Instant) #105
Conversation
WalkthroughThe project has been updated to better handle date types, with new classes and logic for date columns and record values. Static analysis is now stricter due to the inclusion of a new wart. Test data generation has shifted from integer IDs to UUIDs, and the volume of generated test data has been reduced. Additionally, entities now have a creation timestamp, and the test suite has been expanded to cover these new features. Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #105 +/- ##
==========================================
+ Coverage 72.00% 73.79% +1.79%
==========================================
Files 20 20
Lines 350 374 +24
Branches 43 42 -1
==========================================
+ Hits 252 276 +24
Misses 98 98 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 2
Configuration used: CodeRabbit UI
Files selected for processing (6)
- build.sbt (1 hunks)
- src/main/scala/domain/table/ddl/column/ColumnType.scala (13 hunks)
- src/main/scala/domain/table/dml/RecordValue.scala (3 hunks)
- src/test/scala/GenerateTestData.scala (13 hunks)
- src/test/scala/domain/table/ddl/column/ColumnTypeSpec.scala (16 hunks)
- src/test/scala/domain/table/dml/RecordValueSpec.scala (2 hunks)
Additional comments: 16
src/main/scala/domain/table/dml/RecordValue.scala (2)
- 8-8: The import of
ColumnTypeDate
is added to support the new date handling functionality.- 19-20: Imports for
java.sql.Timestamp
andjava.time.Instant
are added, which are necessary for the new date handling invaluesForSql
.build.sbt (1)
- 12-12: The addition of
Wart.AsInstanceOf
to thewartremoverErrors
list is a good practice to enforce type safety and prevent the use ofasInstanceOf
.src/test/scala/domain/table/dml/RecordValueSpec.scala (3)
- 6-7: Imports for
java.sql.Timestamp
andjava.time.Instant
are added to support the new test cases for date handling.- 35-35: The test case for the minimum
Instant
value is added, which is good for ensuring that edge cases are handled correctly.- 39-39: The test case for the maximum
Instant
value is added, which is good for ensuring that edge cases are handled correctly.src/test/scala/GenerateTestData.scala (4)
- 13-13: The import of
java.util.UUID
is added to support the generation of unique identifiers usingUUID.randomUUID()
.- 27-27: The use of
UUID.randomUUID()
for generating unique identifiers is a good practice for test data generation.- 32-32: The addition of a
createdAt
property usingfaker.currentEraInstant()
for entities is a good practice to simulate realistic creation timestamps in test data.- 201-203: Adjusting the counts for generating test data is a change that may affect the test coverage. Ensure that the reduced counts still meet the testing requirements.
src/main/scala/domain/table/ddl/column/ColumnType.scala (3)
- 5-5: The import of
java.time.Instant
is added to support the newColumnTypeDate
class.- 51-53: The addition of the
ColumnTypeDate
class with atoSqlSentence
method is a good practice for handling date types in a type-safe manner.- 90-91: The pattern matching logic for
Instant
values in theColumnType.apply
method is a good addition to support the new date type.src/test/scala/domain/table/ddl/column/ColumnTypeSpec.scala (3)
- 6-6: The import of
java.time.Instant
is added to support the new test cases for theColumnType
class handlingInstant
types.- 20-21: The test cases for
Instant.MAX
andInstant.MIN
are added to ensure that theColumnType
class correctly handlesInstant
types.- 88-88: The merge operation test case for
ColumnTypeBoolean
andColumnTypeDate
should be reviewed to ensure that converting a date to a string is the intended behavior.
case ColumnTypeDouble(_) => value | ||
case ColumnTypeUUID => s"'$value'" | ||
case ColumnTypeDate(_) => | ||
s"'${Timestamp.from(value.asInstanceOf[Instant])}'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casting to Instant
using asInstanceOf
is unsafe and contradicts the PR's objective to enhance type safety by preventing the use of asInstanceOf
. This should be refactored to avoid casting and ensure type safety.
- s"'${Timestamp.from(value.asInstanceOf[Instant])}'"
+ // Assuming value is already of type Instant, otherwise a safe conversion is needed
+ s"'${Timestamp.from(value)}'"
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
s"'${Timestamp.from(value.asInstanceOf[Instant])}'" | |
// Assuming value is already of type Instant, otherwise a safe conversion is needed | |
s"'${Timestamp.from(value)}'" |
case (ColumnTypeBoolean, ColumnTypeDate(length)) => | ||
// change Date -> String | ||
ColumnTypeString(length.max(5)) // 5 = false.toString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The merge logic for ColumnTypeBoolean
and ColumnTypeDate
converts the date to a string. This may not be the best approach as it loses the date type information. Consider if this is the intended behavior or if preserving the date type is more appropriate.
- ColumnTypeString(length.max(5)) // 5 = false.toString
+ // Consider preserving the date type instead of converting to string
+ ColumnTypeDate(length.max(ColumnTypeDate.defaultLength))
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
case (ColumnTypeBoolean, ColumnTypeDate(length)) => | |
// change Date -> String | |
ColumnTypeString(length.max(5)) // 5 = false.toString | |
case (ColumnTypeBoolean, ColumnTypeDate(length)) => | |
// change Date -> String | |
// Consider preserving the date type instead of converting to string | |
ColumnTypeDate(length.max(ColumnTypeDate.defaultLength)) |
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Tests