Repository navigation
Postgres Create(...)` fix on identity columns, - #879
Merged
Merged
Conversation
group-by fix on IsSome/IsNone
There was a problem hiding this comment.
🟡 Changes recommended
Single-table tuple grouping with two computed keys produces duplicate column names in PostgreSQL and SQL Server, causing one value to be overwritten and preventing reconstruction of the group-key tuple.
1 open issue
What changed in this PR
This PR fixes SQLProvider’s nested-query parameter binding, optional group-key handling, and PostgreSQL identity-column detection. It also expands guidance on querying, creating entities, and testing with mock contexts.
Changes:
- Clone and rename nested-query parameters without modifying shared parameter objects.
- Support optional and computed group keys, with regression tests.
- Exclude PostgreSQL identity columns from typed
Create(...)arguments and document the compatibility impact.
| File | Description |
|---|---|
| tests/SqlProvider.Tests/SqlProvider.Tests.fsproj | Registers PostgreSQL schema tests. |
| tests/SqlProvider.Tests/QueryTests.fs | Tests optional and computed group keys. |
| tests/SqlProvider.Tests/PostgreSqlSchemaTests.fs | Tests identity-column metadata against PostgreSQL. |
| tests/SqlProvider.Tests/more/SubqueryCompositionTests.fs | Tests parameter binding across nested subqueries. |
| src/SQLProvider.Runtime/Providers.Postgresql.fs | Recognizes identity columns as autogenerated. |
| src/SQLProvider.Common/Utils.fs | Preserves optional types during value conversion. |
| src/SQLProvider.Common/SqlRuntime.Linq.fs | Updates parameter renaming and tuple group-key translation. |
| docs/RELEASE_NOTES.md | Records fixes and identity-column compatibility guidance. |
| docs/content/index.fsx | Clarifies query example comments. |
| docs/content/core/unittest.fsx | Expands mock-context setup and usage guidance. |
| docs/content/core/querying.fsx | Adds query-style guidance and focused projections. |
| docs/content/core/general.fsx | Links to recommended query practices. |
| docs/content/core/crud.fsx | Documents typed creation and updates without prior reads. |
| docs/content/core/composable.fsx | Clarifies nested-query syntax and mock compatibility. |
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
Computed group-key aliases can collide with ordinary column names, breaking tuple-key reconstruction, and the assembly-wide SQL check incorrectly fails tests that emit no SQL events.
3 open issues
1 resolved since last review
Review effort: Balanced
| /// `plain`, the provider's usual entry. | ||
| let groupKeyColumn (keys:(alias*SqlColumnType) list) (index:int) (column:SqlColumnType) (notation:string) (plain:string) = | ||
| match column with | ||
| | CanonicalOperation _ when keys.Length > 1 -> sprintf "%s as key%i" notation index |
| cmd.CommandText <- sql | ||
| cmd.ExecuteNonQuery() |> ignore | ||
|
|
||
| [<Test>] |
Comment on lines
+87
to
+89
| if not noSql then | ||
| if commands.IsEmpty then | ||
| Assert.Fail "The test sent no SQL: its query ran in memory. Mark it [<NoSql>] if that is meant." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


group-by fix on IsSome/IsNone
Proposed Changes
Create(...)no longer takes them. Breaking for code that passed a value to a BY DEFAULT identity column: use Create() and set it, or Create(data). A saved ContextSchemaPath cache keeps the old signature until regenerated.