Skip to content

Commit 34efc62

Browse files
committed
feat: add JSON column support and GitHub workflows
- Add JSON column deserialization support in SelectQuery - Add GitHub CI, build, and publish workflows - Add issue templates for bug reports and feature requests - Update version to 0.10.0 and repository URL - Update documentation with query predicate clarifications - Make MigrationRunner internal for cleaner API
1 parent 2ef6225 commit 34efc62

57 files changed

Lines changed: 367 additions & 977 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Bug Report
2+
description: Report a problem with SwiftSQL
3+
title: "[Bug]: "
4+
labels: ["bug"]
5+
body:
6+
- type: textarea
7+
id: expected
8+
attributes:
9+
label: Expected behavior
10+
description: What did you expect to happen?
11+
validations:
12+
required: true
13+
- type: textarea
14+
id: actual
15+
attributes:
16+
label: Actual behavior
17+
description: What happened instead?
18+
validations:
19+
required: true
20+
- type: textarea
21+
id: steps
22+
attributes:
23+
label: Reproduction steps
24+
description: Provide minimal steps or a small sample
25+
placeholder: |
26+
1.
27+
2.
28+
3.
29+
validations:
30+
required: true
31+
- type: dropdown
32+
id: dialect
33+
attributes:
34+
label: Database dialect
35+
options:
36+
- SQLite
37+
- MySQL / MariaDB
38+
- PostgreSQL
39+
- Other
40+
validations:
41+
required: true
42+
- type: input
43+
id: swiftsql_version
44+
attributes:
45+
label: SwiftSQL version
46+
placeholder: 1.0.0
47+
validations:
48+
required: true
49+
- type: input
50+
id: swiftly_version
51+
attributes:
52+
label: SwiftlyS2 version
53+
placeholder: 1.0.0
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Feature Request
2+
description: Suggest an improvement for SwiftSQL
3+
title: "[Feature]: "
4+
labels: ["enhancement"]
5+
body:
6+
- type: textarea
7+
id: problem
8+
attributes:
9+
label: Problem description
10+
description: What problem are you trying to solve?
11+
validations:
12+
required: true
13+
- type: textarea
14+
id: proposal
15+
attributes:
16+
label: Proposed solution
17+
description: Describe the change you want
18+
validations:
19+
required: true
20+
- type: textarea
21+
id: alternatives
22+
attributes:
23+
label: Alternatives considered
24+
description: Other approaches you considered
25+
validations:
26+
required: false
27+
- type: textarea
28+
id: fit
29+
attributes:
30+
label: Why this fits SwiftSQL philosophy
31+
description: Keep it explicit, small, and predictable
32+
validations:
33+
required: true

.github/workflows/build.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- '**'
8+
tags:
9+
- '*'
10+
11+
jobs:
12+
build:
13+
if: ${{ github.event_name == 'pull_request' || contains(github.event.head_commit.message, '[build]') || startsWith(github.ref, 'refs/tags/') }}
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-dotnet@v4
18+
with:
19+
dotnet-version: '10.0.x'
20+
- run: dotnet restore
21+
- run: dotnet build -c Release --no-restore

.github/workflows/ci.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- '**'
8+
9+
jobs:
10+
test:
11+
if: ${{ github.event_name == 'pull_request' || contains(github.event.head_commit.message, '[ci]') }}
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-dotnet@v4
16+
with:
17+
dotnet-version: '10.0.x'
18+
- run: dotnet restore
19+
- run: dotnet build -c Release --no-restore
20+
- run: dotnet test -c Release --no-build --verbosity normal

.github/workflows/publish.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
tags:
8+
- 'v*.*.*'
9+
10+
jobs:
11+
publish:
12+
if: ${{ github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || contains(github.event.head_commit.message, '[publish]')) }}
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-dotnet@v4
17+
with:
18+
dotnet-version: '10.0.x'
19+
- run: dotnet restore
20+
- run: dotnet pack -c Release --no-restore
21+
- run: dotnet nuget push "**/*.nupkg" --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json

CONTRIBUTING.md

Lines changed: 24 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,38 @@
11
# Contributing to SwiftSQL
22

3-
Thanks for your interest in contributing to SwiftSQL.
3+
SwiftSQL is intentionally small, explicit, and conservative. Thanks for keeping it that way.
44

5-
SwiftSQL is intentionally small, explicit, and conservative by design.
6-
Contributions are welcome, but only when they align with the project’s core goals.
5+
## Local build and tests
76

8-
---
9-
10-
## Project goals
11-
12-
SwiftSQL exists to provide:
13-
14-
- A lightweight async ORM for plugin environments
15-
- Explicit database access (no hidden magic)
16-
- Stateless, thread-safe operation
17-
- Compatibility with externally managed IDbConnection instances
18-
- Predictable behavior under concurrency (Task.WhenAll)
19-
20-
If a change pushes the project toward a full framework ORM, it will likely be rejected.
21-
22-
---
23-
24-
## Non-goals (important)
25-
26-
SwiftSQL does NOT aim to support:
27-
28-
- Change tracking
29-
- DbContext-style lifetimes
30-
- Navigation properties or automatic joins
31-
- Automatic schema diffing or repair
32-
- Complex LINQ providers
33-
- JSON-path querying
34-
- ORM-managed aggregates
35-
36-
Please do not propose features in these areas.
37-
38-
---
39-
40-
## What contributions are welcome
41-
42-
- Bug fixes
43-
- Performance improvements
44-
- Dialect correctness fixes
45-
- Test coverage improvements
46-
- Documentation improvements
47-
- Small, explicit features that fit the existing design (for example: JSON column support)
48-
49-
When in doubt, open an issue before writing a large change.
50-
51-
---
52-
53-
## Code guidelines
54-
55-
- Target framework: net10.0
56-
- Async-only APIs
57-
- No global mutable state
58-
- No connection ownership inside the ORM
59-
- Prefer explicit behavior over convenience
60-
- Keep public API surface minimal and intentional
61-
62-
All new behavior should be covered by tests.
63-
64-
---
65-
66-
## Tests
67-
68-
- Tests live in `SwiftSQL.Tests`
69-
- SQLite is sufficient for most tests
70-
- New features must include tests
71-
- All tests must pass before a PR is considered
7+
```
8+
dotnet build
9+
dotnet run -c Release --project SwiftSQL.Tests/SwiftSQL.Tests.csproj
10+
```
7211

73-
Run locally with:
12+
## Coding style
7413

75-
dotnet build
76-
dotnet run -c Release --project SwiftSQL.Tests
14+
- Clarity and predictability over cleverness
15+
- Keep async APIs async-only
16+
- Avoid shared mutable state
17+
- Keep the public API surface minimal and intentional
7718

78-
---
19+
## Public API changes
7920

80-
## Pull requests
21+
- Breaking changes require discussion before a PR
22+
- If behavior must change, document the impact and migration path
8123

82-
- Keep PRs focused and small
83-
- Avoid refactors unrelated to the change
84-
- Explain why the change is needed, not just what it does
85-
- Breaking changes require discussion first
24+
## Issues and pull requests
8625

87-
---
26+
- File issues with clear steps or a minimal repro
27+
- Keep PRs focused and explain why the change is needed
28+
- Avoid unrelated refactors
8829

89-
## License
30+
## Branching
9031

91-
By contributing, you agree that your contributions are licensed under the same license as the project (MIT).
32+
- main is stable and release-ready
33+
- Features and fixes land via PRs
9234

93-
---
35+
## Testing expectations
9436

95-
Thanks for helping keep SwiftSQL simple, predictable, and boring (in the best possible way).
37+
- New code must include tests
38+
- All tests must pass before review

EntryPoint.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ public static Task<int> DeleteAsync<T>(
9393
return QuerySingleWithJsonAsync<T>(connection, command, map, cancellationToken);
9494
}
9595

96+
/// <summary>
97+
/// Gets an entity by primary key or returns a default instance without writing to the database.
98+
/// </summary>
99+
/// <param name="connection">Open database connection.</param>
100+
/// <param name="primaryKey">Primary key value.</param>
101+
/// <param name="defaultFactory">Factory used when the entity is not found.</param>
102+
/// <param name="dialect">SQL dialect.</param>
103+
/// <param name="transaction">Optional transaction.</param>
104+
/// <param name="cancellationToken">Cancellation token.</param>
96105
public static async Task<T> GetOrDefaultAsync<T>(
97106
IDbConnection connection,
98107
object primaryKey,

Migrations/MigrationRunner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace SwiftSQL.Migrations;
88
/// <summary>
99
/// Runs explicit, versioned migrations and tracks applied versions.
1010
/// </summary>
11-
public static class MigrationRunner
11+
internal static class MigrationRunner
1212
{
1313
/// <summary>
1414
/// Creates the schema migrations tracking table if it does not already exist.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,12 @@ GetOrDefaultAsync (read-only, does not write to the database):
299299
);
300300
```
301301

302+
defaultFactory is only invoked when no row exists, and the default value is not
303+
inserted.
304+
305+
QueryAsync and Select.Where predicates support simple comparisons (==,
306+
!=, >, >=, <, <=) combined with && and || over mapped properties.
307+
302308
---
303309

304310
## 7. Updating data

0 commit comments

Comments
 (0)