Skip to content

Commit aad8b47

Browse files
authored
Merge pull request #70 from aaronpowell/issue-69
Fix ID lookup bug
2 parents 8b63349 + 871e0b7 commit aad8b47

4 files changed

Lines changed: 22 additions & 12 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
runs-on: windows-latest
1818
steps:
1919
- name: Checkout
20-
uses: actions/checkout@v2
20+
uses: actions/checkout@v3
2121

2222
- name: Setup Dotnet ${{ env.DOTNET_VERSION }}
23-
uses: actions/setup-dotnet@v1
23+
uses: actions/setup-dotnet@v3
2424
with:
2525
dotnet-version: ${{ env.DOTNET_VERSION }}
2626

@@ -31,7 +31,7 @@ jobs:
3131
run: dotnet fake run ./build.fsx --target CI
3232

3333
- name: Publish release packages
34-
uses: actions/upload-artifact@v1
34+
uses: actions/upload-artifact@v3
3535
with:
3636
name: packages
3737
path: ${{ env.OUTPUT_PATH }}
@@ -41,13 +41,13 @@ jobs:
4141
runs-on: ubuntu-latest
4242

4343
steps:
44-
- uses: actions/download-artifact@v2
44+
- uses: actions/download-artifact@v3
4545
with:
4646
name: packages
4747
path: ${{ env.OUTPUT_PATH }}
4848

4949
- name: Setup .NET Core ${{ env.DOTNET_VERSION }}
50-
uses: actions/setup-dotnet@v1
50+
uses: actions/setup-dotnet@v3
5151
with:
5252
dotnet-version: ${{ env.DOTNET_VERSION }}
5353

.github/workflows/release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
runs-on: windows-latest
1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@v3
1919

2020
- name: Setup Dotnet ${{ env.DOTNET_VERSION }}
21-
uses: actions/setup-dotnet@v1
21+
uses: actions/setup-dotnet@v3
2222
with:
2323
dotnet-version: ${{ env.DOTNET_VERSION }}
2424

@@ -54,7 +54,7 @@ jobs:
5454
body_path: ${{ env.OUTPUT_PATH }}/changelog.md
5555
- run: echo ${{ steps.create_release.outputs.id }} >> release.txt
5656
- name: Upload release_id
57-
uses: actions/upload-artifact@v2
57+
uses: actions/upload-artifact@v3
5858
with:
5959
name: release_id
6060
path: release.txt
@@ -107,7 +107,7 @@ jobs:
107107

108108
steps:
109109
- name: Download package
110-
uses: actions/download-artifact@v2
110+
uses: actions/download-artifact@v3
111111
with:
112112
name: release_id
113113
- run: echo "release_id=$(cat release.txt)" >> $GITHUB_ENV
@@ -128,7 +128,7 @@ jobs:
128128
runs-on: ubuntu-latest
129129

130130
steps:
131-
- uses: actions/download-artifact@v2
131+
- uses: actions/download-artifact@v3
132132
with:
133133
name: packages
134134
path: ${{ env.OUTPUT_PATH }}
@@ -151,7 +151,7 @@ jobs:
151151
runs-on: ubuntu-latest
152152

153153
steps:
154-
- uses: actions/download-artifact@v2
154+
- uses: actions/download-artifact@v3
155155
with:
156156
name: packages
157157
path: ${{ env.OUTPUT_PATH }}

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog for `FSharp.CosmosDb`
22

3+
## [1.2.1] - Unreleased
4+
5+
### Fixes
6+
7+
- Fixing #69 by finding a property using conventions first, before raising an error
8+
39
## [1.2.0] - 2022-08-22
410

511
### Added

src/FSharp.CosmosDb/OperationHandling.fs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ let getIdFieldName<'T> (item: 'T) =
1111

1212
match idAttr with
1313
| Some attr -> attr.GetValue(item).ToString()
14-
| None -> "id"
14+
| None ->
15+
let property = item.GetType().GetProperties() |> Array.tryFind(fun p -> p.Name.Equals("id", StringComparison.InvariantCultureIgnoreCase))
16+
match property with
17+
| Some property -> property.GetValue(item).ToString()
18+
| None -> failwith "Unable to determine the id field of the type. Either use the IdAttribute or have a field named Id"
1519

1620
let getPartitionKeyValue<'T> (single: 'T) =
1721
let partitionKey = PartitionKeyAttributeTools.findPartitionKey<'T> ()

0 commit comments

Comments
 (0)