Skip to content

Case handling, datetime handling and geometry updates - #123

Open
Milo-Dias wants to merge 3 commits into
DHI:mainfrom
Milo-Dias:main
Open

Case handling, datetime handling and geometry updates#123
Milo-Dias wants to merge 3 commits into
DHI:mainfrom
Milo-Dias:main

Conversation

@Milo-Dias

@Milo-Dias Milo-Dias commented Jul 15, 2026

Copy link
Copy Markdown

Problem

  • Numeric-looking strings such as "760309" (assetname) and "33,34" (dem_location) were incorrectly interpreted as dates.
  • Insert field names became case-sensitive. Issue: Case sensitivity for the insert method #119.
  • Geometry updates were sent through the ordinary field-update command and were not saved correctly.

Fix

  • dotnet.py: Text values now stay as text unless the destination field is actually a date field.
  • queries.py: Insert field names now work regardless of capitalization—for example, both "Description" and "description" are accepted.
  • queries.py: Geometries now use the correct MIKE+ geometry update operation.
  • queries.py: Apply geometry through UpdateGeomByCommand and raise an explicit error when it does not commit.

dotnet.py: Keep strings unchanged during .NET conversion.
queries.py: Parse strings only for schema-declared DateTime fields.
queries.py: Restore case-insensitive field names for inserts.
queries.py: Send geometry updates through UpdateGeomByCommand and raise an error if they fail.
@ryan-kipawa
ryan-kipawa self-requested a review July 16, 2026 18:12

@ryan-kipawa ryan-kipawa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Great work! I have some feedback that we could iterate on:

  1. Add failing tests for all of the fixes. These are new/modified tests that fail on the main branch, but then pass with the fixes of this PR.
  2. For case-sensitivity: this may be an issue limited to postgres rather than sqlite. Pinpointing the issue slightly could reveal a solution that's easier to maintain. I partly wonder if this could be handled upstream by MIKE+.
  3. The dotnet.py module is intended for code related to Python <--> .NET type conversions. I think the datetime parsing logic should go there - this may require extending it to be aware of the column's data type.

@Milo-Dias

Copy link
Copy Markdown
Author

Great work! I have some feedback that we could iterate on:

1. Add failing tests for all of the fixes. These are new/modified tests that fail on the main branch, but then pass with the fixes of this PR.

2. For case-sensitivity: this may be an issue limited to postgres rather than sqlite. Pinpointing the issue slightly could reveal a solution that's easier to maintain. I partly wonder if this could be handled upstream by MIKE+.

3. The `dotnet.py` module is intended for code related to Python <--> .NET type conversions.  I think the datetime parsing logic should go there - this may require extending it to be aware of the column's data type.

Thank you so much for your feedback Ryan and for your time invested into it, I agree with your three points :)

I will add regression tests covering all that I have touched.

The original case-sensitivity failure was reproduced with an SQLite MIKE+ model, so I will test it out and document it. And investigate whether InsertByCommand should be corrected upstream in MIKE+ or not.

I will also move datetime parsing back into dotnet.py

I will keep you updated,
Thanks :)

@Milo-Dias
Milo-Dias requested a review from ryan-kipawa July 16, 2026 19:02
MILA added 2 commits July 22, 2026 12:27
Refs DHI#123

- Preserve arbitrary strings such as "760309" and "33,34" instead of interpreting them as dates.
- Parse strings as DateTime only when the destination MIKE+ field is schema-declared as DbType.DateTime.
- Restore case-insensitive insert field names by mapping them to canonical schema names.
- Send geometry updates through UpdateGeomByCommand and raise an error when the command does not commit.
- Add eight regression tests covering conversion, SQLite inserts, geometry persistence, command routing, and failed commits.

All eight tests fail against upstream main (fc2836c) and pass with these fixes.
Addresses DHI#119.

Please try it out and give feedback :)
Thank you so much for your time,

mila
Problem:
Numeric strings were interpreted according to the computer’s regional
settings. A value such as "1,2" could insert as NULL or cause an update
failure on a dot-decimal computer, with the reverse risk for "1.2" on
comma-decimal computers.

Fix:
Convert strings for schema-declared DbType.Double fields using either
"." or "," before sending them to MIKE+. Invalid strings remain unchanged.

Tests:
Added converter tests and Sirius insert/update regression tests for
both decimal separators.
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