From 870f87cb17e59ebd0e1c92d5e8ef5ec0f21fb9c2 Mon Sep 17 00:00:00 2001 From: "Daniel J. Summers" Date: Wed, 18 Sep 2024 19:54:45 -0400 Subject: [PATCH] Update for v4-rc5 of doc library --- src/MyWebLog.Data/MyWebLog.Data.fsproj | 4 ++-- src/MyWebLog.Data/Postgres/PostgresCategoryData.fs | 1 - src/MyWebLog.Data/Postgres/PostgresPageData.fs | 3 +-- src/MyWebLog.Data/Postgres/PostgresPostData.fs | 5 ++--- src/MyWebLog.Data/Postgres/PostgresTagMapData.fs | 3 +-- src/MyWebLog.Data/Postgres/PostgresWebLogUserData.fs | 2 +- src/MyWebLog.Data/SQLite/SQLiteCategoryData.fs | 8 +++----- src/MyWebLog.Data/SQLite/SQLitePageData.fs | 2 +- src/MyWebLog.Data/SQLite/SQLitePostData.fs | 4 ++-- src/MyWebLog.Data/SQLite/SQLiteTagMapData.fs | 3 +-- src/MyWebLog.Data/SQLite/SQLiteWebLogUserData.fs | 2 +- 11 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/MyWebLog.Data/MyWebLog.Data.fsproj b/src/MyWebLog.Data/MyWebLog.Data.fsproj index c6b77a0..43f2e0c 100644 --- a/src/MyWebLog.Data/MyWebLog.Data.fsproj +++ b/src/MyWebLog.Data/MyWebLog.Data.fsproj @@ -5,8 +5,8 @@ - - + + diff --git a/src/MyWebLog.Data/Postgres/PostgresCategoryData.fs b/src/MyWebLog.Data/Postgres/PostgresCategoryData.fs index d991c42..3820783 100644 --- a/src/MyWebLog.Data/Postgres/PostgresCategoryData.fs +++ b/src/MyWebLog.Data/Postgres/PostgresCategoryData.fs @@ -43,7 +43,6 @@ type PostgresCategoryData(log: ILogger) = |> Seq.filter (fun cat -> cat.ParentNames |> Array.contains it.Name) |> Seq.map _.Id |> Seq.append (Seq.singleton it.Id) - |> Seq.map box |> Field.InArray (nameof Post.Empty.CategoryIds) Table.Post let query = (Query.statementWhere diff --git a/src/MyWebLog.Data/Postgres/PostgresPageData.fs b/src/MyWebLog.Data/Postgres/PostgresPageData.fs index 2c8b113..e96e4d4 100644 --- a/src/MyWebLog.Data/Postgres/PostgresPageData.fs +++ b/src/MyWebLog.Data/Postgres/PostgresPageData.fs @@ -111,8 +111,7 @@ type PostgresPageData(log: ILogger) = log.LogTrace "Page.findCurrentPermalink" if List.isEmpty permalinks then return None else - let linkField = - Field.InArray (nameof Page.Empty.PriorPermalinks) Table.Page (List.map (string >> box) permalinks) + let linkField = Field.InArray (nameof Page.Empty.PriorPermalinks) Table.Page (List.map string permalinks) let query = (Query.statementWhere (Query.find Table.Page) diff --git a/src/MyWebLog.Data/Postgres/PostgresPostData.fs b/src/MyWebLog.Data/Postgres/PostgresPostData.fs index 9360cb2..4a7af1f 100644 --- a/src/MyWebLog.Data/Postgres/PostgresPostData.fs +++ b/src/MyWebLog.Data/Postgres/PostgresPostData.fs @@ -97,8 +97,7 @@ type PostgresPostData(log: ILogger) = log.LogTrace "Post.findCurrentPermalink" if List.isEmpty permalinks then return None else - let linkField = - Field.InArray (nameof Post.Empty.PriorPermalinks) Table.Post (List.map (string >> box) permalinks) + let linkField = Field.InArray (nameof Post.Empty.PriorPermalinks) Table.Post (List.map string permalinks) let query = (Query.statementWhere (Query.find Table.Post) @@ -121,7 +120,7 @@ type PostgresPostData(log: ILogger) = /// Get a page of categorized posts for the given web log (excludes revisions) let findPageOfCategorizedPosts webLogId (categoryIds: CategoryId list) pageNbr postsPerPage = log.LogTrace "Post.findPageOfCategorizedPosts" - let catIdField = Field.InArray (nameof Post.Empty.CategoryIds) Table.Post (List.map (string >> box) categoryIds) + let catIdField = Field.InArray (nameof Post.Empty.CategoryIds) Table.Post (List.map string categoryIds) Custom.list $"""{selectWithCriteria Table.Post} AND {Query.whereByFields All [ catIdField ]} diff --git a/src/MyWebLog.Data/Postgres/PostgresTagMapData.fs b/src/MyWebLog.Data/Postgres/PostgresTagMapData.fs index e74c66c..8d46d08 100644 --- a/src/MyWebLog.Data/Postgres/PostgresTagMapData.fs +++ b/src/MyWebLog.Data/Postgres/PostgresTagMapData.fs @@ -6,7 +6,6 @@ open Microsoft.Extensions.Logging open MyWebLog open MyWebLog.Data open Npgsql.FSharp -open Npgsql.Internal.Postgres /// PostgreSQL myWebLog tag mapping data implementation type PostgresTagMapData(log: ILogger) = @@ -39,7 +38,7 @@ type PostgresTagMapData(log: ILogger) = /// Find any tag mappings in a list of tags for the given web log let findMappingForTags (tags: string list) webLogId = log.LogTrace "TagMap.findMappingForTags" - let tagField = Field.InArray (nameof TagMap.Empty.Tag) Table.TagMap (List.map box tags) + let tagField = Field.InArray (nameof TagMap.Empty.Tag) Table.TagMap tags Custom.list $"{selectWithCriteria Table.TagMap} AND {Query.whereByFields All [ tagField ]}" (addFieldParams [ tagField ] [ webLogContains webLogId ]) diff --git a/src/MyWebLog.Data/Postgres/PostgresWebLogUserData.fs b/src/MyWebLog.Data/Postgres/PostgresWebLogUserData.fs index 37d1258..2e88fdc 100644 --- a/src/MyWebLog.Data/Postgres/PostgresWebLogUserData.fs +++ b/src/MyWebLog.Data/Postgres/PostgresWebLogUserData.fs @@ -55,7 +55,7 @@ type PostgresWebLogUserData(log: ILogger) = /// Find the names of users by their IDs for the given web log let findNames webLogId (userIds: WebLogUserId list) = backgroundTask { log.LogTrace "WebLogUser.findNames" - let idField = Field.In (nameof WebLogUser.Empty.Id) (List.map (string >> box) userIds) + let idField = Field.In (nameof WebLogUser.Empty.Id) (List.map string userIds) let! users = Custom.list $"{selectWithCriteria Table.WebLogUser} AND {Query.whereByFields All [ idField ]}" diff --git a/src/MyWebLog.Data/SQLite/SQLiteCategoryData.fs b/src/MyWebLog.Data/SQLite/SQLiteCategoryData.fs index 29c96e2..becf83d 100644 --- a/src/MyWebLog.Data/SQLite/SQLiteCategoryData.fs +++ b/src/MyWebLog.Data/SQLite/SQLiteCategoryData.fs @@ -43,16 +43,14 @@ type SQLiteCategoryData(conn: SqliteConnection, ser: JsonSerializer, log: ILogge ordered |> Seq.map (fun it -> backgroundTask { // Parent category post counts include posts in subcategories - let childCats = + let childField = ordered |> Seq.filter (fun cat -> cat.ParentNames |> Array.contains it.Name) |> Seq.map _.Id |> Seq.append (Seq.singleton it.Id) - |> Seq.map box + |> Field.InArray (nameof Post.Empty.CategoryIds) Table.Post let fields = - [ webLogField webLogId - Field.Equal (nameof Post.Empty.Status) (string Published) - Field.InArray (nameof Post.Empty.CategoryIds) Table.Post childCats ] + [ webLogField webLogId; Field.Equal (nameof Post.Empty.Status) (string Published); childField ] let query = (Query.statementWhere (Query.count Table.Post) (Query.whereByFields All fields)) .Replace("(*)", $"(DISTINCT data->>'{nameof Post.Empty.Id}')") diff --git a/src/MyWebLog.Data/SQLite/SQLitePageData.fs b/src/MyWebLog.Data/SQLite/SQLitePageData.fs index 73f0b54..2dc81aa 100644 --- a/src/MyWebLog.Data/SQLite/SQLitePageData.fs +++ b/src/MyWebLog.Data/SQLite/SQLitePageData.fs @@ -116,7 +116,7 @@ type SQLitePageData(conn: SqliteConnection, log: ILogger) = log.LogTrace "Page.findCurrentPermalink" let fields = [ webLogField webLogId - Field.InArray (nameof Page.Empty.PriorPermalinks) Table.Page (List.map (string >> box) permalinks) ] + Field.InArray (nameof Page.Empty.PriorPermalinks) Table.Page (List.map string permalinks) ] let query = (Query.statementWhere (Query.find Table.Page) (Query.whereByFields All fields)) .Replace("SELECT data", $"SELECT data->>'{linkName}' AS permalink") diff --git a/src/MyWebLog.Data/SQLite/SQLitePostData.fs b/src/MyWebLog.Data/SQLite/SQLitePostData.fs index c8f827d..5e8d4df 100644 --- a/src/MyWebLog.Data/SQLite/SQLitePostData.fs +++ b/src/MyWebLog.Data/SQLite/SQLitePostData.fs @@ -116,7 +116,7 @@ type SQLitePostData(conn: SqliteConnection, log: ILogger) = log.LogTrace "Post.findCurrentPermalink" let fields = [ webLogField webLogId - Field.InArray (nameof Post.Empty.PriorPermalinks) Table.Post (List.map (string >> box) permalinks) ] + Field.InArray (nameof Post.Empty.PriorPermalinks) Table.Post (List.map string permalinks) ] let query = (Query.statementWhere (Query.find Table.Post) (Query.whereByFields All fields)) .Replace("SELECT data", $"SELECT data->>'{linkName}' AS permalink") @@ -133,7 +133,7 @@ type SQLitePostData(conn: SqliteConnection, log: ILogger) = /// Get a page of categorized posts for the given web log (excludes revisions) let findPageOfCategorizedPosts webLogId (categoryIds: CategoryId list) pageNbr postsPerPage = log.LogTrace "Post.findPageOfCategorizedPosts" - let catIdField = Field.InArray (nameof Post.Empty.CategoryIds) Table.Post (List.map (string >> box) categoryIds) + let catIdField = Field.InArray (nameof Post.Empty.CategoryIds) Table.Post (List.map string categoryIds) conn.customList $"""{publishedPostByWebLog} AND {Query.whereByFields Any [ catIdField ]} {Query.orderBy [ Field.Named $"{publishName} DESC" ] SQLite} diff --git a/src/MyWebLog.Data/SQLite/SQLiteTagMapData.fs b/src/MyWebLog.Data/SQLite/SQLiteTagMapData.fs index cbd8007..8621b0e 100644 --- a/src/MyWebLog.Data/SQLite/SQLiteTagMapData.fs +++ b/src/MyWebLog.Data/SQLite/SQLiteTagMapData.fs @@ -39,8 +39,7 @@ type SQLiteTagMapData(conn: SqliteConnection, log: ILogger) = /// Find any tag mappings in a list of tags for the given web log let findMappingForTags (tags: string list) webLogId = log.LogTrace "TagMap.findMappingForTags" - conn.findByFields - Table.TagMap All [ webLogField webLogId; Field.In (nameof TagMap.Empty.Tag) (List.map box tags) ] + conn.findByFields Table.TagMap All [ webLogField webLogId; Field.In (nameof TagMap.Empty.Tag) tags ] /// Save a tag mapping let save (tagMap: TagMap) = diff --git a/src/MyWebLog.Data/SQLite/SQLiteWebLogUserData.fs b/src/MyWebLog.Data/SQLite/SQLiteWebLogUserData.fs index 4390ef9..96cf077 100644 --- a/src/MyWebLog.Data/SQLite/SQLiteWebLogUserData.fs +++ b/src/MyWebLog.Data/SQLite/SQLiteWebLogUserData.fs @@ -52,7 +52,7 @@ type SQLiteWebLogUserData(conn: SqliteConnection, log: ILogger) = /// Find the names of users by their IDs for the given web log let findNames webLogId (userIds: WebLogUserId list) = log.LogTrace "WebLogUser.findNames" - let fields = [ webLogField webLogId; Field.In (nameof WebLogUser.Empty.Id) (List.map (string >> box) userIds) ] + let fields = [ webLogField webLogId; Field.In (nameof WebLogUser.Empty.Id) (List.map string userIds) ] let query = Query.statementWhere (Query.find Table.WebLogUser) (Query.whereByFields All fields) conn.customList query