Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/legacy-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
shell: pwsh
command: |
$mysqlJob = Start-Job -ScriptBlock {
choco install mysql --no-progress --version=8.4.4 -y --params "/serviceName:MySQL"
choco install mysql --no-progress --version=8.4.6 -y --params "/serviceName:MySQL"
return $LASTEXITCODE
}

Expand Down
4 changes: 4 additions & 0 deletions PluginOptions/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ public class Options
public Options(GenerateRequest generateRequest)
{
var text = Encoding.UTF8.GetString(generateRequest.PluginOptions.ToByteArray());
// handle empty options case
if (text.Trim() == string.Empty)
text = "{}";

var rawOptions = JsonSerializer.Deserialize<RawOptions>(text) ?? throw new InvalidOperationException();

DriverName = EngineToDriverMapping[generateRequest.Settings.Engine];
Expand Down
64 changes: 64 additions & 0 deletions examples/QuickStartMySqlDalGen/Models.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// auto-generated by sqlc - do not edit
using System;
using System.Collections.Generic;
using System.Linq;

namespace QuickStartMySqlDalGen;
public readonly record struct Author(long Id, string Name, string? Bio);
public readonly record struct Book(long Id, string Name, long AuthorId, string? Description);
public readonly record struct ExtendedBio(string? AuthorName, string? Name, BiosBioType? BioType, HashSet<BiosAuthorType>? AuthorType);
public enum BiosBioType
{
Invalid = 0, // reserved for invalid enum value
Autobiography = 1,
Biography = 2,
Memoir = 3
}

public static class BiosBioTypeExtensions
{
private static readonly Dictionary<string, BiosBioType> StringToEnum = new Dictionary<string, BiosBioType>()
{
[string.Empty] = BiosBioType.Invalid,
["Autobiography"] = BiosBioType.Autobiography,
["Biography"] = BiosBioType.Biography,
["Memoir"] = BiosBioType.Memoir
};
public static BiosBioType ToBiosBioType(this string me)
{
return StringToEnum[me];
}

public static HashSet<BiosBioType> ToBiosBioTypeSet(this string me)
{
return new HashSet<BiosBioType>(me.Split(',').ToList().Select(v => StringToEnum[v]));
}
}

public enum BiosAuthorType
{
Invalid = 0, // reserved for invalid enum value
Author = 1,
Editor = 2,
Translator = 3
}

public static class BiosAuthorTypeExtensions
{
private static readonly Dictionary<string, BiosAuthorType> StringToEnum = new Dictionary<string, BiosAuthorType>()
{
[string.Empty] = BiosAuthorType.Invalid,
["Author"] = BiosAuthorType.Author,
["Editor"] = BiosAuthorType.Editor,
["Translator"] = BiosAuthorType.Translator
};
public static BiosAuthorType ToBiosAuthorType(this string me)
{
return StringToEnum[me];
}

public static HashSet<BiosAuthorType> ToBiosAuthorTypeSet(this string me)
{
return new HashSet<BiosAuthorType>(me.Split(',').ToList().Select(v => StringToEnum[v]));
}
}
Loading
Loading