Skip to content

change segment disctance sql type#842

Merged
EtienneLt merged 3 commits into
mainfrom
change-segment-distance-sql-type
Jul 2, 2026
Merged

change segment disctance sql type#842
EtienneLt merged 3 commits into
mainfrom
change-segment-distance-sql-type

Conversation

@EtienneLt

Copy link
Copy Markdown
Contributor

PR Summary

Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
@EtienneLt EtienneLt self-assigned this Jul 1, 2026
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@EtienneLt, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7aaf751e-4880-44b1-aa14-19fcf447da44

📥 Commits

Reviewing files that changed from the base of the PR and between 4c625b8 and ed281ec.

📒 Files selected for processing (4)
  • src/test/java/org/gridsuite/modification/server/modifications/LineCreationInBusBreakerTest.java
  • src/test/java/org/gridsuite/modification/server/modifications/LineCreationInMixedTypologyTest.java
  • src/test/java/org/gridsuite/modification/server/modifications/LineCreationInNodeBreakerTest.java
  • src/test/java/org/gridsuite/modification/server/modifications/LineModificationTest.java
📝 Walkthrough

Walkthrough

Updated the network-modification.version Maven property, changed LineSegmentEntity.segmentDistanceValue from Integer to Double, and added a Liquibase changeset altering segment_distance_value to FLOAT8 in the line_segments table, registered in the master changelog.

Changes

Segment Distance Type Migration

Layer / File(s) Summary
Entity type update and DB migration
src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineSegmentEntity.java, src/main/resources/db/changelog/changesets/changelog_20260701T113605Z.xml, src/main/resources/db/changelog/db.changelog-master.yaml
segmentDistanceValue field type changes from Integer to Double, with a new Liquibase changeset altering segment_distance_value to FLOAT8 and registering it in the master changelog.
Dependency version bump
pom.xml
network-modification.version property updated from 1.0.0 to 1.1.0.

Suggested reviewers: etiennehomer, flomillot

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description is only a template prompt and gives no substantive details about the change. Replace the template text with a brief summary of the actual changes, including the type update and any reviewer notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: updating the segment distance SQL type.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

Comment thread pom.xml Outdated
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/resources/db/changelog/changesets/changelog_20260701T113605Z.xml (1)

3-7: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Consider adding explicit rollback for this modifyDataType changeset.

modifyDataType is one of the Liquibase change types that does not support automatic rollback generation, per Liquibase docs. INT → FLOAT8 is a safe widening conversion for existing data, but without a <rollback> block, liquibase rollback will fail for this changeset if ever needed.

♻️ Suggested addition
     <changeSet author="lesoteti" id="1782905794769-2">
         <modifyDataType  columnName="segment_distance_value"
                          newDataType="FLOAT8"
                          tableName="line_segments"/>
+        <rollback>
+            <modifyDataType columnName="segment_distance_value"
+                             newDataType="INT"
+                             tableName="line_segments"/>
+        </rollback>
     </changeSet>

Confirm whether this repository's Liquibase workflow relies on rollback support before deciding if this is necessary.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/resources/db/changelog/changesets/changelog_20260701T113605Z.xml`
around lines 3 - 7, The `modifyDataType` changeset for
`line_segments.segment_distance_value` has no explicit rollback, so Liquibase
cannot reverse it reliably. In the same changeset, add a rollback block for the
`modifyDataType` change in `changelog_20260701T113605Z.xml` using the existing
`changeSet` identifier, and choose the prior column type that matches the
pre-change schema. If this repository does not require rollback support, confirm
that explicitly; otherwise keep the rollback alongside this changeSet.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineSegmentEntity.java`:
- Around line 38-39: The `segmentDistanceValue` type is inconsistent between
`LineSegmentEntity` and `LineSegmentInfos`, and both conversion paths currently
pass it through unchanged. Align the types on one side so the entity and DTO
match, then verify the mapping methods that convert between `LineSegmentEntity`
and `LineSegmentInfos` still compile and preserve the value correctly.

---

Nitpick comments:
In `@src/main/resources/db/changelog/changesets/changelog_20260701T113605Z.xml`:
- Around line 3-7: The `modifyDataType` changeset for
`line_segments.segment_distance_value` has no explicit rollback, so Liquibase
cannot reverse it reliably. In the same changeset, add a rollback block for the
`modifyDataType` change in `changelog_20260701T113605Z.xml` using the existing
`changeSet` identifier, and choose the prior column type that matches the
pre-change schema. If this repository does not require rollback support, confirm
that explicitly; otherwise keep the rollback alongside this changeSet.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: becdad1e-88e3-439b-822a-b9d3af6d3799

📥 Commits

Reviewing files that changed from the base of the PR and between 767fc17 and 4c625b8.

📒 Files selected for processing (4)
  • pom.xml
  • src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineSegmentEntity.java
  • src/main/resources/db/changelog/changesets/changelog_20260701T113605Z.xml
  • src/main/resources/db/changelog/db.changelog-master.yaml

Comment on lines 38 to +39
@Column(name = "segment_distance_value")
private Integer segmentDistanceValue;
private Double segmentDistanceValue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Inspect the LineSegmentInfos DTO shipped in the resolved dependency version, and check for any remaining int-literal usages of segmentDistanceValue in this repo.
fd -e jar network-modification | xargs -I{} sh -c 'echo {}; unzip -p {} org/gridsuite/modification/dto/LineSegmentInfos.class 2>/dev/null | javap - 2>/dev/null || true'
rg -n 'new LineSegmentInfos\(' -A1

Repository: gridsuite/network-modification-server

Length of output: 175


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== pom version ==\n'
rg -n 'network-modification\.version|gridsuite-network-modification' pom.xml

printf '\n== relevant files ==\n'
git ls-files 'src/main/java/**/LineSegmentEntity.java' 'src/main/java/**/LineCreationEntity.java' 'src/test/java/**/LineModificationTest.java'

printf '\n== outlines ==\n'
ast-grep outline src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineSegmentEntity.java --view expanded || true
ast-grep outline src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java --view expanded || true

printf '\n== usages ==\n'
rg -n 'LineSegmentInfos|segmentDistanceValue|new LineSegmentInfos\(' src/main/java src/test/java

Repository: gridsuite/network-modification-server

Length of output: 5786


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the exact files and inspect the relevant ranges only.
printf '== files ==\n'
fd 'LineSegmentEntity.java|LineCreationEntity.java|LineModificationTest.java|pom.xml' .

printf '\n== LineSegmentEntity.java ==\n'
sed -n '1,220p' src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineSegmentEntity.java

printf '\n== LineCreationEntity.java ==\n'
sed -n '1,240p' src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java

printf '\n== LineModificationTest.java usages ==\n'
rg -n 'new LineSegmentInfos\(|segmentDistanceValue' src/test/java src/main/java

printf '\n== pom.xml version pin ==\n'
rg -n 'network-modification\.version|gridsuite-network-modification' pom.xml

Repository: gridsuite/network-modification-server

Length of output: 10957


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== repo hits =='
rg -n 'LineSegmentInfos|segmentDistanceValue' src/main/java src/test/java

echo
echo '== line entity and creation entity =='
sed -n '1,220p' src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineSegmentEntity.java
printf '\n---\n'
sed -n '1,260p' src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java

echo
echo '== javac conversion probe =='
tmpdir="$(mktemp -d)"
cat >"$tmpdir/Probe.java" <<'JAVA'
class Probe {
  static final class X {
    X(Double d) {}
    X(Integer i) {}
  }
  static void f() {
    new X(1);
  }
}
JAVA
if javac "$tmpdir/Probe.java" 2>"$tmpdir/err"; then
  echo "compiled"
else
  cat "$tmpdir/err"
fi
rm -rf "$tmpdir"

Repository: gridsuite/network-modification-server

Length of output: 12028


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '== local m2 artifacts ==\n'
fd -a 'gridsuite-network-modification*' "$HOME/.m2/repository" 2>/dev/null | head -n 50

printf '\n== candidate class files ==\n'
fd -a 'LineSegmentInfos.class|LineSegmentInfos.java' "$HOME/.m2/repository" 2>/dev/null | head -n 50

printf '\n== candidate jars ==\n'
fd -a 'gridsuite-network-modification-1.1.0.jar|gridsuite-network-modification-1.1.0-sources.jar' "$HOME/.m2/repository" 2>/dev/null | head -n 50

Repository: gridsuite/network-modification-server

Length of output: 200


🏁 Script executed:

#!/bin/bash
set -euo pipefail

tmpdir="$(mktemp -d)"
cat >"$tmpdir/Probe.java" <<'JAVA'
class Probe {
  static final class X {
    X(Double d) {}
  }
  static void f() {
    new X(1);
  }
}
JAVA

if javac "$tmpdir/Probe.java" 2>"$tmpdir/err"; then
  echo "compiled"
else
  cat "$tmpdir/err"
fi

rm -rf "$tmpdir"

Repository: gridsuite/network-modification-server

Length of output: 396


🌐 Web query:

"gridsuite-network-modification 1.1.0 LineSegmentInfos segmentDistanceValue"

💡 Result:

In the gridsuite-network-modification library, LineSegmentInfos is a Java record introduced in version 0.75.0 to manage line segment information, which is used to generate operational limits from a catalog [1]. The segmentDistanceValue is an Integer field within this record [1]. The record is defined as follows: public record LineSegmentInfos(String segmentTypeId, Integer segmentDistanceValue, String area, String temperature, Double shapeFactor) { } This structure was added to the library as part of pull request #172 in April 2026 [1]. Subsequently, in version 0.76.0, support for these line segments was integrated into the LineModificationInfos class to allow modifications involving these segments [2][3]. There is no "version 1.1.0" documented in the available repository history as of July 2026; the library reached version 0.78.0 by that time [4]. It is likely that the version number referenced in your query is either a misunderstanding or refers to a different context. The implementation details provided above are based on the actual codebase evolution of the gridsuite-network-modification library [1][3].

Citations:


🌐 Web query:

"site:github.com/gridsuite/network-modification LineSegmentInfos record Integer Double segmentDistanceValue"

💡 Result:

The LineSegmentInfos class in the gridsuite/network-modification repository is a Java record defined in the package org.gridsuite.modification.dto [1]. It includes an Integer field named segmentDistanceValue [1]. The full definition of the record is as follows [1]: public record LineSegmentInfos(String segmentTypeId, Integer segmentDistanceValue, String area, String temperature, Double shapeFactor) { } This record was introduced in version v0.76.0 (via pull request #175) to support line modification functionality by defining segment information used from the catalog [1][2][3]. The segmentDistanceValue field is one of several properties, alongside segmentTypeId, area, temperature, and shapeFactor [1].

Citations:


Align segmentDistanceValue with LineSegmentInfos. LineSegmentInfos.segmentDistanceValue is still Integer, while this entity uses Double; both conversion methods pass the value through unchanged, so the entity/DTO pair is type-incompatible. Update one side to match the other before merging.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineSegmentEntity.java`
around lines 38 - 39, The `segmentDistanceValue` type is inconsistent between
`LineSegmentEntity` and `LineSegmentInfos`, and both conversion paths currently
pass it through unchanged. Align the types on one side so the entity and DTO
match, then verify the mapping methods that convert between `LineSegmentEntity`
and `LineSegmentInfos` still compile and preserve the value correctly.

Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
@sonarqubecloud

sonarqubecloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

@EtienneLt EtienneLt merged commit 3bffb36 into main Jul 2, 2026
4 checks passed
@EtienneLt EtienneLt deleted the change-segment-distance-sql-type branch July 2, 2026 07:22
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