feat(core-base/database): add ForeignKeyAction and ColumnInfo constants#124
feat(core-base/database): add ForeignKeyAction and ColumnInfo constants#124niyajali merged 2 commits intoopenMF:devfrom
Conversation
📝 WalkthroughWalkthroughExtended the Room database API with foreign key action constants and column information type hints. Added Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai suggest a better PR title for the changes |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 170 🏁 Script executed: Length of output: 3116
Recommended: Alternative options: The current title "updated Room annotations" is too vague. The PR actually:
The recommended title more accurately describes what was added to the codebase. |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
core-base/database/src/commonMain/kotlin/template/core/base/database/Room.kt (1)
113-130:⚠️ Potential issue | 🟡 MinorKDoc example still references
ForeignKey.CASCADE— now inconsistent with the newForeignKeyActionobject.The example at line 123 uses
onDelete = ForeignKey.CASCADE. With theForeignKeyActionobject introduced in this PR, the idiomatic cross-platform usage isonDelete = ForeignKeyAction.CASCADE. The stale reference will mislead readers.📝 Suggested KDoc fix
- * onDelete = ForeignKey.CASCADE + * onDelete = ForeignKeyAction.CASCADE🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@core-base/database/src/commonMain/kotlin/template/core/base/database/Room.kt` around lines 113 - 130, Update the KDoc example to use the new cross-platform API: replace the stale reference to ForeignKey.CASCADE with ForeignKeyAction.CASCADE in the onDelete (and any onUpdate) usages so the example matches the introduced ForeignKeyAction object; locate the example in the Room KDoc block around the Post entity and adjust the example lines to use onDelete = ForeignKeyAction.CASCADE (and onUpdate = ForeignKeyAction.CASCADE if present).
🧹 Nitpick comments (1)
core-base/database/src/commonMain/kotlin/template/core/base/database/Room.kt (1)
767-772:INHERIT_FIELD_NAMEandVALUE_UNSPECIFIEDare semantically misplaced inColumnInfoTypeAffinity.
ColumnInfoTypeAffinityholdsIntconstants that map to SQLite storage-class hints (UNDEFINED,TEXT,INTEGER,REAL,BLOB). In AndroidX Room'sColumnInfocompanion,INHERIT_FIELD_NAMEandVALUE_UNSPECIFIEDareStringsentinel values for thenameanddefaultValueparameters of@ColumnInfo— an entirely different concern from type affinity.Mixing
Stringcolumn-name/default-value sentinels into a type-affinity constants object breaks the single-responsibility principle: callers looking for the "inherit field name" sentinel will not naturally look insideColumnInfoTypeAffinity, and a reader seeing the object will be surprised to findStringmembers alongside theIntaffinities.Consider extracting these into a dedicated holder:
♻️ Proposed refactor — separate ColumnInfo sentinel values
object ColumnInfoTypeAffinity { const val UNDEFINED = 1 const val TEXT = 2 const val INTEGER = 3 const val REAL = 4 const val BLOB = 5 - - /** Indicates that the column name should be inherited from the field name */ - const val INHERIT_FIELD_NAME: String = "[field-name]" - - /** Indicates that no default value is specified for the column */ - const val VALUE_UNSPECIFIED: String = "[value-unspecified]" } + +/** + * Sentinel string constants for [ColumnInfo] name and defaultValue parameters. + */ +object ColumnInfoDefaults { + /** Inherits the column name from the field name (mirrors ColumnInfo.INHERIT_FIELD_NAME). */ + const val INHERIT_FIELD_NAME: String = "[field-name]" + + /** Indicates no default value is specified (mirrors ColumnInfo.VALUE_UNSPECIFIED). */ + const val VALUE_UNSPECIFIED: String = "[value-unspecified]" +}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@core-base/database/src/commonMain/kotlin/template/core/base/database/Room.kt` around lines 767 - 772, The two String sentinels INHERIT_FIELD_NAME and VALUE_UNSPECIFIED are misplaced inside ColumnInfoTypeAffinity (which holds Int affinity constants); extract these two constants into a dedicated holder aligned with ColumnInfo semantics — e.g., create a ColumnInfoSentinels (or add them to ColumnInfo companion) and move INHERIT_FIELD_NAME and VALUE_UNSPECIFIED there, update all references to use the new holder, and remove the two String constants from ColumnInfoTypeAffinity to keep affinity constants strictly Int-only.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In
`@core-base/database/src/commonMain/kotlin/template/core/base/database/Room.kt`:
- Around line 113-130: Update the KDoc example to use the new cross-platform
API: replace the stale reference to ForeignKey.CASCADE with
ForeignKeyAction.CASCADE in the onDelete (and any onUpdate) usages so the
example matches the introduced ForeignKeyAction object; locate the example in
the Room KDoc block around the Post entity and adjust the example lines to use
onDelete = ForeignKeyAction.CASCADE (and onUpdate = ForeignKeyAction.CASCADE if
present).
---
Nitpick comments:
In
`@core-base/database/src/commonMain/kotlin/template/core/base/database/Room.kt`:
- Around line 767-772: The two String sentinels INHERIT_FIELD_NAME and
VALUE_UNSPECIFIED are misplaced inside ColumnInfoTypeAffinity (which holds Int
affinity constants); extract these two constants into a dedicated holder aligned
with ColumnInfo semantics — e.g., create a ColumnInfoSentinels (or add them to
ColumnInfo companion) and move INHERIT_FIELD_NAME and VALUE_UNSPECIFIED there,
update all references to use the new holder, and remove the two String constants
from ColumnInfoTypeAffinity to keep affinity constants strictly Int-only.
|
@amanna13 upload screenshots or a video of all the platforms |
|
@niyajali Updated the description with the screenshots. Hence took a photo insted from another phone. It builds fine.
|
|
Upload videos of all the platforms |
|
@niyajali i don't have an iOS device with me. Other than that I have updated the videos. |

Screenshots
Desktop
desktop.mp4
web-js
web-js.mp4
web-wasm
web-wasm.mp4
Summary by CodeRabbit