Skip to content

Commit f0f1414

Browse files
author
MPCoreDeveloper
committed
current status
1 parent ccc0afe commit f0f1414

25 files changed

Lines changed: 2288 additions & 118 deletions

.github/copilot-instructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## General Guidelines
44
- Test programs should be located in the `tests` folder and not in the repository root.
55
- All project documentation must be written in English. This includes docs, README files, technical specs, implementation plans, and code comments.
6-
- Provide periodic progress updates while work is ongoing to ensure the assistant is not stuck.
6+
- Provide periodic progress updates while work is ongoing and do not remain stuck on the same point for long stretches.
77
- When benchmarking competitor databases (like BLite), document the developer experience (DX) honestly. If a library's API is hard to use, poorly documented, or has mismatches between docs and actual API, note that as a real finding in the benchmark report. User-friendliness and ease of integration matter as much as raw performance numbers.
88
- Standardize all documentation/version labels to v1.7.0 ("V 1.70").
99
- Continue implementation until the scoped roadmap work is finished without pausing for confirmation.

Examples/CQRS/OrderManagement.CqrsDemo/OrderCqrsDemo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace OrderManagement.CqrsDemo;
77

8-
using SharpCoreDB.CQRS;
8+
using SharpDispatch;
99

1010
/// <summary>
1111
/// Command for creating an order on the write side.

Examples/CQRS/OrderManagement.CqrsDemo/OrderManagement.CqrsDemo.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
@@ -20,6 +20,10 @@
2020
<PackageReference Include="SharpCoreDB.CQRS" Version="1.7.0" />
2121
</ItemGroup>
2222

23+
<ItemGroup>
24+
<PackageReference Include="SharpDispatch" Version="1.0.1" />
25+
</ItemGroup>
26+
2327
<ItemGroup>
2428
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="10.0.202" />
2529
</ItemGroup>

Examples/CQRS/OrderManagement.CqrsDemo/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// </copyright>
55

66
using OrderManagement.CqrsDemo;
7-
using SharpCoreDB.CQRS;
7+
using SharpDispatch;
88

99
Console.WriteLine("========================================");
1010
Console.WriteLine(" SharpCoreDB Explicit CQRS Demo");

Examples/Web/Orchardcore/SharpCoreDb.Orchardcore/SharpCoreDb.Orchardcore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<ItemGroup>
2323
<PackageReference Include="HtmlSanitizer" Version="9.0.892" />
2424
<PackageReference Include="MimeKit" Version="4.15.1" />
25-
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="10.4.0" />
25+
<PackageReference Include="Microsoft.Extensions.Http.Resilience" Version="10.5.0" />
2626
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="10.0.6" />
2727
<PackageReference Include="AWSSDK.Core" Version="4.0.3.29" />
2828
</ItemGroup>

docs/analytics/README.md

Lines changed: 83 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,27 @@ var running = await database.QueryAsync(
296296
);
297297
```
298298

299+
### FILTER on Window Functions
300+
**Supported since v1.7.0** — FILTER clause applies to window functions, filtering the window frame before calculation.
301+
302+
```csharp
303+
// Row numbers only for active employees
304+
var activeRanking = await database.QueryAsync(
305+
@"SELECT name, department,
306+
ROW_NUMBER() FILTER (WHERE active = 1) OVER (PARTITION BY department ORDER BY salary DESC) AS active_rank
307+
FROM employees
308+
ORDER BY department, active_rank"
309+
);
310+
311+
// Department averages excluding inactive employees
312+
var deptAvgs = await database.QueryAsync(
313+
@"SELECT name, department, salary,
314+
AVG(salary) FILTER (WHERE active = 1) OVER (PARTITION BY department) AS active_dept_avg
315+
FROM employees
316+
ORDER BY department, salary"
317+
);
318+
```
319+
299320
---
300321

301322
## Group By and Having
@@ -316,20 +337,73 @@ var byRegion = await database.QueryAsync(
316337
);
317338
```
318339

340+
### FILTER (WHERE ...)
341+
Applies a predicate to a single aggregate expression, matching the SQLite/PostgreSQL aggregate `FILTER` style for the currently supported aggregate executor path.
342+
343+
```csharp
344+
// Count only paid sales while still returning grouped totals
345+
var filtered = await database.QueryAsync(
346+
@"SELECT
347+
category,
348+
COUNT(*) AS total_count,
349+
COUNT(*) FILTER (WHERE status = 'paid') AS paid_count,
350+
SUM(amount) FILTER (WHERE status = 'paid') AS paid_total
351+
FROM sales
352+
GROUP BY category
353+
ORDER BY category"
354+
);
355+
```
356+
357+
Current support and known gaps are tracked in `docs/compatibility/SQLITE_POSTGRESQL_AGGREGATE_SYNTAX_v1.7.0.md`.
358+
319359
### HAVING
320360
Filters grouped results (WHERE applies before GROUP BY, HAVING after).
321361

362+
**Supported since v1.7.0** — HAVING predicates can reference aggregate aliases defined in SELECT.
363+
322364
```csharp
323-
// Find departments with >5 employees
324-
var largeDepts = await database.QueryAsync(
365+
// Find categories with total revenue > 100
366+
var highRevenue = await database.QueryAsync(
325367
@"SELECT
326-
department,
327-
COUNT(*) AS emp_count,
328-
AVG(salary) AS avg_salary
329-
FROM employees
330-
GROUP BY department
331-
HAVING COUNT(*) > 5
332-
ORDER BY emp_count DESC"
368+
category,
369+
SUM(amount) AS total
370+
FROM orders
371+
GROUP BY category
372+
HAVING total > 100
373+
ORDER BY total DESC"
374+
);
375+
376+
// Filter groups by count
377+
var popularItems = await database.QueryAsync(
378+
@"SELECT category, COUNT(*) AS cnt
379+
FROM items
380+
GROUP BY category
381+
HAVING cnt >= 2"
382+
);
383+
```
384+
385+
### Arithmetic expressions inside aggregates
386+
**Supported since v1.7.0** — aggregate arguments accept arithmetic expressions such as `price * qty`, `a + b`, `a - b / c`.
387+
388+
```csharp
389+
// Total revenue: SUM(price * quantity)
390+
var revenue = await database.QueryAsync(
391+
@"SELECT SUM(price * qty) AS revenue FROM sales"
392+
);
393+
```
394+
395+
### FILTER with JOIN queries
396+
**Supported since v1.7.0** — FILTER clause works on both single-table and JOIN-backed aggregate queries.
397+
398+
```csharp
399+
// Active payroll per department (JOIN + FILTER + GROUP BY)
400+
var payroll = await database.QueryAsync(
401+
@"SELECT departments.name,
402+
SUM(employees.salary) FILTER (WHERE employees.active = 1) AS active_payroll
403+
FROM departments
404+
JOIN employees ON departments.id = employees.dept_id
405+
GROUP BY departments.name
406+
ORDER BY departments.name"
333407
);
334408
```
335409

0 commit comments

Comments
 (0)