Skip to content

Commit

Permalink
fixed selectAll function generation
Browse files Browse the repository at this point in the history
  • Loading branch information
lamg committed Jun 28, 2024
1 parent 7ce4e50 commit f1f20ea
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.19] - 2024-06-28

Fixed:

- fixed `selectAll` function generation: snake_case to camelCase is now being applied

## [0.0.18] - 2024-06-28

Added:
Expand Down
2 changes: 1 addition & 1 deletion Cli/Cli.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>0.0.18</Version>
<Version>0.0.19</Version>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RollForward>major</RollForward>
Expand Down
10 changes: 5 additions & 5 deletions Lib/FsGeneration/QueryModule.fs
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ let relationToFsRecord (r: Relation) =

Record(pascalCase r.name) { yield! fields }

let relationToSelect (r: Relation) =
let relationToSelectAll (r: Relation) =
let cols = r.columns |> Seq.map fst |> String.concat ", "
let selectQuery = $"SELECT {cols} FROM {r.name}"

let readRowBody =
r.columns
|> List.mapi (fun i (c, t) ->
match t with
| SqlInteger -> RecordFieldExpr(c, $"rd.GetInt32 {i}")
| SqlText -> RecordFieldExpr(c, $"rd.GetString {i}")
| SqlReal -> RecordFieldExpr(c, $"rd.GetDouble {i}"))
| SqlInteger -> RecordFieldExpr(camelCase c, $"rd.GetInt32 {i}")
| SqlText -> RecordFieldExpr(camelCase c, $"rd.GetString {i}")
| SqlReal -> RecordFieldExpr(camelCase c, $"rd.GetDouble {i}"))
|> RecordExpr

let whileBody =
Expand Down Expand Up @@ -93,7 +93,7 @@ let queryModule (rs: Relation list) =
for x in rs |> List.map relationToFsRecord do
yield x

for x in rs |> List.map relationToSelect do
for x in rs |> List.map relationToSelectAll do
yield x
}
}
Expand Down
2 changes: 1 addition & 1 deletion Lib/Lib.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageId>MigrateLib</PackageId>
<Version>0.0.18</Version>
<Version>0.0.19</Version>
<Authors>Luis Ángel Méndez Gort</Authors>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<AssemblyName>Migrate</AssemblyName>
Expand Down

0 comments on commit f1f20ea

Please sign in to comment.