Skip to content

Commit

Permalink
Add aggregate 🖼️ (#55)
Browse files Browse the repository at this point in the history
* add aggregate

* fix bugs

* remove debug logs

* fix bugs and update manifest for aggregate

* update CHANGELOG
  • Loading branch information
n25a authored Nov 8, 2022
1 parent 4e09586 commit 8dd4735
Show file tree
Hide file tree
Showing 15 changed files with 372 additions and 86 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Add `Join` function for generating join query with tests. (2022-09-01, @n25a, !44)
* Isolate sql tests by reseting sqlmock for each test. (2022-10-29, @bamdadnouri, !46)
* Remove unnecessary sqlmock row creation in sql tests. (2022-10-29, @bamdadnouri, !48)
* Add aggregate functions and group by to manifest. (2022-11-08, @n25a, !55)

# v1.2.0 - Jun 25 2022

Expand Down
3 changes: 2 additions & 1 deletion cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ func generate(_ *cobra.Command, _ []string) {
joinVars = parser.ExtractJoinVariables(join)
}

if err := repository.Generate(source, destination, packageName, structName, getVars, updateVars, joinVars, create, test); err != nil {
if err := repository.Generate(source, destination, packageName, structName,
getVars, updateVars, joinVars, &[]structure.AggregateField{}, create, test); err != nil {
log.Fatal(err)
}
}
2 changes: 1 addition & 1 deletion cmd/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func apply(_ *cobra.Command, _ []string) {
}

if err := repository.Generate(repo.Source, repo.Destination, repo.PackageName, repo.StructName, &repo.Get,
&repo.Update, &repo.Join, repo.Create.Enable, repo.Test); err != nil {
&repo.Update, &repo.Join, &repo.Aggregate, repo.Create.Enable, repo.Test); err != nil {
log.Fatal(err)
}
}
Expand Down
7 changes: 7 additions & 0 deletions example/ct_manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ repositories:
create:
enable: true
costum_function_name: ""
aggregate:
- conditions: [ 'var1' ]
function: "COUNT"
on: "var2"
as: "count"
group_by: [ 'var1', 'var2' ]
costum_function_name: ""
test: true

- tag: "Example2"
Expand Down
18 changes: 18 additions & 0 deletions example/dst/example.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 1 addition & 27 deletions example/dst/example2_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions example/dst/example_join.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions example/dst/example_join_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 60 additions & 40 deletions example/dst/example_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8dd4735

Please sign in to comment.