Skip to content

feat(core-base/database): add ForeignKeyAction and ColumnInfo constants#124

Merged
niyajali merged 2 commits intoopenMF:devfrom
amanna13:fix/core-base
Feb 18, 2026
Merged

feat(core-base/database): add ForeignKeyAction and ColumnInfo constants#124
niyajali merged 2 commits intoopenMF:devfrom
amanna13:fix/core-base

Conversation

@amanna13
Copy link
Member

@amanna13 amanna13 commented Feb 18, 2026

Screenshots

Desktop

desktop.mp4

web-js

web-js.mp4

web-wasm

web-wasm.mp4

Summary by CodeRabbit

  • New Features
    • Added foreign key action constants (NO_ACTION, RESTRICT, SET_NULL, SET_DEFAULT, CASCADE) for database operations.
    • Added new column info type affinity constants for enhanced database configuration options.

@coderabbitai
Copy link

coderabbitai bot commented Feb 18, 2026

📝 Walkthrough

Walkthrough

Extended the Room database API with foreign key action constants and column information type hints. Added ForeignKeyAction object with standard foreign key behaviors (NO_ACTION, RESTRICT, SET_NULL, SET_DEFAULT, CASCADE) and two new constants to ColumnInfoTypeAffinity. Updated type alias mappings to use local implementations instead of androidx.room dependencies.

Changes

Cohort / File(s) Summary
Room API Extensions
core-base/database/src/commonMain/kotlin/template/core/base/database/Room.kt
Added two public constants (INHERIT_FIELD_NAME, VALUE_UNSPECIFIED) to ColumnInfoTypeAffinity object and introduced new ForeignKeyAction object with five integer constants for cross-platform foreign key constraint behaviors.
Type Alias Updates
core-base/database/src/nonJsCommonMain/kotlin/template/core/base/database/Room.nonJsCommon.kt
Updated BuiltInTypeConverters and AutoMigration type aliases to map to local implementations instead of androidx.room classes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Poem

🐰 Constants hop into the fold,
Foreign keys with actions bold,
NO_ACTION, CASCADE in array,
Type aliases mapped the new way! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately describes the main changes: adding ForeignKeyAction object and ColumnInfo constants (INHERIT_FIELD_NAME and VALUE_UNSPECIFIED) to the core-base/database module.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/core-base

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@amanna13 amanna13 marked this pull request as ready for review February 18, 2026 14:11
@amanna13
Copy link
Member Author

@coderabbitai suggest a better PR title for the changes

@coderabbitai
Copy link

coderabbitai bot commented Feb 18, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Get the list of files changed in this PR
gh pr view 124 --json files --jq '.files[].path'

Length of output: 170


🏁 Script executed:

#!/bin/bash
# Get the diff for this PR to understand what changes were made
gh pr diff 124

Length of output: 3116


@amanna13 Based on the changes in this PR, I suggest the following alternative titles:

Recommended:

feat(core-base/database): add ForeignKeyAction and ColumnInfo constants

Alternative options:

feat(core-base/database): add foreign key action and column info constants
feat(core-base/database): add cross-platform Room database constants

The current title "updated Room annotations" is too vague. The PR actually:

  • Adds a new ForeignKeyAction object with 5 constants (NO_ACTION, RESTRICT, SET_NULL, SET_DEFAULT, CASCADE)
  • Adds 2 new constants to ColumnInfoTypeAffinity (INHERIT_FIELD_NAME, VALUE_UNSPECIFIED)
  • Includes minor import cleanup

The recommended title more accurately describes what was added to the codebase.

@amanna13 amanna13 changed the title feat(core-base/database): updated Room annotations feat(core-base/database): add ForeignKeyAction and ColumnInfo constants Feb 18, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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 | 🟡 Minor

KDoc example still references ForeignKey.CASCADE — now inconsistent with the new ForeignKeyAction object.

The example at line 123 uses onDelete = ForeignKey.CASCADE. With the ForeignKeyAction object introduced in this PR, the idiomatic cross-platform usage is onDelete = 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_NAME and VALUE_UNSPECIFIED are semantically misplaced in ColumnInfoTypeAffinity.

ColumnInfoTypeAffinity holds Int constants that map to SQLite storage-class hints (UNDEFINED, TEXT, INTEGER, REAL, BLOB). In AndroidX Room's ColumnInfo companion, INHERIT_FIELD_NAME and VALUE_UNSPECIFIED are String sentinel values for the name and defaultValue parameters of @ColumnInfo — an entirely different concern from type affinity.

Mixing String column-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 inside ColumnInfoTypeAffinity, and a reader seeing the object will be surprised to find String members alongside the Int affinities.

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.

@niyajali
Copy link
Collaborator

@amanna13 upload screenshots or a video of all the platforms

@amanna13
Copy link
Member Author

amanna13 commented Feb 18, 2026

@niyajali Updated the description with the screenshots.
I can't take screenshot of the Android app it says - " This app doesn't allow screenshots"

Hence took a photo insted from another phone. It builds fine.

@niyajali
Copy link
Collaborator

Upload videos of all the platforms

@amanna13
Copy link
Member Author

@niyajali i don't have an iOS device with me. Other than that I have updated the videos.
For Android - screenshot/screen recording is showing as disabled

@niyajali niyajali merged commit c68c5ae into openMF:dev Feb 18, 2026
8 checks passed
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.

2 participants