parent
83841d801c
commit
b95a67751e
58 changed files with 1257 additions and 4006 deletions
5
.github/workflows/ci_golangci-lint.yml
vendored
5
.github/workflows/ci_golangci-lint.yml
vendored
|
@ -23,6 +23,11 @@ jobs:
|
||||||
name: lint
|
name: lint
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
|
- name: Set up Go 1.19
|
||||||
|
uses: actions/setup-go@v1
|
||||||
|
with:
|
||||||
|
go-version: 1.19
|
||||||
|
id: go
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v3
|
uses: golangci/golangci-lint-action@v3
|
||||||
|
|
22
go.mod
22
go.mod
|
@ -3,7 +3,7 @@ module github.com/crowdsecurity/crowdsec
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
entgo.io/ent v0.10.1
|
entgo.io/ent v0.11.3
|
||||||
github.com/AlecAivazis/survey/v2 v2.2.7
|
github.com/AlecAivazis/survey/v2 v2.2.7
|
||||||
github.com/Microsoft/go-winio v0.5.2 // indirect
|
github.com/Microsoft/go-winio v0.5.2 // indirect
|
||||||
github.com/crowdsecurity/dlog v0.0.0-20170105205344-4fb5f8204f26
|
github.com/crowdsecurity/dlog v0.0.0-20170105205344-4fb5f8204f26
|
||||||
|
@ -15,7 +15,7 @@ require (
|
||||||
github.com/c-robinson/iplib v1.0.3
|
github.com/c-robinson/iplib v1.0.3
|
||||||
github.com/confluentinc/bincover v0.2.0
|
github.com/confluentinc/bincover v0.2.0
|
||||||
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
|
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
|
||||||
github.com/crowdsecurity/grokky v0.0.0-20220120093523-d5b3478363fa
|
github.com/crowdsecurity/grokky v0.1.0
|
||||||
github.com/crowdsecurity/machineid v1.0.2
|
github.com/crowdsecurity/machineid v1.0.2
|
||||||
github.com/davecgh/go-spew v1.1.1
|
github.com/davecgh/go-spew v1.1.1
|
||||||
github.com/dghubble/sling v1.3.0
|
github.com/dghubble/sling v1.3.0
|
||||||
|
@ -25,7 +25,7 @@ require (
|
||||||
github.com/fatih/color v1.13.0
|
github.com/fatih/color v1.13.0
|
||||||
github.com/fsnotify/fsnotify v1.5.1
|
github.com/fsnotify/fsnotify v1.5.1
|
||||||
github.com/gin-gonic/gin v1.7.7
|
github.com/gin-gonic/gin v1.7.7
|
||||||
github.com/go-co-op/gocron v1.9.0
|
github.com/go-co-op/gocron v1.17.0
|
||||||
github.com/go-openapi/errors v0.20.1
|
github.com/go-openapi/errors v0.20.1
|
||||||
github.com/go-openapi/strfmt v0.19.11
|
github.com/go-openapi/strfmt v0.19.11
|
||||||
github.com/go-openapi/swag v0.19.12
|
github.com/go-openapi/swag v0.19.12
|
||||||
|
@ -40,8 +40,8 @@ require (
|
||||||
github.com/jackc/pgx/v4 v4.14.1
|
github.com/jackc/pgx/v4 v4.14.1
|
||||||
github.com/jarcoal/httpmock v1.1.0
|
github.com/jarcoal/httpmock v1.1.0
|
||||||
github.com/jszwec/csvutil v1.5.1
|
github.com/jszwec/csvutil v1.5.1
|
||||||
github.com/lib/pq v1.10.4
|
github.com/lib/pq v1.10.7
|
||||||
github.com/mattn/go-sqlite3 v1.14.10
|
github.com/mattn/go-sqlite3 v1.14.15
|
||||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
|
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
|
||||||
github.com/nxadm/tail v1.4.6
|
github.com/nxadm/tail v1.4.6
|
||||||
github.com/olekukonko/tablewriter v0.0.5
|
github.com/olekukonko/tablewriter v0.0.5
|
||||||
|
@ -56,7 +56,7 @@ require (
|
||||||
github.com/spf13/cobra v1.5.0
|
github.com/spf13/cobra v1.5.0
|
||||||
github.com/stretchr/testify v1.8.0
|
github.com/stretchr/testify v1.8.0
|
||||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d
|
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4
|
||||||
google.golang.org/grpc v1.45.0
|
google.golang.org/grpc v1.45.0
|
||||||
google.golang.org/protobuf v1.28.0
|
google.golang.org/protobuf v1.28.0
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0
|
gopkg.in/natefinch/lumberjack.v2 v2.0.0
|
||||||
|
@ -73,11 +73,11 @@ require (
|
||||||
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58
|
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58
|
||||||
github.com/segmentio/kafka-go v0.4.34
|
github.com/segmentio/kafka-go v0.4.34
|
||||||
github.com/texttheater/golang-levenshtein/levenshtein v0.0.0-20200805054039-cae8b0eaed6c
|
github.com/texttheater/golang-levenshtein/levenshtein v0.0.0-20200805054039-cae8b0eaed6c
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
ariga.io/atlas v0.3.7-0.20220303204946-787354f533c3 // indirect
|
ariga.io/atlas v0.7.2-0.20220927111110-867ee0cca56a // indirect
|
||||||
github.com/Masterminds/goutils v1.1.1 // indirect
|
github.com/Masterminds/goutils v1.1.1 // indirect
|
||||||
github.com/Masterminds/semver/v3 v3.1.1 // indirect
|
github.com/Masterminds/semver/v3 v3.1.1 // indirect
|
||||||
github.com/PuerkitoBio/purell v1.1.1 // indirect
|
github.com/PuerkitoBio/purell v1.1.1 // indirect
|
||||||
|
@ -111,7 +111,7 @@ require (
|
||||||
github.com/golang/protobuf v1.5.2 // indirect
|
github.com/golang/protobuf v1.5.2 // indirect
|
||||||
github.com/google/go-cmp v0.5.7 // indirect
|
github.com/google/go-cmp v0.5.7 // indirect
|
||||||
github.com/gorilla/mux v1.7.3 // indirect
|
github.com/gorilla/mux v1.7.3 // indirect
|
||||||
github.com/hashicorp/hcl/v2 v2.11.1 // indirect
|
github.com/hashicorp/hcl/v2 v2.13.0 // indirect
|
||||||
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect
|
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect
|
||||||
github.com/huandu/xstrings v1.3.2 // indirect
|
github.com/huandu/xstrings v1.3.2 // indirect
|
||||||
github.com/imdario/mergo v0.3.12 // indirect
|
github.com/imdario/mergo v0.3.12 // indirect
|
||||||
|
@ -138,7 +138,7 @@ require (
|
||||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||||
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
|
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
|
||||||
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
|
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
|
||||||
github.com/mitchellh/mapstructure v1.4.3 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||||
github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 // indirect
|
github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
|
@ -164,7 +164,7 @@ require (
|
||||||
github.com/zclconf/go-cty v1.10.0 // indirect
|
github.com/zclconf/go-cty v1.10.0 // indirect
|
||||||
go.mongodb.org/mongo-driver v1.9.0 // indirect
|
go.mongodb.org/mongo-driver v1.9.0 // indirect
|
||||||
golang.org/x/net v0.0.0-20220706163947-c90051bbdb60 // indirect
|
golang.org/x/net v0.0.0-20220706163947-c90051bbdb60 // indirect
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
|
||||||
golang.org/x/text v0.3.7 // indirect
|
golang.org/x/text v0.3.7 // indirect
|
||||||
google.golang.org/appengine v1.6.7 // indirect
|
google.golang.org/appengine v1.6.7 // indirect
|
||||||
|
|
23
go.sum
23
go.sum
|
@ -1,5 +1,7 @@
|
||||||
ariga.io/atlas v0.3.7-0.20220303204946-787354f533c3 h1:fjG4oFCQEfGrRi0QoxWcH2OO28CE6VYa6DkIr3yDySU=
|
ariga.io/atlas v0.3.7-0.20220303204946-787354f533c3 h1:fjG4oFCQEfGrRi0QoxWcH2OO28CE6VYa6DkIr3yDySU=
|
||||||
ariga.io/atlas v0.3.7-0.20220303204946-787354f533c3/go.mod h1:yWGf4VPiD4SW83+kAqzD624txN9VKoJC+bpVXr2pKJA=
|
ariga.io/atlas v0.3.7-0.20220303204946-787354f533c3/go.mod h1:yWGf4VPiD4SW83+kAqzD624txN9VKoJC+bpVXr2pKJA=
|
||||||
|
ariga.io/atlas v0.7.2-0.20220927111110-867ee0cca56a h1:6/nt4DODfgxzHTTg3tYy7YkVzruGQGZ/kRvXpA45KUo=
|
||||||
|
ariga.io/atlas v0.7.2-0.20220927111110-867ee0cca56a/go.mod h1:ft47uSh5hWGDCmQC9DsztZg6Xk+KagM5Ts/mZYKb9JE=
|
||||||
bitbucket.org/creachadair/stringset v0.0.9 h1:L4vld9nzPt90UZNrXjNelTshD74ps4P5NGs3Iq6yN3o=
|
bitbucket.org/creachadair/stringset v0.0.9 h1:L4vld9nzPt90UZNrXjNelTshD74ps4P5NGs3Iq6yN3o=
|
||||||
bitbucket.org/creachadair/stringset v0.0.9/go.mod h1:t+4WcQ4+PXTa8aQdNKe40ZP6iwesoMFWAxPGd3UGjyY=
|
bitbucket.org/creachadair/stringset v0.0.9/go.mod h1:t+4WcQ4+PXTa8aQdNKe40ZP6iwesoMFWAxPGd3UGjyY=
|
||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
|
@ -37,6 +39,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
entgo.io/ent v0.10.1 h1:dM5h4Zk6yHGIgw4dCqVzGw3nWgpGYJiV4/kyHEF6PFo=
|
entgo.io/ent v0.10.1 h1:dM5h4Zk6yHGIgw4dCqVzGw3nWgpGYJiV4/kyHEF6PFo=
|
||||||
entgo.io/ent v0.10.1/go.mod h1:YPgxeLnoQ/YdpVORRtqjBF+wCy9NX9IR7veTv3Bffus=
|
entgo.io/ent v0.10.1/go.mod h1:YPgxeLnoQ/YdpVORRtqjBF+wCy9NX9IR7veTv3Bffus=
|
||||||
|
entgo.io/ent v0.11.3 h1:F5FBGAWiDCGder7YT+lqMnyzXl6d0xU3xMBM/SO3CMc=
|
||||||
|
entgo.io/ent v0.11.3/go.mod h1:mvDhvynOzAsOe7anH7ynPPtMjA/eeXP96kAfweevyxc=
|
||||||
github.com/AlecAivazis/survey/v2 v2.2.7 h1:5NbxkF4RSKmpywYdcRgUmos1o+roJY8duCLZXbVjoig=
|
github.com/AlecAivazis/survey/v2 v2.2.7 h1:5NbxkF4RSKmpywYdcRgUmos1o+roJY8duCLZXbVjoig=
|
||||||
github.com/AlecAivazis/survey/v2 v2.2.7/go.mod h1:9DYvHgXtiXm6nCn+jXnOXLKbH+Yo9u8fAS/SduGdoPk=
|
github.com/AlecAivazis/survey/v2 v2.2.7/go.mod h1:9DYvHgXtiXm6nCn+jXnOXLKbH+Yo9u8fAS/SduGdoPk=
|
||||||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8=
|
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8=
|
||||||
|
@ -138,6 +142,8 @@ github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw=
|
||||||
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/crowdsecurity/grokky v0.0.0-20220120093523-d5b3478363fa h1:pcHZgbBbIkNDO1cAgipEgaGeFJ0se+FOPvq6A4d/g9c=
|
github.com/crowdsecurity/grokky v0.0.0-20220120093523-d5b3478363fa h1:pcHZgbBbIkNDO1cAgipEgaGeFJ0se+FOPvq6A4d/g9c=
|
||||||
github.com/crowdsecurity/grokky v0.0.0-20220120093523-d5b3478363fa/go.mod h1:fx5UYUYAFIrOUNAkFCUOM2wJcsp9EWSQE9R0/9kaFJg=
|
github.com/crowdsecurity/grokky v0.0.0-20220120093523-d5b3478363fa/go.mod h1:fx5UYUYAFIrOUNAkFCUOM2wJcsp9EWSQE9R0/9kaFJg=
|
||||||
|
github.com/crowdsecurity/grokky v0.1.0 h1:jLUzZd3vKxYrM4hQ8n5HWLfvs5ag4UP08eT9OTekI4U=
|
||||||
|
github.com/crowdsecurity/grokky v0.1.0/go.mod h1:fx5UYUYAFIrOUNAkFCUOM2wJcsp9EWSQE9R0/9kaFJg=
|
||||||
github.com/crowdsecurity/machineid v1.0.2 h1:wpkpsUghJF8Khtmn/tg6GxgdhLA1Xflerh5lirI+bdc=
|
github.com/crowdsecurity/machineid v1.0.2 h1:wpkpsUghJF8Khtmn/tg6GxgdhLA1Xflerh5lirI+bdc=
|
||||||
github.com/crowdsecurity/machineid v1.0.2/go.mod h1:XWUSlnS0R0+u/JK5ulidwlbceNT3ZOCKteoVQEn6Luo=
|
github.com/crowdsecurity/machineid v1.0.2/go.mod h1:XWUSlnS0R0+u/JK5ulidwlbceNT3ZOCKteoVQEn6Luo=
|
||||||
github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
@ -180,6 +186,8 @@ github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0
|
||||||
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
|
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q=
|
||||||
github.com/go-co-op/gocron v1.9.0 h1:+V+DDenw3ryB7B+tK1bAIC5p0ruw4oX9IqAsdRnGIf0=
|
github.com/go-co-op/gocron v1.9.0 h1:+V+DDenw3ryB7B+tK1bAIC5p0ruw4oX9IqAsdRnGIf0=
|
||||||
github.com/go-co-op/gocron v1.9.0/go.mod h1:DbJm9kdgr1sEvWpHCA7dFFs/PGHPMil9/97EXCRPr4k=
|
github.com/go-co-op/gocron v1.9.0/go.mod h1:DbJm9kdgr1sEvWpHCA7dFFs/PGHPMil9/97EXCRPr4k=
|
||||||
|
github.com/go-co-op/gocron v1.17.0 h1:IixLXsti+Qo0wMvmn6Kmjp2csk2ykpkcL+EmHmST18w=
|
||||||
|
github.com/go-co-op/gocron v1.17.0/go.mod h1:IpDBSaJOVfFw7hXZuTag3SCSkqazXBBUkbQ1m1aesBs=
|
||||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||||
|
@ -410,6 +418,8 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
||||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
github.com/hashicorp/hcl/v2 v2.11.1 h1:yTyWcXcm9XB0TEkyU/JCRU6rYy4K+mgLtzn2wlrJbcc=
|
github.com/hashicorp/hcl/v2 v2.11.1 h1:yTyWcXcm9XB0TEkyU/JCRU6rYy4K+mgLtzn2wlrJbcc=
|
||||||
github.com/hashicorp/hcl/v2 v2.11.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg=
|
github.com/hashicorp/hcl/v2 v2.11.1/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg=
|
||||||
|
github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgCNc=
|
||||||
|
github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0=
|
||||||
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M=
|
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M=
|
||||||
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
|
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
|
||||||
github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174 h1:WlZsjVhE8Af9IcZDGgJGQpNflI3+MJSBhsgT5PCtzBQ=
|
github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174 h1:WlZsjVhE8Af9IcZDGgJGQpNflI3+MJSBhsgT5PCtzBQ=
|
||||||
|
@ -533,6 +543,8 @@ github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk=
|
github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk=
|
||||||
github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
|
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
|
||||||
|
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s=
|
github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s=
|
||||||
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||||
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||||
|
@ -565,6 +577,8 @@ github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4
|
||||||
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||||
github.com/mattn/go-sqlite3 v1.14.10 h1:MLn+5bFRlWMGoSRmJour3CL1w/qL96mvipqpwQW/Sfk=
|
github.com/mattn/go-sqlite3 v1.14.10 h1:MLn+5bFRlWMGoSRmJour3CL1w/qL96mvipqpwQW/Sfk=
|
||||||
github.com/mattn/go-sqlite3 v1.14.10/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
github.com/mattn/go-sqlite3 v1.14.10/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
|
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
|
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
|
||||||
|
@ -586,6 +600,8 @@ github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR
|
||||||
github.com/mitchellh/mapstructure v1.4.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
github.com/mitchellh/mapstructure v1.4.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||||
github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs=
|
github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs=
|
||||||
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||||
|
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||||
|
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||||
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
||||||
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
|
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
|
||||||
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
||||||
|
@ -844,6 +860,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
|
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
|
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
|
||||||
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
|
||||||
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
@ -908,6 +926,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
|
||||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
|
||||||
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
@ -971,6 +991,8 @@ golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k=
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
|
||||||
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
|
||||||
|
@ -1045,6 +1067,7 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc
|
||||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||||
|
golang.org/x/tools v0.1.13-0.20220804200503-81c7dc4e4efa h1:uKcci2q7Qtp6nMTC/AAvfNUAldFtJuHWV9/5QWiypts=
|
||||||
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -87,8 +87,7 @@ type AlertEdges struct {
|
||||||
func (e AlertEdges) OwnerOrErr() (*Machine, error) {
|
func (e AlertEdges) OwnerOrErr() (*Machine, error) {
|
||||||
if e.loadedTypes[0] {
|
if e.loadedTypes[0] {
|
||||||
if e.Owner == nil {
|
if e.Owner == nil {
|
||||||
// The edge owner was loaded in eager-loading,
|
// Edge was loaded but was not found.
|
||||||
// but was not found.
|
|
||||||
return nil, &NotFoundError{label: machine.Label}
|
return nil, &NotFoundError{label: machine.Label}
|
||||||
}
|
}
|
||||||
return e.Owner, nil
|
return e.Owner, nil
|
||||||
|
@ -124,8 +123,8 @@ func (e AlertEdges) MetasOrErr() ([]*Meta, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// scanValues returns the types for scanning values from sql.Rows.
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
func (*Alert) scanValues(columns []string) ([]interface{}, error) {
|
func (*Alert) scanValues(columns []string) ([]any, error) {
|
||||||
values := make([]interface{}, len(columns))
|
values := make([]any, len(columns))
|
||||||
for i := range columns {
|
for i := range columns {
|
||||||
switch columns[i] {
|
switch columns[i] {
|
||||||
case alert.FieldSimulated:
|
case alert.FieldSimulated:
|
||||||
|
@ -149,7 +148,7 @@ func (*Alert) scanValues(columns []string) ([]interface{}, error) {
|
||||||
|
|
||||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||||
// to the Alert fields.
|
// to the Alert fields.
|
||||||
func (a *Alert) assignValues(columns []string, values []interface{}) error {
|
func (a *Alert) assignValues(columns []string, values []any) error {
|
||||||
if m, n := len(values), len(columns); m < n {
|
if m, n := len(values), len(columns); m < n {
|
||||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||||
}
|
}
|
||||||
|
@ -337,11 +336,11 @@ func (a *Alert) Update() *AlertUpdateOne {
|
||||||
// Unwrap unwraps the Alert entity that was returned from a transaction after it was closed,
|
// Unwrap unwraps the Alert entity that was returned from a transaction after it was closed,
|
||||||
// so that all future queries will be executed through the driver which created the transaction.
|
// so that all future queries will be executed through the driver which created the transaction.
|
||||||
func (a *Alert) Unwrap() *Alert {
|
func (a *Alert) Unwrap() *Alert {
|
||||||
tx, ok := a.config.driver.(*txDriver)
|
_tx, ok := a.config.driver.(*txDriver)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("ent: Alert is not a transactional entity")
|
panic("ent: Alert is not a transactional entity")
|
||||||
}
|
}
|
||||||
a.config.driver = tx.drv
|
a.config.driver = _tx.drv
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -349,54 +348,75 @@ func (a *Alert) Unwrap() *Alert {
|
||||||
func (a *Alert) String() string {
|
func (a *Alert) String() string {
|
||||||
var builder strings.Builder
|
var builder strings.Builder
|
||||||
builder.WriteString("Alert(")
|
builder.WriteString("Alert(")
|
||||||
builder.WriteString(fmt.Sprintf("id=%v", a.ID))
|
builder.WriteString(fmt.Sprintf("id=%v, ", a.ID))
|
||||||
if v := a.CreatedAt; v != nil {
|
if v := a.CreatedAt; v != nil {
|
||||||
builder.WriteString(", created_at=")
|
builder.WriteString("created_at=")
|
||||||
builder.WriteString(v.Format(time.ANSIC))
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
}
|
}
|
||||||
|
builder.WriteString(", ")
|
||||||
if v := a.UpdatedAt; v != nil {
|
if v := a.UpdatedAt; v != nil {
|
||||||
builder.WriteString(", updated_at=")
|
builder.WriteString("updated_at=")
|
||||||
builder.WriteString(v.Format(time.ANSIC))
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
}
|
}
|
||||||
builder.WriteString(", scenario=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("scenario=")
|
||||||
builder.WriteString(a.Scenario)
|
builder.WriteString(a.Scenario)
|
||||||
builder.WriteString(", bucketId=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("bucketId=")
|
||||||
builder.WriteString(a.BucketId)
|
builder.WriteString(a.BucketId)
|
||||||
builder.WriteString(", message=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("message=")
|
||||||
builder.WriteString(a.Message)
|
builder.WriteString(a.Message)
|
||||||
builder.WriteString(", eventsCount=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("eventsCount=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", a.EventsCount))
|
builder.WriteString(fmt.Sprintf("%v", a.EventsCount))
|
||||||
builder.WriteString(", startedAt=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("startedAt=")
|
||||||
builder.WriteString(a.StartedAt.Format(time.ANSIC))
|
builder.WriteString(a.StartedAt.Format(time.ANSIC))
|
||||||
builder.WriteString(", stoppedAt=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("stoppedAt=")
|
||||||
builder.WriteString(a.StoppedAt.Format(time.ANSIC))
|
builder.WriteString(a.StoppedAt.Format(time.ANSIC))
|
||||||
builder.WriteString(", sourceIp=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("sourceIp=")
|
||||||
builder.WriteString(a.SourceIp)
|
builder.WriteString(a.SourceIp)
|
||||||
builder.WriteString(", sourceRange=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("sourceRange=")
|
||||||
builder.WriteString(a.SourceRange)
|
builder.WriteString(a.SourceRange)
|
||||||
builder.WriteString(", sourceAsNumber=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("sourceAsNumber=")
|
||||||
builder.WriteString(a.SourceAsNumber)
|
builder.WriteString(a.SourceAsNumber)
|
||||||
builder.WriteString(", sourceAsName=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("sourceAsName=")
|
||||||
builder.WriteString(a.SourceAsName)
|
builder.WriteString(a.SourceAsName)
|
||||||
builder.WriteString(", sourceCountry=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("sourceCountry=")
|
||||||
builder.WriteString(a.SourceCountry)
|
builder.WriteString(a.SourceCountry)
|
||||||
builder.WriteString(", sourceLatitude=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("sourceLatitude=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", a.SourceLatitude))
|
builder.WriteString(fmt.Sprintf("%v", a.SourceLatitude))
|
||||||
builder.WriteString(", sourceLongitude=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("sourceLongitude=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", a.SourceLongitude))
|
builder.WriteString(fmt.Sprintf("%v", a.SourceLongitude))
|
||||||
builder.WriteString(", sourceScope=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("sourceScope=")
|
||||||
builder.WriteString(a.SourceScope)
|
builder.WriteString(a.SourceScope)
|
||||||
builder.WriteString(", sourceValue=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("sourceValue=")
|
||||||
builder.WriteString(a.SourceValue)
|
builder.WriteString(a.SourceValue)
|
||||||
builder.WriteString(", capacity=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("capacity=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", a.Capacity))
|
builder.WriteString(fmt.Sprintf("%v", a.Capacity))
|
||||||
builder.WriteString(", leakSpeed=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("leakSpeed=")
|
||||||
builder.WriteString(a.LeakSpeed)
|
builder.WriteString(a.LeakSpeed)
|
||||||
builder.WriteString(", scenarioVersion=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("scenarioVersion=")
|
||||||
builder.WriteString(a.ScenarioVersion)
|
builder.WriteString(a.ScenarioVersion)
|
||||||
builder.WriteString(", scenarioHash=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("scenarioHash=")
|
||||||
builder.WriteString(a.ScenarioHash)
|
builder.WriteString(a.ScenarioHash)
|
||||||
builder.WriteString(", simulated=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("simulated=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", a.Simulated))
|
builder.WriteString(fmt.Sprintf("%v", a.Simulated))
|
||||||
builder.WriteByte(')')
|
builder.WriteByte(')')
|
||||||
return builder.String()
|
return builder.String()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package alert
|
package alert
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package alert
|
package alert
|
||||||
|
|
||||||
|
@ -34,13 +34,7 @@ func IDNEQ(id int) predicate.Alert {
|
||||||
// IDIn applies the In predicate on the ID field.
|
// IDIn applies the In predicate on the ID field.
|
||||||
func IDIn(ids ...int) predicate.Alert {
|
func IDIn(ids ...int) predicate.Alert {
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
v := make([]any, len(ids))
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(ids) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
v := make([]interface{}, len(ids))
|
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = ids[i]
|
v[i] = ids[i]
|
||||||
}
|
}
|
||||||
|
@ -51,13 +45,7 @@ func IDIn(ids ...int) predicate.Alert {
|
||||||
// IDNotIn applies the NotIn predicate on the ID field.
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
func IDNotIn(ids ...int) predicate.Alert {
|
func IDNotIn(ids ...int) predicate.Alert {
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
v := make([]any, len(ids))
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(ids) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
v := make([]interface{}, len(ids))
|
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = ids[i]
|
v[i] = ids[i]
|
||||||
}
|
}
|
||||||
|
@ -263,34 +251,22 @@ func CreatedAtNEQ(v time.Time) predicate.Alert {
|
||||||
|
|
||||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||||
func CreatedAtIn(vs ...time.Time) predicate.Alert {
|
func CreatedAtIn(vs ...time.Time) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldCreatedAt), v...))
|
s.Where(sql.In(s.C(FieldCreatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||||
func CreatedAtNotIn(vs ...time.Time) predicate.Alert {
|
func CreatedAtNotIn(vs ...time.Time) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
|
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -353,34 +329,22 @@ func UpdatedAtNEQ(v time.Time) predicate.Alert {
|
||||||
|
|
||||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||||
func UpdatedAtIn(vs ...time.Time) predicate.Alert {
|
func UpdatedAtIn(vs ...time.Time) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
|
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||||
func UpdatedAtNotIn(vs ...time.Time) predicate.Alert {
|
func UpdatedAtNotIn(vs ...time.Time) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
|
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -443,34 +407,22 @@ func ScenarioNEQ(v string) predicate.Alert {
|
||||||
|
|
||||||
// ScenarioIn applies the In predicate on the "scenario" field.
|
// ScenarioIn applies the In predicate on the "scenario" field.
|
||||||
func ScenarioIn(vs ...string) predicate.Alert {
|
func ScenarioIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldScenario), v...))
|
s.Where(sql.In(s.C(FieldScenario), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScenarioNotIn applies the NotIn predicate on the "scenario" field.
|
// ScenarioNotIn applies the NotIn predicate on the "scenario" field.
|
||||||
func ScenarioNotIn(vs ...string) predicate.Alert {
|
func ScenarioNotIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldScenario), v...))
|
s.Where(sql.NotIn(s.C(FieldScenario), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -554,34 +506,22 @@ func BucketIdNEQ(v string) predicate.Alert {
|
||||||
|
|
||||||
// BucketIdIn applies the In predicate on the "bucketId" field.
|
// BucketIdIn applies the In predicate on the "bucketId" field.
|
||||||
func BucketIdIn(vs ...string) predicate.Alert {
|
func BucketIdIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldBucketId), v...))
|
s.Where(sql.In(s.C(FieldBucketId), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// BucketIdNotIn applies the NotIn predicate on the "bucketId" field.
|
// BucketIdNotIn applies the NotIn predicate on the "bucketId" field.
|
||||||
func BucketIdNotIn(vs ...string) predicate.Alert {
|
func BucketIdNotIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldBucketId), v...))
|
s.Where(sql.NotIn(s.C(FieldBucketId), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -679,34 +619,22 @@ func MessageNEQ(v string) predicate.Alert {
|
||||||
|
|
||||||
// MessageIn applies the In predicate on the "message" field.
|
// MessageIn applies the In predicate on the "message" field.
|
||||||
func MessageIn(vs ...string) predicate.Alert {
|
func MessageIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldMessage), v...))
|
s.Where(sql.In(s.C(FieldMessage), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// MessageNotIn applies the NotIn predicate on the "message" field.
|
// MessageNotIn applies the NotIn predicate on the "message" field.
|
||||||
func MessageNotIn(vs ...string) predicate.Alert {
|
func MessageNotIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldMessage), v...))
|
s.Where(sql.NotIn(s.C(FieldMessage), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -804,34 +732,22 @@ func EventsCountNEQ(v int32) predicate.Alert {
|
||||||
|
|
||||||
// EventsCountIn applies the In predicate on the "eventsCount" field.
|
// EventsCountIn applies the In predicate on the "eventsCount" field.
|
||||||
func EventsCountIn(vs ...int32) predicate.Alert {
|
func EventsCountIn(vs ...int32) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldEventsCount), v...))
|
s.Where(sql.In(s.C(FieldEventsCount), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// EventsCountNotIn applies the NotIn predicate on the "eventsCount" field.
|
// EventsCountNotIn applies the NotIn predicate on the "eventsCount" field.
|
||||||
func EventsCountNotIn(vs ...int32) predicate.Alert {
|
func EventsCountNotIn(vs ...int32) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldEventsCount), v...))
|
s.Where(sql.NotIn(s.C(FieldEventsCount), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -894,34 +810,22 @@ func StartedAtNEQ(v time.Time) predicate.Alert {
|
||||||
|
|
||||||
// StartedAtIn applies the In predicate on the "startedAt" field.
|
// StartedAtIn applies the In predicate on the "startedAt" field.
|
||||||
func StartedAtIn(vs ...time.Time) predicate.Alert {
|
func StartedAtIn(vs ...time.Time) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldStartedAt), v...))
|
s.Where(sql.In(s.C(FieldStartedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartedAtNotIn applies the NotIn predicate on the "startedAt" field.
|
// StartedAtNotIn applies the NotIn predicate on the "startedAt" field.
|
||||||
func StartedAtNotIn(vs ...time.Time) predicate.Alert {
|
func StartedAtNotIn(vs ...time.Time) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldStartedAt), v...))
|
s.Where(sql.NotIn(s.C(FieldStartedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -984,34 +888,22 @@ func StoppedAtNEQ(v time.Time) predicate.Alert {
|
||||||
|
|
||||||
// StoppedAtIn applies the In predicate on the "stoppedAt" field.
|
// StoppedAtIn applies the In predicate on the "stoppedAt" field.
|
||||||
func StoppedAtIn(vs ...time.Time) predicate.Alert {
|
func StoppedAtIn(vs ...time.Time) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldStoppedAt), v...))
|
s.Where(sql.In(s.C(FieldStoppedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// StoppedAtNotIn applies the NotIn predicate on the "stoppedAt" field.
|
// StoppedAtNotIn applies the NotIn predicate on the "stoppedAt" field.
|
||||||
func StoppedAtNotIn(vs ...time.Time) predicate.Alert {
|
func StoppedAtNotIn(vs ...time.Time) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldStoppedAt), v...))
|
s.Where(sql.NotIn(s.C(FieldStoppedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1074,34 +966,22 @@ func SourceIpNEQ(v string) predicate.Alert {
|
||||||
|
|
||||||
// SourceIpIn applies the In predicate on the "sourceIp" field.
|
// SourceIpIn applies the In predicate on the "sourceIp" field.
|
||||||
func SourceIpIn(vs ...string) predicate.Alert {
|
func SourceIpIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldSourceIp), v...))
|
s.Where(sql.In(s.C(FieldSourceIp), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SourceIpNotIn applies the NotIn predicate on the "sourceIp" field.
|
// SourceIpNotIn applies the NotIn predicate on the "sourceIp" field.
|
||||||
func SourceIpNotIn(vs ...string) predicate.Alert {
|
func SourceIpNotIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldSourceIp), v...))
|
s.Where(sql.NotIn(s.C(FieldSourceIp), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1199,34 +1079,22 @@ func SourceRangeNEQ(v string) predicate.Alert {
|
||||||
|
|
||||||
// SourceRangeIn applies the In predicate on the "sourceRange" field.
|
// SourceRangeIn applies the In predicate on the "sourceRange" field.
|
||||||
func SourceRangeIn(vs ...string) predicate.Alert {
|
func SourceRangeIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldSourceRange), v...))
|
s.Where(sql.In(s.C(FieldSourceRange), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SourceRangeNotIn applies the NotIn predicate on the "sourceRange" field.
|
// SourceRangeNotIn applies the NotIn predicate on the "sourceRange" field.
|
||||||
func SourceRangeNotIn(vs ...string) predicate.Alert {
|
func SourceRangeNotIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldSourceRange), v...))
|
s.Where(sql.NotIn(s.C(FieldSourceRange), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1324,34 +1192,22 @@ func SourceAsNumberNEQ(v string) predicate.Alert {
|
||||||
|
|
||||||
// SourceAsNumberIn applies the In predicate on the "sourceAsNumber" field.
|
// SourceAsNumberIn applies the In predicate on the "sourceAsNumber" field.
|
||||||
func SourceAsNumberIn(vs ...string) predicate.Alert {
|
func SourceAsNumberIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldSourceAsNumber), v...))
|
s.Where(sql.In(s.C(FieldSourceAsNumber), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SourceAsNumberNotIn applies the NotIn predicate on the "sourceAsNumber" field.
|
// SourceAsNumberNotIn applies the NotIn predicate on the "sourceAsNumber" field.
|
||||||
func SourceAsNumberNotIn(vs ...string) predicate.Alert {
|
func SourceAsNumberNotIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldSourceAsNumber), v...))
|
s.Where(sql.NotIn(s.C(FieldSourceAsNumber), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1449,34 +1305,22 @@ func SourceAsNameNEQ(v string) predicate.Alert {
|
||||||
|
|
||||||
// SourceAsNameIn applies the In predicate on the "sourceAsName" field.
|
// SourceAsNameIn applies the In predicate on the "sourceAsName" field.
|
||||||
func SourceAsNameIn(vs ...string) predicate.Alert {
|
func SourceAsNameIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldSourceAsName), v...))
|
s.Where(sql.In(s.C(FieldSourceAsName), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SourceAsNameNotIn applies the NotIn predicate on the "sourceAsName" field.
|
// SourceAsNameNotIn applies the NotIn predicate on the "sourceAsName" field.
|
||||||
func SourceAsNameNotIn(vs ...string) predicate.Alert {
|
func SourceAsNameNotIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldSourceAsName), v...))
|
s.Where(sql.NotIn(s.C(FieldSourceAsName), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1574,34 +1418,22 @@ func SourceCountryNEQ(v string) predicate.Alert {
|
||||||
|
|
||||||
// SourceCountryIn applies the In predicate on the "sourceCountry" field.
|
// SourceCountryIn applies the In predicate on the "sourceCountry" field.
|
||||||
func SourceCountryIn(vs ...string) predicate.Alert {
|
func SourceCountryIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldSourceCountry), v...))
|
s.Where(sql.In(s.C(FieldSourceCountry), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SourceCountryNotIn applies the NotIn predicate on the "sourceCountry" field.
|
// SourceCountryNotIn applies the NotIn predicate on the "sourceCountry" field.
|
||||||
func SourceCountryNotIn(vs ...string) predicate.Alert {
|
func SourceCountryNotIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldSourceCountry), v...))
|
s.Where(sql.NotIn(s.C(FieldSourceCountry), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1699,34 +1531,22 @@ func SourceLatitudeNEQ(v float32) predicate.Alert {
|
||||||
|
|
||||||
// SourceLatitudeIn applies the In predicate on the "sourceLatitude" field.
|
// SourceLatitudeIn applies the In predicate on the "sourceLatitude" field.
|
||||||
func SourceLatitudeIn(vs ...float32) predicate.Alert {
|
func SourceLatitudeIn(vs ...float32) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldSourceLatitude), v...))
|
s.Where(sql.In(s.C(FieldSourceLatitude), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SourceLatitudeNotIn applies the NotIn predicate on the "sourceLatitude" field.
|
// SourceLatitudeNotIn applies the NotIn predicate on the "sourceLatitude" field.
|
||||||
func SourceLatitudeNotIn(vs ...float32) predicate.Alert {
|
func SourceLatitudeNotIn(vs ...float32) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldSourceLatitude), v...))
|
s.Where(sql.NotIn(s.C(FieldSourceLatitude), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1789,34 +1609,22 @@ func SourceLongitudeNEQ(v float32) predicate.Alert {
|
||||||
|
|
||||||
// SourceLongitudeIn applies the In predicate on the "sourceLongitude" field.
|
// SourceLongitudeIn applies the In predicate on the "sourceLongitude" field.
|
||||||
func SourceLongitudeIn(vs ...float32) predicate.Alert {
|
func SourceLongitudeIn(vs ...float32) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldSourceLongitude), v...))
|
s.Where(sql.In(s.C(FieldSourceLongitude), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SourceLongitudeNotIn applies the NotIn predicate on the "sourceLongitude" field.
|
// SourceLongitudeNotIn applies the NotIn predicate on the "sourceLongitude" field.
|
||||||
func SourceLongitudeNotIn(vs ...float32) predicate.Alert {
|
func SourceLongitudeNotIn(vs ...float32) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldSourceLongitude), v...))
|
s.Where(sql.NotIn(s.C(FieldSourceLongitude), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1879,34 +1687,22 @@ func SourceScopeNEQ(v string) predicate.Alert {
|
||||||
|
|
||||||
// SourceScopeIn applies the In predicate on the "sourceScope" field.
|
// SourceScopeIn applies the In predicate on the "sourceScope" field.
|
||||||
func SourceScopeIn(vs ...string) predicate.Alert {
|
func SourceScopeIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldSourceScope), v...))
|
s.Where(sql.In(s.C(FieldSourceScope), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SourceScopeNotIn applies the NotIn predicate on the "sourceScope" field.
|
// SourceScopeNotIn applies the NotIn predicate on the "sourceScope" field.
|
||||||
func SourceScopeNotIn(vs ...string) predicate.Alert {
|
func SourceScopeNotIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldSourceScope), v...))
|
s.Where(sql.NotIn(s.C(FieldSourceScope), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -2004,34 +1800,22 @@ func SourceValueNEQ(v string) predicate.Alert {
|
||||||
|
|
||||||
// SourceValueIn applies the In predicate on the "sourceValue" field.
|
// SourceValueIn applies the In predicate on the "sourceValue" field.
|
||||||
func SourceValueIn(vs ...string) predicate.Alert {
|
func SourceValueIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldSourceValue), v...))
|
s.Where(sql.In(s.C(FieldSourceValue), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SourceValueNotIn applies the NotIn predicate on the "sourceValue" field.
|
// SourceValueNotIn applies the NotIn predicate on the "sourceValue" field.
|
||||||
func SourceValueNotIn(vs ...string) predicate.Alert {
|
func SourceValueNotIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldSourceValue), v...))
|
s.Where(sql.NotIn(s.C(FieldSourceValue), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -2129,34 +1913,22 @@ func CapacityNEQ(v int32) predicate.Alert {
|
||||||
|
|
||||||
// CapacityIn applies the In predicate on the "capacity" field.
|
// CapacityIn applies the In predicate on the "capacity" field.
|
||||||
func CapacityIn(vs ...int32) predicate.Alert {
|
func CapacityIn(vs ...int32) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldCapacity), v...))
|
s.Where(sql.In(s.C(FieldCapacity), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// CapacityNotIn applies the NotIn predicate on the "capacity" field.
|
// CapacityNotIn applies the NotIn predicate on the "capacity" field.
|
||||||
func CapacityNotIn(vs ...int32) predicate.Alert {
|
func CapacityNotIn(vs ...int32) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldCapacity), v...))
|
s.Where(sql.NotIn(s.C(FieldCapacity), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -2219,34 +1991,22 @@ func LeakSpeedNEQ(v string) predicate.Alert {
|
||||||
|
|
||||||
// LeakSpeedIn applies the In predicate on the "leakSpeed" field.
|
// LeakSpeedIn applies the In predicate on the "leakSpeed" field.
|
||||||
func LeakSpeedIn(vs ...string) predicate.Alert {
|
func LeakSpeedIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldLeakSpeed), v...))
|
s.Where(sql.In(s.C(FieldLeakSpeed), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// LeakSpeedNotIn applies the NotIn predicate on the "leakSpeed" field.
|
// LeakSpeedNotIn applies the NotIn predicate on the "leakSpeed" field.
|
||||||
func LeakSpeedNotIn(vs ...string) predicate.Alert {
|
func LeakSpeedNotIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldLeakSpeed), v...))
|
s.Where(sql.NotIn(s.C(FieldLeakSpeed), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -2344,34 +2104,22 @@ func ScenarioVersionNEQ(v string) predicate.Alert {
|
||||||
|
|
||||||
// ScenarioVersionIn applies the In predicate on the "scenarioVersion" field.
|
// ScenarioVersionIn applies the In predicate on the "scenarioVersion" field.
|
||||||
func ScenarioVersionIn(vs ...string) predicate.Alert {
|
func ScenarioVersionIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldScenarioVersion), v...))
|
s.Where(sql.In(s.C(FieldScenarioVersion), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScenarioVersionNotIn applies the NotIn predicate on the "scenarioVersion" field.
|
// ScenarioVersionNotIn applies the NotIn predicate on the "scenarioVersion" field.
|
||||||
func ScenarioVersionNotIn(vs ...string) predicate.Alert {
|
func ScenarioVersionNotIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldScenarioVersion), v...))
|
s.Where(sql.NotIn(s.C(FieldScenarioVersion), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -2469,34 +2217,22 @@ func ScenarioHashNEQ(v string) predicate.Alert {
|
||||||
|
|
||||||
// ScenarioHashIn applies the In predicate on the "scenarioHash" field.
|
// ScenarioHashIn applies the In predicate on the "scenarioHash" field.
|
||||||
func ScenarioHashIn(vs ...string) predicate.Alert {
|
func ScenarioHashIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldScenarioHash), v...))
|
s.Where(sql.In(s.C(FieldScenarioHash), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScenarioHashNotIn applies the NotIn predicate on the "scenarioHash" field.
|
// ScenarioHashNotIn applies the NotIn predicate on the "scenarioHash" field.
|
||||||
func ScenarioHashNotIn(vs ...string) predicate.Alert {
|
func ScenarioHashNotIn(vs ...string) predicate.Alert {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Alert(func(s *sql.Selector) {
|
return predicate.Alert(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldScenarioHash), v...))
|
s.Where(sql.NotIn(s.C(FieldScenarioHash), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -428,9 +428,15 @@ func (ac *AlertCreate) Save(ctx context.Context) (*Alert, error) {
|
||||||
}
|
}
|
||||||
mut = ac.hooks[i](mut)
|
mut = ac.hooks[i](mut)
|
||||||
}
|
}
|
||||||
if _, err := mut.Mutate(ctx, ac.mutation); err != nil {
|
v, err := mut.Mutate(ctx, ac.mutation)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
nv, ok := v.(*Alert)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected node type %T returned from AlertMutation", v)
|
||||||
|
}
|
||||||
|
node = nv
|
||||||
}
|
}
|
||||||
return node, err
|
return node, err
|
||||||
}
|
}
|
||||||
|
@ -508,7 +514,7 @@ func (ac *AlertCreate) sqlSave(ctx context.Context) (*Alert, error) {
|
||||||
_node, _spec := ac.createSpec()
|
_node, _spec := ac.createSpec()
|
||||||
if err := sqlgraph.CreateNode(ctx, ac.driver, _spec); err != nil {
|
if err := sqlgraph.CreateNode(ctx, ac.driver, _spec); err != nil {
|
||||||
if sqlgraph.IsConstraintError(err) {
|
if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -817,7 +823,7 @@ func (acb *AlertCreateBulk) Save(ctx context.Context) ([]*Alert, error) {
|
||||||
// Invoke the actual operation on the latest mutation in the chain.
|
// Invoke the actual operation on the latest mutation in the chain.
|
||||||
if err = sqlgraph.BatchCreate(ctx, acb.driver, spec); err != nil {
|
if err = sqlgraph.BatchCreate(ctx, acb.driver, spec); err != nil {
|
||||||
if sqlgraph.IsConstraintError(err) {
|
if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -825,11 +831,11 @@ func (acb *AlertCreateBulk) Save(ctx context.Context) ([]*Alert, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
mutation.id = &nodes[i].ID
|
mutation.id = &nodes[i].ID
|
||||||
mutation.done = true
|
|
||||||
if specs[i].ID.Value != nil {
|
if specs[i].ID.Value != nil {
|
||||||
id := specs[i].ID.Value.(int64)
|
id := specs[i].ID.Value.(int64)
|
||||||
nodes[i].ID = int(id)
|
nodes[i].ID = int(id)
|
||||||
}
|
}
|
||||||
|
mutation.done = true
|
||||||
return nodes[i], nil
|
return nodes[i], nil
|
||||||
})
|
})
|
||||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -84,7 +84,11 @@ func (ad *AlertDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sqlgraph.DeleteNodes(ctx, ad.driver, _spec)
|
affected, err := sqlgraph.DeleteNodes(ctx, ad.driver, _spec)
|
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return affected, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// AlertDeleteOne is the builder for deleting a single Alert entity.
|
// AlertDeleteOne is the builder for deleting a single Alert entity.
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
|
@ -23,13 +22,12 @@ import (
|
||||||
// AlertQuery is the builder for querying Alert entities.
|
// AlertQuery is the builder for querying Alert entities.
|
||||||
type AlertQuery struct {
|
type AlertQuery struct {
|
||||||
config
|
config
|
||||||
limit *int
|
limit *int
|
||||||
offset *int
|
offset *int
|
||||||
unique *bool
|
unique *bool
|
||||||
order []OrderFunc
|
order []OrderFunc
|
||||||
fields []string
|
fields []string
|
||||||
predicates []predicate.Alert
|
predicates []predicate.Alert
|
||||||
// eager-loading edges.
|
|
||||||
withOwner *MachineQuery
|
withOwner *MachineQuery
|
||||||
withDecisions *DecisionQuery
|
withDecisions *DecisionQuery
|
||||||
withEvents *EventQuery
|
withEvents *EventQuery
|
||||||
|
@ -409,17 +407,18 @@ func (aq *AlertQuery) WithMetas(opts ...func(*MetaQuery)) *AlertQuery {
|
||||||
// GroupBy(alert.FieldCreatedAt).
|
// GroupBy(alert.FieldCreatedAt).
|
||||||
// Aggregate(ent.Count()).
|
// Aggregate(ent.Count()).
|
||||||
// Scan(ctx, &v)
|
// Scan(ctx, &v)
|
||||||
//
|
|
||||||
func (aq *AlertQuery) GroupBy(field string, fields ...string) *AlertGroupBy {
|
func (aq *AlertQuery) GroupBy(field string, fields ...string) *AlertGroupBy {
|
||||||
group := &AlertGroupBy{config: aq.config}
|
grbuild := &AlertGroupBy{config: aq.config}
|
||||||
group.fields = append([]string{field}, fields...)
|
grbuild.fields = append([]string{field}, fields...)
|
||||||
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
||||||
if err := aq.prepareQuery(ctx); err != nil {
|
if err := aq.prepareQuery(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return aq.sqlQuery(ctx), nil
|
return aq.sqlQuery(ctx), nil
|
||||||
}
|
}
|
||||||
return group
|
grbuild.label = alert.Label
|
||||||
|
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan
|
||||||
|
return grbuild
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select allows the selection one or more fields/columns for the given query,
|
// Select allows the selection one or more fields/columns for the given query,
|
||||||
|
@ -434,10 +433,12 @@ func (aq *AlertQuery) GroupBy(field string, fields ...string) *AlertGroupBy {
|
||||||
// client.Alert.Query().
|
// client.Alert.Query().
|
||||||
// Select(alert.FieldCreatedAt).
|
// Select(alert.FieldCreatedAt).
|
||||||
// Scan(ctx, &v)
|
// Scan(ctx, &v)
|
||||||
//
|
|
||||||
func (aq *AlertQuery) Select(fields ...string) *AlertSelect {
|
func (aq *AlertQuery) Select(fields ...string) *AlertSelect {
|
||||||
aq.fields = append(aq.fields, fields...)
|
aq.fields = append(aq.fields, fields...)
|
||||||
return &AlertSelect{AlertQuery: aq}
|
selbuild := &AlertSelect{AlertQuery: aq}
|
||||||
|
selbuild.label = alert.Label
|
||||||
|
selbuild.flds, selbuild.scan = &aq.fields, selbuild.Scan
|
||||||
|
return selbuild
|
||||||
}
|
}
|
||||||
|
|
||||||
func (aq *AlertQuery) prepareQuery(ctx context.Context) error {
|
func (aq *AlertQuery) prepareQuery(ctx context.Context) error {
|
||||||
|
@ -456,7 +457,7 @@ func (aq *AlertQuery) prepareQuery(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (aq *AlertQuery) sqlAll(ctx context.Context) ([]*Alert, error) {
|
func (aq *AlertQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Alert, error) {
|
||||||
var (
|
var (
|
||||||
nodes = []*Alert{}
|
nodes = []*Alert{}
|
||||||
withFKs = aq.withFKs
|
withFKs = aq.withFKs
|
||||||
|
@ -474,143 +475,175 @@ func (aq *AlertQuery) sqlAll(ctx context.Context) ([]*Alert, error) {
|
||||||
if withFKs {
|
if withFKs {
|
||||||
_spec.Node.Columns = append(_spec.Node.Columns, alert.ForeignKeys...)
|
_spec.Node.Columns = append(_spec.Node.Columns, alert.ForeignKeys...)
|
||||||
}
|
}
|
||||||
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
return (*Alert).scanValues(nil, columns)
|
||||||
|
}
|
||||||
|
_spec.Assign = func(columns []string, values []any) error {
|
||||||
node := &Alert{config: aq.config}
|
node := &Alert{config: aq.config}
|
||||||
nodes = append(nodes, node)
|
nodes = append(nodes, node)
|
||||||
return node.scanValues(columns)
|
|
||||||
}
|
|
||||||
_spec.Assign = func(columns []string, values []interface{}) error {
|
|
||||||
if len(nodes) == 0 {
|
|
||||||
return fmt.Errorf("ent: Assign called without calling ScanValues")
|
|
||||||
}
|
|
||||||
node := nodes[len(nodes)-1]
|
|
||||||
node.Edges.loadedTypes = loadedTypes
|
node.Edges.loadedTypes = loadedTypes
|
||||||
return node.assignValues(columns, values)
|
return node.assignValues(columns, values)
|
||||||
}
|
}
|
||||||
|
for i := range hooks {
|
||||||
|
hooks[i](ctx, _spec)
|
||||||
|
}
|
||||||
if err := sqlgraph.QueryNodes(ctx, aq.driver, _spec); err != nil {
|
if err := sqlgraph.QueryNodes(ctx, aq.driver, _spec); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(nodes) == 0 {
|
if len(nodes) == 0 {
|
||||||
return nodes, nil
|
return nodes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if query := aq.withOwner; query != nil {
|
if query := aq.withOwner; query != nil {
|
||||||
ids := make([]int, 0, len(nodes))
|
if err := aq.loadOwner(ctx, query, nodes, nil,
|
||||||
nodeids := make(map[int][]*Alert)
|
func(n *Alert, e *Machine) { n.Edges.Owner = e }); err != nil {
|
||||||
for i := range nodes {
|
|
||||||
if nodes[i].machine_alerts == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
fk := *nodes[i].machine_alerts
|
|
||||||
if _, ok := nodeids[fk]; !ok {
|
|
||||||
ids = append(ids, fk)
|
|
||||||
}
|
|
||||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
|
||||||
}
|
|
||||||
query.Where(machine.IDIn(ids...))
|
|
||||||
neighbors, err := query.All(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, n := range neighbors {
|
|
||||||
nodes, ok := nodeids[n.ID]
|
|
||||||
if !ok {
|
|
||||||
return nil, fmt.Errorf(`unexpected foreign-key "machine_alerts" returned %v`, n.ID)
|
|
||||||
}
|
|
||||||
for i := range nodes {
|
|
||||||
nodes[i].Edges.Owner = n
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if query := aq.withDecisions; query != nil {
|
if query := aq.withDecisions; query != nil {
|
||||||
fks := make([]driver.Value, 0, len(nodes))
|
if err := aq.loadDecisions(ctx, query, nodes,
|
||||||
nodeids := make(map[int]*Alert)
|
func(n *Alert) { n.Edges.Decisions = []*Decision{} },
|
||||||
for i := range nodes {
|
func(n *Alert, e *Decision) { n.Edges.Decisions = append(n.Edges.Decisions, e) }); err != nil {
|
||||||
fks = append(fks, nodes[i].ID)
|
|
||||||
nodeids[nodes[i].ID] = nodes[i]
|
|
||||||
nodes[i].Edges.Decisions = []*Decision{}
|
|
||||||
}
|
|
||||||
query.withFKs = true
|
|
||||||
query.Where(predicate.Decision(func(s *sql.Selector) {
|
|
||||||
s.Where(sql.InValues(alert.DecisionsColumn, fks...))
|
|
||||||
}))
|
|
||||||
neighbors, err := query.All(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, n := range neighbors {
|
|
||||||
fk := n.alert_decisions
|
|
||||||
if fk == nil {
|
|
||||||
return nil, fmt.Errorf(`foreign-key "alert_decisions" is nil for node %v`, n.ID)
|
|
||||||
}
|
|
||||||
node, ok := nodeids[*fk]
|
|
||||||
if !ok {
|
|
||||||
return nil, fmt.Errorf(`unexpected foreign-key "alert_decisions" returned %v for node %v`, *fk, n.ID)
|
|
||||||
}
|
|
||||||
node.Edges.Decisions = append(node.Edges.Decisions, n)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if query := aq.withEvents; query != nil {
|
if query := aq.withEvents; query != nil {
|
||||||
fks := make([]driver.Value, 0, len(nodes))
|
if err := aq.loadEvents(ctx, query, nodes,
|
||||||
nodeids := make(map[int]*Alert)
|
func(n *Alert) { n.Edges.Events = []*Event{} },
|
||||||
for i := range nodes {
|
func(n *Alert, e *Event) { n.Edges.Events = append(n.Edges.Events, e) }); err != nil {
|
||||||
fks = append(fks, nodes[i].ID)
|
|
||||||
nodeids[nodes[i].ID] = nodes[i]
|
|
||||||
nodes[i].Edges.Events = []*Event{}
|
|
||||||
}
|
|
||||||
query.withFKs = true
|
|
||||||
query.Where(predicate.Event(func(s *sql.Selector) {
|
|
||||||
s.Where(sql.InValues(alert.EventsColumn, fks...))
|
|
||||||
}))
|
|
||||||
neighbors, err := query.All(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, n := range neighbors {
|
|
||||||
fk := n.alert_events
|
|
||||||
if fk == nil {
|
|
||||||
return nil, fmt.Errorf(`foreign-key "alert_events" is nil for node %v`, n.ID)
|
|
||||||
}
|
|
||||||
node, ok := nodeids[*fk]
|
|
||||||
if !ok {
|
|
||||||
return nil, fmt.Errorf(`unexpected foreign-key "alert_events" returned %v for node %v`, *fk, n.ID)
|
|
||||||
}
|
|
||||||
node.Edges.Events = append(node.Edges.Events, n)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if query := aq.withMetas; query != nil {
|
if query := aq.withMetas; query != nil {
|
||||||
fks := make([]driver.Value, 0, len(nodes))
|
if err := aq.loadMetas(ctx, query, nodes,
|
||||||
nodeids := make(map[int]*Alert)
|
func(n *Alert) { n.Edges.Metas = []*Meta{} },
|
||||||
for i := range nodes {
|
func(n *Alert, e *Meta) { n.Edges.Metas = append(n.Edges.Metas, e) }); err != nil {
|
||||||
fks = append(fks, nodes[i].ID)
|
|
||||||
nodeids[nodes[i].ID] = nodes[i]
|
|
||||||
nodes[i].Edges.Metas = []*Meta{}
|
|
||||||
}
|
|
||||||
query.withFKs = true
|
|
||||||
query.Where(predicate.Meta(func(s *sql.Selector) {
|
|
||||||
s.Where(sql.InValues(alert.MetasColumn, fks...))
|
|
||||||
}))
|
|
||||||
neighbors, err := query.All(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, n := range neighbors {
|
}
|
||||||
fk := n.alert_metas
|
return nodes, nil
|
||||||
if fk == nil {
|
}
|
||||||
return nil, fmt.Errorf(`foreign-key "alert_metas" is nil for node %v`, n.ID)
|
|
||||||
}
|
func (aq *AlertQuery) loadOwner(ctx context.Context, query *MachineQuery, nodes []*Alert, init func(*Alert), assign func(*Alert, *Machine)) error {
|
||||||
node, ok := nodeids[*fk]
|
ids := make([]int, 0, len(nodes))
|
||||||
if !ok {
|
nodeids := make(map[int][]*Alert)
|
||||||
return nil, fmt.Errorf(`unexpected foreign-key "alert_metas" returned %v for node %v`, *fk, n.ID)
|
for i := range nodes {
|
||||||
}
|
if nodes[i].machine_alerts == nil {
|
||||||
node.Edges.Metas = append(node.Edges.Metas, n)
|
continue
|
||||||
|
}
|
||||||
|
fk := *nodes[i].machine_alerts
|
||||||
|
if _, ok := nodeids[fk]; !ok {
|
||||||
|
ids = append(ids, fk)
|
||||||
|
}
|
||||||
|
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||||
|
}
|
||||||
|
query.Where(machine.IDIn(ids...))
|
||||||
|
neighbors, err := query.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, n := range neighbors {
|
||||||
|
nodes, ok := nodeids[n.ID]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(`unexpected foreign-key "machine_alerts" returned %v`, n.ID)
|
||||||
|
}
|
||||||
|
for i := range nodes {
|
||||||
|
assign(nodes[i], n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
return nodes, nil
|
}
|
||||||
|
func (aq *AlertQuery) loadDecisions(ctx context.Context, query *DecisionQuery, nodes []*Alert, init func(*Alert), assign func(*Alert, *Decision)) error {
|
||||||
|
fks := make([]driver.Value, 0, len(nodes))
|
||||||
|
nodeids := make(map[int]*Alert)
|
||||||
|
for i := range nodes {
|
||||||
|
fks = append(fks, nodes[i].ID)
|
||||||
|
nodeids[nodes[i].ID] = nodes[i]
|
||||||
|
if init != nil {
|
||||||
|
init(nodes[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
query.withFKs = true
|
||||||
|
query.Where(predicate.Decision(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.InValues(alert.DecisionsColumn, fks...))
|
||||||
|
}))
|
||||||
|
neighbors, err := query.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, n := range neighbors {
|
||||||
|
fk := n.alert_decisions
|
||||||
|
if fk == nil {
|
||||||
|
return fmt.Errorf(`foreign-key "alert_decisions" is nil for node %v`, n.ID)
|
||||||
|
}
|
||||||
|
node, ok := nodeids[*fk]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(`unexpected foreign-key "alert_decisions" returned %v for node %v`, *fk, n.ID)
|
||||||
|
}
|
||||||
|
assign(node, n)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (aq *AlertQuery) loadEvents(ctx context.Context, query *EventQuery, nodes []*Alert, init func(*Alert), assign func(*Alert, *Event)) error {
|
||||||
|
fks := make([]driver.Value, 0, len(nodes))
|
||||||
|
nodeids := make(map[int]*Alert)
|
||||||
|
for i := range nodes {
|
||||||
|
fks = append(fks, nodes[i].ID)
|
||||||
|
nodeids[nodes[i].ID] = nodes[i]
|
||||||
|
if init != nil {
|
||||||
|
init(nodes[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
query.withFKs = true
|
||||||
|
query.Where(predicate.Event(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.InValues(alert.EventsColumn, fks...))
|
||||||
|
}))
|
||||||
|
neighbors, err := query.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, n := range neighbors {
|
||||||
|
fk := n.alert_events
|
||||||
|
if fk == nil {
|
||||||
|
return fmt.Errorf(`foreign-key "alert_events" is nil for node %v`, n.ID)
|
||||||
|
}
|
||||||
|
node, ok := nodeids[*fk]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(`unexpected foreign-key "alert_events" returned %v for node %v`, *fk, n.ID)
|
||||||
|
}
|
||||||
|
assign(node, n)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (aq *AlertQuery) loadMetas(ctx context.Context, query *MetaQuery, nodes []*Alert, init func(*Alert), assign func(*Alert, *Meta)) error {
|
||||||
|
fks := make([]driver.Value, 0, len(nodes))
|
||||||
|
nodeids := make(map[int]*Alert)
|
||||||
|
for i := range nodes {
|
||||||
|
fks = append(fks, nodes[i].ID)
|
||||||
|
nodeids[nodes[i].ID] = nodes[i]
|
||||||
|
if init != nil {
|
||||||
|
init(nodes[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
query.withFKs = true
|
||||||
|
query.Where(predicate.Meta(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.InValues(alert.MetasColumn, fks...))
|
||||||
|
}))
|
||||||
|
neighbors, err := query.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, n := range neighbors {
|
||||||
|
fk := n.alert_metas
|
||||||
|
if fk == nil {
|
||||||
|
return fmt.Errorf(`foreign-key "alert_metas" is nil for node %v`, n.ID)
|
||||||
|
}
|
||||||
|
node, ok := nodeids[*fk]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(`unexpected foreign-key "alert_metas" returned %v for node %v`, *fk, n.ID)
|
||||||
|
}
|
||||||
|
assign(node, n)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (aq *AlertQuery) sqlCount(ctx context.Context) (int, error) {
|
func (aq *AlertQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
|
@ -623,11 +656,14 @@ func (aq *AlertQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (aq *AlertQuery) sqlExist(ctx context.Context) (bool, error) {
|
func (aq *AlertQuery) sqlExist(ctx context.Context) (bool, error) {
|
||||||
n, err := aq.sqlCount(ctx)
|
switch _, err := aq.FirstID(ctx); {
|
||||||
if err != nil {
|
case IsNotFound(err):
|
||||||
|
return false, nil
|
||||||
|
case err != nil:
|
||||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||||
|
default:
|
||||||
|
return true, nil
|
||||||
}
|
}
|
||||||
return n > 0, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (aq *AlertQuery) querySpec() *sqlgraph.QuerySpec {
|
func (aq *AlertQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
|
@ -713,6 +749,7 @@ func (aq *AlertQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||||
// AlertGroupBy is the group-by builder for Alert entities.
|
// AlertGroupBy is the group-by builder for Alert entities.
|
||||||
type AlertGroupBy struct {
|
type AlertGroupBy struct {
|
||||||
config
|
config
|
||||||
|
selector
|
||||||
fields []string
|
fields []string
|
||||||
fns []AggregateFunc
|
fns []AggregateFunc
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
|
@ -727,7 +764,7 @@ func (agb *AlertGroupBy) Aggregate(fns ...AggregateFunc) *AlertGroupBy {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan applies the group-by query and scans the result into the given value.
|
// Scan applies the group-by query and scans the result into the given value.
|
||||||
func (agb *AlertGroupBy) Scan(ctx context.Context, v interface{}) error {
|
func (agb *AlertGroupBy) Scan(ctx context.Context, v any) error {
|
||||||
query, err := agb.path(ctx)
|
query, err := agb.path(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -736,210 +773,7 @@ func (agb *AlertGroupBy) Scan(ctx context.Context, v interface{}) error {
|
||||||
return agb.sqlScan(ctx, v)
|
return agb.sqlScan(ctx, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScanX is like Scan, but panics if an error occurs.
|
func (agb *AlertGroupBy) sqlScan(ctx context.Context, v any) error {
|
||||||
func (agb *AlertGroupBy) ScanX(ctx context.Context, v interface{}) {
|
|
||||||
if err := agb.Scan(ctx, v); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strings returns list of strings from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (agb *AlertGroupBy) Strings(ctx context.Context) ([]string, error) {
|
|
||||||
if len(agb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: AlertGroupBy.Strings is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []string
|
|
||||||
if err := agb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringsX is like Strings, but panics if an error occurs.
|
|
||||||
func (agb *AlertGroupBy) StringsX(ctx context.Context) []string {
|
|
||||||
v, err := agb.Strings(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns a single string from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (agb *AlertGroupBy) String(ctx context.Context) (_ string, err error) {
|
|
||||||
var v []string
|
|
||||||
if v, err = agb.Strings(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{alert.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: AlertGroupBy.Strings returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringX is like String, but panics if an error occurs.
|
|
||||||
func (agb *AlertGroupBy) StringX(ctx context.Context) string {
|
|
||||||
v, err := agb.String(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ints returns list of ints from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (agb *AlertGroupBy) Ints(ctx context.Context) ([]int, error) {
|
|
||||||
if len(agb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: AlertGroupBy.Ints is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []int
|
|
||||||
if err := agb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntsX is like Ints, but panics if an error occurs.
|
|
||||||
func (agb *AlertGroupBy) IntsX(ctx context.Context) []int {
|
|
||||||
v, err := agb.Ints(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int returns a single int from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (agb *AlertGroupBy) Int(ctx context.Context) (_ int, err error) {
|
|
||||||
var v []int
|
|
||||||
if v, err = agb.Ints(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{alert.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: AlertGroupBy.Ints returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntX is like Int, but panics if an error occurs.
|
|
||||||
func (agb *AlertGroupBy) IntX(ctx context.Context) int {
|
|
||||||
v, err := agb.Int(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64s returns list of float64s from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (agb *AlertGroupBy) Float64s(ctx context.Context) ([]float64, error) {
|
|
||||||
if len(agb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: AlertGroupBy.Float64s is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []float64
|
|
||||||
if err := agb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64sX is like Float64s, but panics if an error occurs.
|
|
||||||
func (agb *AlertGroupBy) Float64sX(ctx context.Context) []float64 {
|
|
||||||
v, err := agb.Float64s(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64 returns a single float64 from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (agb *AlertGroupBy) Float64(ctx context.Context) (_ float64, err error) {
|
|
||||||
var v []float64
|
|
||||||
if v, err = agb.Float64s(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{alert.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: AlertGroupBy.Float64s returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64X is like Float64, but panics if an error occurs.
|
|
||||||
func (agb *AlertGroupBy) Float64X(ctx context.Context) float64 {
|
|
||||||
v, err := agb.Float64(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bools returns list of bools from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (agb *AlertGroupBy) Bools(ctx context.Context) ([]bool, error) {
|
|
||||||
if len(agb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: AlertGroupBy.Bools is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []bool
|
|
||||||
if err := agb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolsX is like Bools, but panics if an error occurs.
|
|
||||||
func (agb *AlertGroupBy) BoolsX(ctx context.Context) []bool {
|
|
||||||
v, err := agb.Bools(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bool returns a single bool from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (agb *AlertGroupBy) Bool(ctx context.Context) (_ bool, err error) {
|
|
||||||
var v []bool
|
|
||||||
if v, err = agb.Bools(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{alert.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: AlertGroupBy.Bools returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolX is like Bool, but panics if an error occurs.
|
|
||||||
func (agb *AlertGroupBy) BoolX(ctx context.Context) bool {
|
|
||||||
v, err := agb.Bool(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
func (agb *AlertGroupBy) sqlScan(ctx context.Context, v interface{}) error {
|
|
||||||
for _, f := range agb.fields {
|
for _, f := range agb.fields {
|
||||||
if !alert.ValidColumn(f) {
|
if !alert.ValidColumn(f) {
|
||||||
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
|
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
|
||||||
|
@ -980,12 +814,13 @@ func (agb *AlertGroupBy) sqlQuery() *sql.Selector {
|
||||||
// AlertSelect is the builder for selecting fields of Alert entities.
|
// AlertSelect is the builder for selecting fields of Alert entities.
|
||||||
type AlertSelect struct {
|
type AlertSelect struct {
|
||||||
*AlertQuery
|
*AlertQuery
|
||||||
|
selector
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
sql *sql.Selector
|
sql *sql.Selector
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan applies the selector query and scans the result into the given value.
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
func (as *AlertSelect) Scan(ctx context.Context, v interface{}) error {
|
func (as *AlertSelect) Scan(ctx context.Context, v any) error {
|
||||||
if err := as.prepareQuery(ctx); err != nil {
|
if err := as.prepareQuery(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -993,202 +828,7 @@ func (as *AlertSelect) Scan(ctx context.Context, v interface{}) error {
|
||||||
return as.sqlScan(ctx, v)
|
return as.sqlScan(ctx, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScanX is like Scan, but panics if an error occurs.
|
func (as *AlertSelect) sqlScan(ctx context.Context, v any) error {
|
||||||
func (as *AlertSelect) ScanX(ctx context.Context, v interface{}) {
|
|
||||||
if err := as.Scan(ctx, v); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
|
|
||||||
func (as *AlertSelect) Strings(ctx context.Context) ([]string, error) {
|
|
||||||
if len(as.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: AlertSelect.Strings is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []string
|
|
||||||
if err := as.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringsX is like Strings, but panics if an error occurs.
|
|
||||||
func (as *AlertSelect) StringsX(ctx context.Context) []string {
|
|
||||||
v, err := as.Strings(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns a single string from a selector. It is only allowed when selecting one field.
|
|
||||||
func (as *AlertSelect) String(ctx context.Context) (_ string, err error) {
|
|
||||||
var v []string
|
|
||||||
if v, err = as.Strings(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{alert.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: AlertSelect.Strings returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringX is like String, but panics if an error occurs.
|
|
||||||
func (as *AlertSelect) StringX(ctx context.Context) string {
|
|
||||||
v, err := as.String(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
|
|
||||||
func (as *AlertSelect) Ints(ctx context.Context) ([]int, error) {
|
|
||||||
if len(as.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: AlertSelect.Ints is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []int
|
|
||||||
if err := as.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntsX is like Ints, but panics if an error occurs.
|
|
||||||
func (as *AlertSelect) IntsX(ctx context.Context) []int {
|
|
||||||
v, err := as.Ints(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int returns a single int from a selector. It is only allowed when selecting one field.
|
|
||||||
func (as *AlertSelect) Int(ctx context.Context) (_ int, err error) {
|
|
||||||
var v []int
|
|
||||||
if v, err = as.Ints(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{alert.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: AlertSelect.Ints returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntX is like Int, but panics if an error occurs.
|
|
||||||
func (as *AlertSelect) IntX(ctx context.Context) int {
|
|
||||||
v, err := as.Int(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
|
|
||||||
func (as *AlertSelect) Float64s(ctx context.Context) ([]float64, error) {
|
|
||||||
if len(as.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: AlertSelect.Float64s is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []float64
|
|
||||||
if err := as.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64sX is like Float64s, but panics if an error occurs.
|
|
||||||
func (as *AlertSelect) Float64sX(ctx context.Context) []float64 {
|
|
||||||
v, err := as.Float64s(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
|
|
||||||
func (as *AlertSelect) Float64(ctx context.Context) (_ float64, err error) {
|
|
||||||
var v []float64
|
|
||||||
if v, err = as.Float64s(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{alert.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: AlertSelect.Float64s returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64X is like Float64, but panics if an error occurs.
|
|
||||||
func (as *AlertSelect) Float64X(ctx context.Context) float64 {
|
|
||||||
v, err := as.Float64(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
|
|
||||||
func (as *AlertSelect) Bools(ctx context.Context) ([]bool, error) {
|
|
||||||
if len(as.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: AlertSelect.Bools is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []bool
|
|
||||||
if err := as.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolsX is like Bools, but panics if an error occurs.
|
|
||||||
func (as *AlertSelect) BoolsX(ctx context.Context) []bool {
|
|
||||||
v, err := as.Bools(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
|
|
||||||
func (as *AlertSelect) Bool(ctx context.Context) (_ bool, err error) {
|
|
||||||
var v []bool
|
|
||||||
if v, err = as.Bools(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{alert.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: AlertSelect.Bools returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolX is like Bool, but panics if an error occurs.
|
|
||||||
func (as *AlertSelect) BoolX(ctx context.Context) bool {
|
|
||||||
v, err := as.Bool(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
func (as *AlertSelect) sqlScan(ctx context.Context, v interface{}) error {
|
|
||||||
rows := &sql.Rows{}
|
rows := &sql.Rows{}
|
||||||
query, args := as.sql.Query()
|
query, args := as.sql.Query()
|
||||||
if err := as.driver.Query(ctx, query, args, rows); err != nil {
|
if err := as.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -1190,7 +1190,7 @@ func (au *AlertUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
err = &NotFoundError{alert.Label}
|
err = &NotFoundError{alert.Label}
|
||||||
} else if sqlgraph.IsConstraintError(err) {
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -1808,9 +1808,15 @@ func (auo *AlertUpdateOne) Save(ctx context.Context) (*Alert, error) {
|
||||||
}
|
}
|
||||||
mut = auo.hooks[i](mut)
|
mut = auo.hooks[i](mut)
|
||||||
}
|
}
|
||||||
if _, err := mut.Mutate(ctx, auo.mutation); err != nil {
|
v, err := mut.Mutate(ctx, auo.mutation)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
nv, ok := v.(*Alert)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected node type %T returned from AlertMutation", v)
|
||||||
|
}
|
||||||
|
node = nv
|
||||||
}
|
}
|
||||||
return node, err
|
return node, err
|
||||||
}
|
}
|
||||||
|
@ -2390,7 +2396,7 @@ func (auo *AlertUpdateOne) sqlSave(ctx context.Context) (_node *Alert, err error
|
||||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
err = &NotFoundError{alert.Label}
|
err = &NotFoundError{alert.Label}
|
||||||
} else if sqlgraph.IsConstraintError(err) {
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ type Bouncer struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// scanValues returns the types for scanning values from sql.Rows.
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
func (*Bouncer) scanValues(columns []string) ([]interface{}, error) {
|
func (*Bouncer) scanValues(columns []string) ([]any, error) {
|
||||||
values := make([]interface{}, len(columns))
|
values := make([]any, len(columns))
|
||||||
for i := range columns {
|
for i := range columns {
|
||||||
switch columns[i] {
|
switch columns[i] {
|
||||||
case bouncer.FieldRevoked:
|
case bouncer.FieldRevoked:
|
||||||
|
@ -62,7 +62,7 @@ func (*Bouncer) scanValues(columns []string) ([]interface{}, error) {
|
||||||
|
|
||||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||||
// to the Bouncer fields.
|
// to the Bouncer fields.
|
||||||
func (b *Bouncer) assignValues(columns []string, values []interface{}) error {
|
func (b *Bouncer) assignValues(columns []string, values []any) error {
|
||||||
if m, n := len(values), len(columns); m < n {
|
if m, n := len(values), len(columns); m < n {
|
||||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||||
}
|
}
|
||||||
|
@ -157,11 +157,11 @@ func (b *Bouncer) Update() *BouncerUpdateOne {
|
||||||
// Unwrap unwraps the Bouncer entity that was returned from a transaction after it was closed,
|
// Unwrap unwraps the Bouncer entity that was returned from a transaction after it was closed,
|
||||||
// so that all future queries will be executed through the driver which created the transaction.
|
// so that all future queries will be executed through the driver which created the transaction.
|
||||||
func (b *Bouncer) Unwrap() *Bouncer {
|
func (b *Bouncer) Unwrap() *Bouncer {
|
||||||
tx, ok := b.config.driver.(*txDriver)
|
_tx, ok := b.config.driver.(*txDriver)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("ent: Bouncer is not a transactional entity")
|
panic("ent: Bouncer is not a transactional entity")
|
||||||
}
|
}
|
||||||
b.config.driver = tx.drv
|
b.config.driver = _tx.drv
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,32 +169,42 @@ func (b *Bouncer) Unwrap() *Bouncer {
|
||||||
func (b *Bouncer) String() string {
|
func (b *Bouncer) String() string {
|
||||||
var builder strings.Builder
|
var builder strings.Builder
|
||||||
builder.WriteString("Bouncer(")
|
builder.WriteString("Bouncer(")
|
||||||
builder.WriteString(fmt.Sprintf("id=%v", b.ID))
|
builder.WriteString(fmt.Sprintf("id=%v, ", b.ID))
|
||||||
if v := b.CreatedAt; v != nil {
|
if v := b.CreatedAt; v != nil {
|
||||||
builder.WriteString(", created_at=")
|
builder.WriteString("created_at=")
|
||||||
builder.WriteString(v.Format(time.ANSIC))
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
}
|
}
|
||||||
|
builder.WriteString(", ")
|
||||||
if v := b.UpdatedAt; v != nil {
|
if v := b.UpdatedAt; v != nil {
|
||||||
builder.WriteString(", updated_at=")
|
builder.WriteString("updated_at=")
|
||||||
builder.WriteString(v.Format(time.ANSIC))
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
}
|
}
|
||||||
builder.WriteString(", name=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("name=")
|
||||||
builder.WriteString(b.Name)
|
builder.WriteString(b.Name)
|
||||||
builder.WriteString(", api_key=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("api_key=")
|
||||||
builder.WriteString(b.APIKey)
|
builder.WriteString(b.APIKey)
|
||||||
builder.WriteString(", revoked=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("revoked=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", b.Revoked))
|
builder.WriteString(fmt.Sprintf("%v", b.Revoked))
|
||||||
builder.WriteString(", ip_address=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("ip_address=")
|
||||||
builder.WriteString(b.IPAddress)
|
builder.WriteString(b.IPAddress)
|
||||||
builder.WriteString(", type=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("type=")
|
||||||
builder.WriteString(b.Type)
|
builder.WriteString(b.Type)
|
||||||
builder.WriteString(", version=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("version=")
|
||||||
builder.WriteString(b.Version)
|
builder.WriteString(b.Version)
|
||||||
builder.WriteString(", until=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("until=")
|
||||||
builder.WriteString(b.Until.Format(time.ANSIC))
|
builder.WriteString(b.Until.Format(time.ANSIC))
|
||||||
builder.WriteString(", last_pull=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("last_pull=")
|
||||||
builder.WriteString(b.LastPull.Format(time.ANSIC))
|
builder.WriteString(b.LastPull.Format(time.ANSIC))
|
||||||
builder.WriteString(", auth_type=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("auth_type=")
|
||||||
builder.WriteString(b.AuthType)
|
builder.WriteString(b.AuthType)
|
||||||
builder.WriteByte(')')
|
builder.WriteByte(')')
|
||||||
return builder.String()
|
return builder.String()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package bouncer
|
package bouncer
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package bouncer
|
package bouncer
|
||||||
|
|
||||||
|
@ -33,13 +33,7 @@ func IDNEQ(id int) predicate.Bouncer {
|
||||||
// IDIn applies the In predicate on the ID field.
|
// IDIn applies the In predicate on the ID field.
|
||||||
func IDIn(ids ...int) predicate.Bouncer {
|
func IDIn(ids ...int) predicate.Bouncer {
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
v := make([]any, len(ids))
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(ids) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
v := make([]interface{}, len(ids))
|
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = ids[i]
|
v[i] = ids[i]
|
||||||
}
|
}
|
||||||
|
@ -50,13 +44,7 @@ func IDIn(ids ...int) predicate.Bouncer {
|
||||||
// IDNotIn applies the NotIn predicate on the ID field.
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
func IDNotIn(ids ...int) predicate.Bouncer {
|
func IDNotIn(ids ...int) predicate.Bouncer {
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
v := make([]any, len(ids))
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(ids) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
v := make([]interface{}, len(ids))
|
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = ids[i]
|
v[i] = ids[i]
|
||||||
}
|
}
|
||||||
|
@ -185,34 +173,22 @@ func CreatedAtNEQ(v time.Time) predicate.Bouncer {
|
||||||
|
|
||||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||||
func CreatedAtIn(vs ...time.Time) predicate.Bouncer {
|
func CreatedAtIn(vs ...time.Time) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldCreatedAt), v...))
|
s.Where(sql.In(s.C(FieldCreatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||||
func CreatedAtNotIn(vs ...time.Time) predicate.Bouncer {
|
func CreatedAtNotIn(vs ...time.Time) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
|
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -275,34 +251,22 @@ func UpdatedAtNEQ(v time.Time) predicate.Bouncer {
|
||||||
|
|
||||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||||
func UpdatedAtIn(vs ...time.Time) predicate.Bouncer {
|
func UpdatedAtIn(vs ...time.Time) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
|
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||||
func UpdatedAtNotIn(vs ...time.Time) predicate.Bouncer {
|
func UpdatedAtNotIn(vs ...time.Time) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
|
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -365,34 +329,22 @@ func NameNEQ(v string) predicate.Bouncer {
|
||||||
|
|
||||||
// NameIn applies the In predicate on the "name" field.
|
// NameIn applies the In predicate on the "name" field.
|
||||||
func NameIn(vs ...string) predicate.Bouncer {
|
func NameIn(vs ...string) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldName), v...))
|
s.Where(sql.In(s.C(FieldName), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// NameNotIn applies the NotIn predicate on the "name" field.
|
// NameNotIn applies the NotIn predicate on the "name" field.
|
||||||
func NameNotIn(vs ...string) predicate.Bouncer {
|
func NameNotIn(vs ...string) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldName), v...))
|
s.Where(sql.NotIn(s.C(FieldName), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -476,34 +428,22 @@ func APIKeyNEQ(v string) predicate.Bouncer {
|
||||||
|
|
||||||
// APIKeyIn applies the In predicate on the "api_key" field.
|
// APIKeyIn applies the In predicate on the "api_key" field.
|
||||||
func APIKeyIn(vs ...string) predicate.Bouncer {
|
func APIKeyIn(vs ...string) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldAPIKey), v...))
|
s.Where(sql.In(s.C(FieldAPIKey), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// APIKeyNotIn applies the NotIn predicate on the "api_key" field.
|
// APIKeyNotIn applies the NotIn predicate on the "api_key" field.
|
||||||
func APIKeyNotIn(vs ...string) predicate.Bouncer {
|
func APIKeyNotIn(vs ...string) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldAPIKey), v...))
|
s.Where(sql.NotIn(s.C(FieldAPIKey), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -601,34 +541,22 @@ func IPAddressNEQ(v string) predicate.Bouncer {
|
||||||
|
|
||||||
// IPAddressIn applies the In predicate on the "ip_address" field.
|
// IPAddressIn applies the In predicate on the "ip_address" field.
|
||||||
func IPAddressIn(vs ...string) predicate.Bouncer {
|
func IPAddressIn(vs ...string) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldIPAddress), v...))
|
s.Where(sql.In(s.C(FieldIPAddress), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// IPAddressNotIn applies the NotIn predicate on the "ip_address" field.
|
// IPAddressNotIn applies the NotIn predicate on the "ip_address" field.
|
||||||
func IPAddressNotIn(vs ...string) predicate.Bouncer {
|
func IPAddressNotIn(vs ...string) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldIPAddress), v...))
|
s.Where(sql.NotIn(s.C(FieldIPAddress), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -726,34 +654,22 @@ func TypeNEQ(v string) predicate.Bouncer {
|
||||||
|
|
||||||
// TypeIn applies the In predicate on the "type" field.
|
// TypeIn applies the In predicate on the "type" field.
|
||||||
func TypeIn(vs ...string) predicate.Bouncer {
|
func TypeIn(vs ...string) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldType), v...))
|
s.Where(sql.In(s.C(FieldType), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TypeNotIn applies the NotIn predicate on the "type" field.
|
// TypeNotIn applies the NotIn predicate on the "type" field.
|
||||||
func TypeNotIn(vs ...string) predicate.Bouncer {
|
func TypeNotIn(vs ...string) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldType), v...))
|
s.Where(sql.NotIn(s.C(FieldType), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -851,34 +767,22 @@ func VersionNEQ(v string) predicate.Bouncer {
|
||||||
|
|
||||||
// VersionIn applies the In predicate on the "version" field.
|
// VersionIn applies the In predicate on the "version" field.
|
||||||
func VersionIn(vs ...string) predicate.Bouncer {
|
func VersionIn(vs ...string) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldVersion), v...))
|
s.Where(sql.In(s.C(FieldVersion), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// VersionNotIn applies the NotIn predicate on the "version" field.
|
// VersionNotIn applies the NotIn predicate on the "version" field.
|
||||||
func VersionNotIn(vs ...string) predicate.Bouncer {
|
func VersionNotIn(vs ...string) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldVersion), v...))
|
s.Where(sql.NotIn(s.C(FieldVersion), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -976,34 +880,22 @@ func UntilNEQ(v time.Time) predicate.Bouncer {
|
||||||
|
|
||||||
// UntilIn applies the In predicate on the "until" field.
|
// UntilIn applies the In predicate on the "until" field.
|
||||||
func UntilIn(vs ...time.Time) predicate.Bouncer {
|
func UntilIn(vs ...time.Time) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldUntil), v...))
|
s.Where(sql.In(s.C(FieldUntil), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// UntilNotIn applies the NotIn predicate on the "until" field.
|
// UntilNotIn applies the NotIn predicate on the "until" field.
|
||||||
func UntilNotIn(vs ...time.Time) predicate.Bouncer {
|
func UntilNotIn(vs ...time.Time) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldUntil), v...))
|
s.Where(sql.NotIn(s.C(FieldUntil), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1066,34 +958,22 @@ func LastPullNEQ(v time.Time) predicate.Bouncer {
|
||||||
|
|
||||||
// LastPullIn applies the In predicate on the "last_pull" field.
|
// LastPullIn applies the In predicate on the "last_pull" field.
|
||||||
func LastPullIn(vs ...time.Time) predicate.Bouncer {
|
func LastPullIn(vs ...time.Time) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldLastPull), v...))
|
s.Where(sql.In(s.C(FieldLastPull), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// LastPullNotIn applies the NotIn predicate on the "last_pull" field.
|
// LastPullNotIn applies the NotIn predicate on the "last_pull" field.
|
||||||
func LastPullNotIn(vs ...time.Time) predicate.Bouncer {
|
func LastPullNotIn(vs ...time.Time) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldLastPull), v...))
|
s.Where(sql.NotIn(s.C(FieldLastPull), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1142,34 +1022,22 @@ func AuthTypeNEQ(v string) predicate.Bouncer {
|
||||||
|
|
||||||
// AuthTypeIn applies the In predicate on the "auth_type" field.
|
// AuthTypeIn applies the In predicate on the "auth_type" field.
|
||||||
func AuthTypeIn(vs ...string) predicate.Bouncer {
|
func AuthTypeIn(vs ...string) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldAuthType), v...))
|
s.Where(sql.In(s.C(FieldAuthType), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuthTypeNotIn applies the NotIn predicate on the "auth_type" field.
|
// AuthTypeNotIn applies the NotIn predicate on the "auth_type" field.
|
||||||
func AuthTypeNotIn(vs ...string) predicate.Bouncer {
|
func AuthTypeNotIn(vs ...string) predicate.Bouncer {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Bouncer(func(s *sql.Selector) {
|
return predicate.Bouncer(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldAuthType), v...))
|
s.Where(sql.NotIn(s.C(FieldAuthType), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -190,9 +190,15 @@ func (bc *BouncerCreate) Save(ctx context.Context) (*Bouncer, error) {
|
||||||
}
|
}
|
||||||
mut = bc.hooks[i](mut)
|
mut = bc.hooks[i](mut)
|
||||||
}
|
}
|
||||||
if _, err := mut.Mutate(ctx, bc.mutation); err != nil {
|
v, err := mut.Mutate(ctx, bc.mutation)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
nv, ok := v.(*Bouncer)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected node type %T returned from BouncerMutation", v)
|
||||||
|
}
|
||||||
|
node = nv
|
||||||
}
|
}
|
||||||
return node, err
|
return node, err
|
||||||
}
|
}
|
||||||
|
@ -271,7 +277,7 @@ func (bc *BouncerCreate) sqlSave(ctx context.Context) (*Bouncer, error) {
|
||||||
_node, _spec := bc.createSpec()
|
_node, _spec := bc.createSpec()
|
||||||
if err := sqlgraph.CreateNode(ctx, bc.driver, _spec); err != nil {
|
if err := sqlgraph.CreateNode(ctx, bc.driver, _spec); err != nil {
|
||||||
if sqlgraph.IsConstraintError(err) {
|
if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -415,7 +421,7 @@ func (bcb *BouncerCreateBulk) Save(ctx context.Context) ([]*Bouncer, error) {
|
||||||
// Invoke the actual operation on the latest mutation in the chain.
|
// Invoke the actual operation on the latest mutation in the chain.
|
||||||
if err = sqlgraph.BatchCreate(ctx, bcb.driver, spec); err != nil {
|
if err = sqlgraph.BatchCreate(ctx, bcb.driver, spec); err != nil {
|
||||||
if sqlgraph.IsConstraintError(err) {
|
if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -423,11 +429,11 @@ func (bcb *BouncerCreateBulk) Save(ctx context.Context) ([]*Bouncer, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
mutation.id = &nodes[i].ID
|
mutation.id = &nodes[i].ID
|
||||||
mutation.done = true
|
|
||||||
if specs[i].ID.Value != nil {
|
if specs[i].ID.Value != nil {
|
||||||
id := specs[i].ID.Value.(int64)
|
id := specs[i].ID.Value.(int64)
|
||||||
nodes[i].ID = int(id)
|
nodes[i].ID = int(id)
|
||||||
}
|
}
|
||||||
|
mutation.done = true
|
||||||
return nodes[i], nil
|
return nodes[i], nil
|
||||||
})
|
})
|
||||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -84,7 +84,11 @@ func (bd *BouncerDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sqlgraph.DeleteNodes(ctx, bd.driver, _spec)
|
affected, err := sqlgraph.DeleteNodes(ctx, bd.driver, _spec)
|
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return affected, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// BouncerDeleteOne is the builder for deleting a single Bouncer entity.
|
// BouncerDeleteOne is the builder for deleting a single Bouncer entity.
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
|
@ -262,17 +261,18 @@ func (bq *BouncerQuery) Clone() *BouncerQuery {
|
||||||
// GroupBy(bouncer.FieldCreatedAt).
|
// GroupBy(bouncer.FieldCreatedAt).
|
||||||
// Aggregate(ent.Count()).
|
// Aggregate(ent.Count()).
|
||||||
// Scan(ctx, &v)
|
// Scan(ctx, &v)
|
||||||
//
|
|
||||||
func (bq *BouncerQuery) GroupBy(field string, fields ...string) *BouncerGroupBy {
|
func (bq *BouncerQuery) GroupBy(field string, fields ...string) *BouncerGroupBy {
|
||||||
group := &BouncerGroupBy{config: bq.config}
|
grbuild := &BouncerGroupBy{config: bq.config}
|
||||||
group.fields = append([]string{field}, fields...)
|
grbuild.fields = append([]string{field}, fields...)
|
||||||
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
||||||
if err := bq.prepareQuery(ctx); err != nil {
|
if err := bq.prepareQuery(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return bq.sqlQuery(ctx), nil
|
return bq.sqlQuery(ctx), nil
|
||||||
}
|
}
|
||||||
return group
|
grbuild.label = bouncer.Label
|
||||||
|
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan
|
||||||
|
return grbuild
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select allows the selection one or more fields/columns for the given query,
|
// Select allows the selection one or more fields/columns for the given query,
|
||||||
|
@ -287,10 +287,12 @@ func (bq *BouncerQuery) GroupBy(field string, fields ...string) *BouncerGroupBy
|
||||||
// client.Bouncer.Query().
|
// client.Bouncer.Query().
|
||||||
// Select(bouncer.FieldCreatedAt).
|
// Select(bouncer.FieldCreatedAt).
|
||||||
// Scan(ctx, &v)
|
// Scan(ctx, &v)
|
||||||
//
|
|
||||||
func (bq *BouncerQuery) Select(fields ...string) *BouncerSelect {
|
func (bq *BouncerQuery) Select(fields ...string) *BouncerSelect {
|
||||||
bq.fields = append(bq.fields, fields...)
|
bq.fields = append(bq.fields, fields...)
|
||||||
return &BouncerSelect{BouncerQuery: bq}
|
selbuild := &BouncerSelect{BouncerQuery: bq}
|
||||||
|
selbuild.label = bouncer.Label
|
||||||
|
selbuild.flds, selbuild.scan = &bq.fields, selbuild.Scan
|
||||||
|
return selbuild
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bq *BouncerQuery) prepareQuery(ctx context.Context) error {
|
func (bq *BouncerQuery) prepareQuery(ctx context.Context) error {
|
||||||
|
@ -309,23 +311,22 @@ func (bq *BouncerQuery) prepareQuery(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bq *BouncerQuery) sqlAll(ctx context.Context) ([]*Bouncer, error) {
|
func (bq *BouncerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Bouncer, error) {
|
||||||
var (
|
var (
|
||||||
nodes = []*Bouncer{}
|
nodes = []*Bouncer{}
|
||||||
_spec = bq.querySpec()
|
_spec = bq.querySpec()
|
||||||
)
|
)
|
||||||
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
return (*Bouncer).scanValues(nil, columns)
|
||||||
|
}
|
||||||
|
_spec.Assign = func(columns []string, values []any) error {
|
||||||
node := &Bouncer{config: bq.config}
|
node := &Bouncer{config: bq.config}
|
||||||
nodes = append(nodes, node)
|
nodes = append(nodes, node)
|
||||||
return node.scanValues(columns)
|
|
||||||
}
|
|
||||||
_spec.Assign = func(columns []string, values []interface{}) error {
|
|
||||||
if len(nodes) == 0 {
|
|
||||||
return fmt.Errorf("ent: Assign called without calling ScanValues")
|
|
||||||
}
|
|
||||||
node := nodes[len(nodes)-1]
|
|
||||||
return node.assignValues(columns, values)
|
return node.assignValues(columns, values)
|
||||||
}
|
}
|
||||||
|
for i := range hooks {
|
||||||
|
hooks[i](ctx, _spec)
|
||||||
|
}
|
||||||
if err := sqlgraph.QueryNodes(ctx, bq.driver, _spec); err != nil {
|
if err := sqlgraph.QueryNodes(ctx, bq.driver, _spec); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -345,11 +346,14 @@ func (bq *BouncerQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bq *BouncerQuery) sqlExist(ctx context.Context) (bool, error) {
|
func (bq *BouncerQuery) sqlExist(ctx context.Context) (bool, error) {
|
||||||
n, err := bq.sqlCount(ctx)
|
switch _, err := bq.FirstID(ctx); {
|
||||||
if err != nil {
|
case IsNotFound(err):
|
||||||
|
return false, nil
|
||||||
|
case err != nil:
|
||||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||||
|
default:
|
||||||
|
return true, nil
|
||||||
}
|
}
|
||||||
return n > 0, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (bq *BouncerQuery) querySpec() *sqlgraph.QuerySpec {
|
func (bq *BouncerQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
|
@ -435,6 +439,7 @@ func (bq *BouncerQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||||
// BouncerGroupBy is the group-by builder for Bouncer entities.
|
// BouncerGroupBy is the group-by builder for Bouncer entities.
|
||||||
type BouncerGroupBy struct {
|
type BouncerGroupBy struct {
|
||||||
config
|
config
|
||||||
|
selector
|
||||||
fields []string
|
fields []string
|
||||||
fns []AggregateFunc
|
fns []AggregateFunc
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
|
@ -449,7 +454,7 @@ func (bgb *BouncerGroupBy) Aggregate(fns ...AggregateFunc) *BouncerGroupBy {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan applies the group-by query and scans the result into the given value.
|
// Scan applies the group-by query and scans the result into the given value.
|
||||||
func (bgb *BouncerGroupBy) Scan(ctx context.Context, v interface{}) error {
|
func (bgb *BouncerGroupBy) Scan(ctx context.Context, v any) error {
|
||||||
query, err := bgb.path(ctx)
|
query, err := bgb.path(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -458,210 +463,7 @@ func (bgb *BouncerGroupBy) Scan(ctx context.Context, v interface{}) error {
|
||||||
return bgb.sqlScan(ctx, v)
|
return bgb.sqlScan(ctx, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScanX is like Scan, but panics if an error occurs.
|
func (bgb *BouncerGroupBy) sqlScan(ctx context.Context, v any) error {
|
||||||
func (bgb *BouncerGroupBy) ScanX(ctx context.Context, v interface{}) {
|
|
||||||
if err := bgb.Scan(ctx, v); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strings returns list of strings from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (bgb *BouncerGroupBy) Strings(ctx context.Context) ([]string, error) {
|
|
||||||
if len(bgb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: BouncerGroupBy.Strings is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []string
|
|
||||||
if err := bgb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringsX is like Strings, but panics if an error occurs.
|
|
||||||
func (bgb *BouncerGroupBy) StringsX(ctx context.Context) []string {
|
|
||||||
v, err := bgb.Strings(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns a single string from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (bgb *BouncerGroupBy) String(ctx context.Context) (_ string, err error) {
|
|
||||||
var v []string
|
|
||||||
if v, err = bgb.Strings(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{bouncer.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: BouncerGroupBy.Strings returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringX is like String, but panics if an error occurs.
|
|
||||||
func (bgb *BouncerGroupBy) StringX(ctx context.Context) string {
|
|
||||||
v, err := bgb.String(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ints returns list of ints from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (bgb *BouncerGroupBy) Ints(ctx context.Context) ([]int, error) {
|
|
||||||
if len(bgb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: BouncerGroupBy.Ints is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []int
|
|
||||||
if err := bgb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntsX is like Ints, but panics if an error occurs.
|
|
||||||
func (bgb *BouncerGroupBy) IntsX(ctx context.Context) []int {
|
|
||||||
v, err := bgb.Ints(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int returns a single int from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (bgb *BouncerGroupBy) Int(ctx context.Context) (_ int, err error) {
|
|
||||||
var v []int
|
|
||||||
if v, err = bgb.Ints(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{bouncer.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: BouncerGroupBy.Ints returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntX is like Int, but panics if an error occurs.
|
|
||||||
func (bgb *BouncerGroupBy) IntX(ctx context.Context) int {
|
|
||||||
v, err := bgb.Int(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64s returns list of float64s from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (bgb *BouncerGroupBy) Float64s(ctx context.Context) ([]float64, error) {
|
|
||||||
if len(bgb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: BouncerGroupBy.Float64s is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []float64
|
|
||||||
if err := bgb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64sX is like Float64s, but panics if an error occurs.
|
|
||||||
func (bgb *BouncerGroupBy) Float64sX(ctx context.Context) []float64 {
|
|
||||||
v, err := bgb.Float64s(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64 returns a single float64 from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (bgb *BouncerGroupBy) Float64(ctx context.Context) (_ float64, err error) {
|
|
||||||
var v []float64
|
|
||||||
if v, err = bgb.Float64s(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{bouncer.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: BouncerGroupBy.Float64s returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64X is like Float64, but panics if an error occurs.
|
|
||||||
func (bgb *BouncerGroupBy) Float64X(ctx context.Context) float64 {
|
|
||||||
v, err := bgb.Float64(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bools returns list of bools from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (bgb *BouncerGroupBy) Bools(ctx context.Context) ([]bool, error) {
|
|
||||||
if len(bgb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: BouncerGroupBy.Bools is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []bool
|
|
||||||
if err := bgb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolsX is like Bools, but panics if an error occurs.
|
|
||||||
func (bgb *BouncerGroupBy) BoolsX(ctx context.Context) []bool {
|
|
||||||
v, err := bgb.Bools(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bool returns a single bool from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (bgb *BouncerGroupBy) Bool(ctx context.Context) (_ bool, err error) {
|
|
||||||
var v []bool
|
|
||||||
if v, err = bgb.Bools(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{bouncer.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: BouncerGroupBy.Bools returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolX is like Bool, but panics if an error occurs.
|
|
||||||
func (bgb *BouncerGroupBy) BoolX(ctx context.Context) bool {
|
|
||||||
v, err := bgb.Bool(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
func (bgb *BouncerGroupBy) sqlScan(ctx context.Context, v interface{}) error {
|
|
||||||
for _, f := range bgb.fields {
|
for _, f := range bgb.fields {
|
||||||
if !bouncer.ValidColumn(f) {
|
if !bouncer.ValidColumn(f) {
|
||||||
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
|
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
|
||||||
|
@ -702,12 +504,13 @@ func (bgb *BouncerGroupBy) sqlQuery() *sql.Selector {
|
||||||
// BouncerSelect is the builder for selecting fields of Bouncer entities.
|
// BouncerSelect is the builder for selecting fields of Bouncer entities.
|
||||||
type BouncerSelect struct {
|
type BouncerSelect struct {
|
||||||
*BouncerQuery
|
*BouncerQuery
|
||||||
|
selector
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
sql *sql.Selector
|
sql *sql.Selector
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan applies the selector query and scans the result into the given value.
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
func (bs *BouncerSelect) Scan(ctx context.Context, v interface{}) error {
|
func (bs *BouncerSelect) Scan(ctx context.Context, v any) error {
|
||||||
if err := bs.prepareQuery(ctx); err != nil {
|
if err := bs.prepareQuery(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -715,202 +518,7 @@ func (bs *BouncerSelect) Scan(ctx context.Context, v interface{}) error {
|
||||||
return bs.sqlScan(ctx, v)
|
return bs.sqlScan(ctx, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScanX is like Scan, but panics if an error occurs.
|
func (bs *BouncerSelect) sqlScan(ctx context.Context, v any) error {
|
||||||
func (bs *BouncerSelect) ScanX(ctx context.Context, v interface{}) {
|
|
||||||
if err := bs.Scan(ctx, v); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
|
|
||||||
func (bs *BouncerSelect) Strings(ctx context.Context) ([]string, error) {
|
|
||||||
if len(bs.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: BouncerSelect.Strings is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []string
|
|
||||||
if err := bs.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringsX is like Strings, but panics if an error occurs.
|
|
||||||
func (bs *BouncerSelect) StringsX(ctx context.Context) []string {
|
|
||||||
v, err := bs.Strings(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns a single string from a selector. It is only allowed when selecting one field.
|
|
||||||
func (bs *BouncerSelect) String(ctx context.Context) (_ string, err error) {
|
|
||||||
var v []string
|
|
||||||
if v, err = bs.Strings(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{bouncer.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: BouncerSelect.Strings returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringX is like String, but panics if an error occurs.
|
|
||||||
func (bs *BouncerSelect) StringX(ctx context.Context) string {
|
|
||||||
v, err := bs.String(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
|
|
||||||
func (bs *BouncerSelect) Ints(ctx context.Context) ([]int, error) {
|
|
||||||
if len(bs.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: BouncerSelect.Ints is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []int
|
|
||||||
if err := bs.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntsX is like Ints, but panics if an error occurs.
|
|
||||||
func (bs *BouncerSelect) IntsX(ctx context.Context) []int {
|
|
||||||
v, err := bs.Ints(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int returns a single int from a selector. It is only allowed when selecting one field.
|
|
||||||
func (bs *BouncerSelect) Int(ctx context.Context) (_ int, err error) {
|
|
||||||
var v []int
|
|
||||||
if v, err = bs.Ints(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{bouncer.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: BouncerSelect.Ints returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntX is like Int, but panics if an error occurs.
|
|
||||||
func (bs *BouncerSelect) IntX(ctx context.Context) int {
|
|
||||||
v, err := bs.Int(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
|
|
||||||
func (bs *BouncerSelect) Float64s(ctx context.Context) ([]float64, error) {
|
|
||||||
if len(bs.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: BouncerSelect.Float64s is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []float64
|
|
||||||
if err := bs.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64sX is like Float64s, but panics if an error occurs.
|
|
||||||
func (bs *BouncerSelect) Float64sX(ctx context.Context) []float64 {
|
|
||||||
v, err := bs.Float64s(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
|
|
||||||
func (bs *BouncerSelect) Float64(ctx context.Context) (_ float64, err error) {
|
|
||||||
var v []float64
|
|
||||||
if v, err = bs.Float64s(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{bouncer.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: BouncerSelect.Float64s returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64X is like Float64, but panics if an error occurs.
|
|
||||||
func (bs *BouncerSelect) Float64X(ctx context.Context) float64 {
|
|
||||||
v, err := bs.Float64(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
|
|
||||||
func (bs *BouncerSelect) Bools(ctx context.Context) ([]bool, error) {
|
|
||||||
if len(bs.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: BouncerSelect.Bools is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []bool
|
|
||||||
if err := bs.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolsX is like Bools, but panics if an error occurs.
|
|
||||||
func (bs *BouncerSelect) BoolsX(ctx context.Context) []bool {
|
|
||||||
v, err := bs.Bools(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
|
|
||||||
func (bs *BouncerSelect) Bool(ctx context.Context) (_ bool, err error) {
|
|
||||||
var v []bool
|
|
||||||
if v, err = bs.Bools(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{bouncer.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: BouncerSelect.Bools returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolX is like Bool, but panics if an error occurs.
|
|
||||||
func (bs *BouncerSelect) BoolX(ctx context.Context) bool {
|
|
||||||
v, err := bs.Bool(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
func (bs *BouncerSelect) sqlScan(ctx context.Context, v interface{}) error {
|
|
||||||
rows := &sql.Rows{}
|
rows := &sql.Rows{}
|
||||||
query, args := bs.sql.Query()
|
query, args := bs.sql.Query()
|
||||||
if err := bs.driver.Query(ctx, query, args, rows); err != nil {
|
if err := bs.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -385,7 +385,7 @@ func (bu *BouncerUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
err = &NotFoundError{bouncer.Label}
|
err = &NotFoundError{bouncer.Label}
|
||||||
} else if sqlgraph.IsConstraintError(err) {
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -588,9 +588,15 @@ func (buo *BouncerUpdateOne) Save(ctx context.Context) (*Bouncer, error) {
|
||||||
}
|
}
|
||||||
mut = buo.hooks[i](mut)
|
mut = buo.hooks[i](mut)
|
||||||
}
|
}
|
||||||
if _, err := mut.Mutate(ctx, buo.mutation); err != nil {
|
v, err := mut.Mutate(ctx, buo.mutation)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
nv, ok := v.(*Bouncer)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected node type %T returned from BouncerMutation", v)
|
||||||
|
}
|
||||||
|
node = nv
|
||||||
}
|
}
|
||||||
return node, err
|
return node, err
|
||||||
}
|
}
|
||||||
|
@ -784,7 +790,7 @@ func (buo *BouncerUpdateOne) sqlSave(ctx context.Context) (_node *Bouncer, err e
|
||||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
err = &NotFoundError{bouncer.Label}
|
err = &NotFoundError{bouncer.Label}
|
||||||
} else if sqlgraph.IsConstraintError(err) {
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
|
@ -79,7 +80,7 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error)
|
||||||
// is used until the transaction is committed or rolled back.
|
// is used until the transaction is committed or rolled back.
|
||||||
func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||||
if _, ok := c.driver.(*txDriver); ok {
|
if _, ok := c.driver.(*txDriver); ok {
|
||||||
return nil, fmt.Errorf("ent: cannot start a transaction within a transaction")
|
return nil, errors.New("ent: cannot start a transaction within a transaction")
|
||||||
}
|
}
|
||||||
tx, err := newTx(ctx, c.driver)
|
tx, err := newTx(ctx, c.driver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -102,7 +103,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||||
// BeginTx returns a transactional client with specified options.
|
// BeginTx returns a transactional client with specified options.
|
||||||
func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
|
func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
|
||||||
if _, ok := c.driver.(*txDriver); ok {
|
if _, ok := c.driver.(*txDriver); ok {
|
||||||
return nil, fmt.Errorf("ent: cannot start a transaction within a transaction")
|
return nil, errors.New("ent: cannot start a transaction within a transaction")
|
||||||
}
|
}
|
||||||
tx, err := c.driver.(interface {
|
tx, err := c.driver.(interface {
|
||||||
BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
|
BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
|
||||||
|
@ -130,7 +131,6 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
|
||||||
// Alert.
|
// Alert.
|
||||||
// Query().
|
// Query().
|
||||||
// Count(ctx)
|
// Count(ctx)
|
||||||
//
|
|
||||||
func (c *Client) Debug() *Client {
|
func (c *Client) Debug() *Client {
|
||||||
if c.debug {
|
if c.debug {
|
||||||
return c
|
return c
|
||||||
|
@ -174,7 +174,7 @@ func (c *AlertClient) Use(hooks ...Hook) {
|
||||||
c.hooks.Alert = append(c.hooks.Alert, hooks...)
|
c.hooks.Alert = append(c.hooks.Alert, hooks...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create returns a create builder for Alert.
|
// Create returns a builder for creating a Alert entity.
|
||||||
func (c *AlertClient) Create() *AlertCreate {
|
func (c *AlertClient) Create() *AlertCreate {
|
||||||
mutation := newAlertMutation(c.config, OpCreate)
|
mutation := newAlertMutation(c.config, OpCreate)
|
||||||
return &AlertCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
return &AlertCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
@ -209,12 +209,12 @@ func (c *AlertClient) Delete() *AlertDelete {
|
||||||
return &AlertDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
return &AlertDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteOne returns a delete builder for the given entity.
|
// DeleteOne returns a builder for deleting the given entity.
|
||||||
func (c *AlertClient) DeleteOne(a *Alert) *AlertDeleteOne {
|
func (c *AlertClient) DeleteOne(a *Alert) *AlertDeleteOne {
|
||||||
return c.DeleteOneID(a.ID)
|
return c.DeleteOneID(a.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteOneID returns a delete builder for the given id.
|
// DeleteOne returns a builder for deleting the given entity by its id.
|
||||||
func (c *AlertClient) DeleteOneID(id int) *AlertDeleteOne {
|
func (c *AlertClient) DeleteOneID(id int) *AlertDeleteOne {
|
||||||
builder := c.Delete().Where(alert.ID(id))
|
builder := c.Delete().Where(alert.ID(id))
|
||||||
builder.mutation.id = &id
|
builder.mutation.id = &id
|
||||||
|
@ -328,7 +328,7 @@ func (c *BouncerClient) Use(hooks ...Hook) {
|
||||||
c.hooks.Bouncer = append(c.hooks.Bouncer, hooks...)
|
c.hooks.Bouncer = append(c.hooks.Bouncer, hooks...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create returns a create builder for Bouncer.
|
// Create returns a builder for creating a Bouncer entity.
|
||||||
func (c *BouncerClient) Create() *BouncerCreate {
|
func (c *BouncerClient) Create() *BouncerCreate {
|
||||||
mutation := newBouncerMutation(c.config, OpCreate)
|
mutation := newBouncerMutation(c.config, OpCreate)
|
||||||
return &BouncerCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
return &BouncerCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
@ -363,12 +363,12 @@ func (c *BouncerClient) Delete() *BouncerDelete {
|
||||||
return &BouncerDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
return &BouncerDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteOne returns a delete builder for the given entity.
|
// DeleteOne returns a builder for deleting the given entity.
|
||||||
func (c *BouncerClient) DeleteOne(b *Bouncer) *BouncerDeleteOne {
|
func (c *BouncerClient) DeleteOne(b *Bouncer) *BouncerDeleteOne {
|
||||||
return c.DeleteOneID(b.ID)
|
return c.DeleteOneID(b.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteOneID returns a delete builder for the given id.
|
// DeleteOne returns a builder for deleting the given entity by its id.
|
||||||
func (c *BouncerClient) DeleteOneID(id int) *BouncerDeleteOne {
|
func (c *BouncerClient) DeleteOneID(id int) *BouncerDeleteOne {
|
||||||
builder := c.Delete().Where(bouncer.ID(id))
|
builder := c.Delete().Where(bouncer.ID(id))
|
||||||
builder.mutation.id = &id
|
builder.mutation.id = &id
|
||||||
|
@ -418,7 +418,7 @@ func (c *DecisionClient) Use(hooks ...Hook) {
|
||||||
c.hooks.Decision = append(c.hooks.Decision, hooks...)
|
c.hooks.Decision = append(c.hooks.Decision, hooks...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create returns a create builder for Decision.
|
// Create returns a builder for creating a Decision entity.
|
||||||
func (c *DecisionClient) Create() *DecisionCreate {
|
func (c *DecisionClient) Create() *DecisionCreate {
|
||||||
mutation := newDecisionMutation(c.config, OpCreate)
|
mutation := newDecisionMutation(c.config, OpCreate)
|
||||||
return &DecisionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
return &DecisionCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
@ -453,12 +453,12 @@ func (c *DecisionClient) Delete() *DecisionDelete {
|
||||||
return &DecisionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
return &DecisionDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteOne returns a delete builder for the given entity.
|
// DeleteOne returns a builder for deleting the given entity.
|
||||||
func (c *DecisionClient) DeleteOne(d *Decision) *DecisionDeleteOne {
|
func (c *DecisionClient) DeleteOne(d *Decision) *DecisionDeleteOne {
|
||||||
return c.DeleteOneID(d.ID)
|
return c.DeleteOneID(d.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteOneID returns a delete builder for the given id.
|
// DeleteOne returns a builder for deleting the given entity by its id.
|
||||||
func (c *DecisionClient) DeleteOneID(id int) *DecisionDeleteOne {
|
func (c *DecisionClient) DeleteOneID(id int) *DecisionDeleteOne {
|
||||||
builder := c.Delete().Where(decision.ID(id))
|
builder := c.Delete().Where(decision.ID(id))
|
||||||
builder.mutation.id = &id
|
builder.mutation.id = &id
|
||||||
|
@ -524,7 +524,7 @@ func (c *EventClient) Use(hooks ...Hook) {
|
||||||
c.hooks.Event = append(c.hooks.Event, hooks...)
|
c.hooks.Event = append(c.hooks.Event, hooks...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create returns a create builder for Event.
|
// Create returns a builder for creating a Event entity.
|
||||||
func (c *EventClient) Create() *EventCreate {
|
func (c *EventClient) Create() *EventCreate {
|
||||||
mutation := newEventMutation(c.config, OpCreate)
|
mutation := newEventMutation(c.config, OpCreate)
|
||||||
return &EventCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
return &EventCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
@ -559,12 +559,12 @@ func (c *EventClient) Delete() *EventDelete {
|
||||||
return &EventDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
return &EventDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteOne returns a delete builder for the given entity.
|
// DeleteOne returns a builder for deleting the given entity.
|
||||||
func (c *EventClient) DeleteOne(e *Event) *EventDeleteOne {
|
func (c *EventClient) DeleteOne(e *Event) *EventDeleteOne {
|
||||||
return c.DeleteOneID(e.ID)
|
return c.DeleteOneID(e.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteOneID returns a delete builder for the given id.
|
// DeleteOne returns a builder for deleting the given entity by its id.
|
||||||
func (c *EventClient) DeleteOneID(id int) *EventDeleteOne {
|
func (c *EventClient) DeleteOneID(id int) *EventDeleteOne {
|
||||||
builder := c.Delete().Where(event.ID(id))
|
builder := c.Delete().Where(event.ID(id))
|
||||||
builder.mutation.id = &id
|
builder.mutation.id = &id
|
||||||
|
@ -630,7 +630,7 @@ func (c *MachineClient) Use(hooks ...Hook) {
|
||||||
c.hooks.Machine = append(c.hooks.Machine, hooks...)
|
c.hooks.Machine = append(c.hooks.Machine, hooks...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create returns a create builder for Machine.
|
// Create returns a builder for creating a Machine entity.
|
||||||
func (c *MachineClient) Create() *MachineCreate {
|
func (c *MachineClient) Create() *MachineCreate {
|
||||||
mutation := newMachineMutation(c.config, OpCreate)
|
mutation := newMachineMutation(c.config, OpCreate)
|
||||||
return &MachineCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
return &MachineCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
@ -665,12 +665,12 @@ func (c *MachineClient) Delete() *MachineDelete {
|
||||||
return &MachineDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
return &MachineDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteOne returns a delete builder for the given entity.
|
// DeleteOne returns a builder for deleting the given entity.
|
||||||
func (c *MachineClient) DeleteOne(m *Machine) *MachineDeleteOne {
|
func (c *MachineClient) DeleteOne(m *Machine) *MachineDeleteOne {
|
||||||
return c.DeleteOneID(m.ID)
|
return c.DeleteOneID(m.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteOneID returns a delete builder for the given id.
|
// DeleteOne returns a builder for deleting the given entity by its id.
|
||||||
func (c *MachineClient) DeleteOneID(id int) *MachineDeleteOne {
|
func (c *MachineClient) DeleteOneID(id int) *MachineDeleteOne {
|
||||||
builder := c.Delete().Where(machine.ID(id))
|
builder := c.Delete().Where(machine.ID(id))
|
||||||
builder.mutation.id = &id
|
builder.mutation.id = &id
|
||||||
|
@ -736,7 +736,7 @@ func (c *MetaClient) Use(hooks ...Hook) {
|
||||||
c.hooks.Meta = append(c.hooks.Meta, hooks...)
|
c.hooks.Meta = append(c.hooks.Meta, hooks...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create returns a create builder for Meta.
|
// Create returns a builder for creating a Meta entity.
|
||||||
func (c *MetaClient) Create() *MetaCreate {
|
func (c *MetaClient) Create() *MetaCreate {
|
||||||
mutation := newMetaMutation(c.config, OpCreate)
|
mutation := newMetaMutation(c.config, OpCreate)
|
||||||
return &MetaCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
return &MetaCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
|
@ -771,12 +771,12 @@ func (c *MetaClient) Delete() *MetaDelete {
|
||||||
return &MetaDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
return &MetaDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteOne returns a delete builder for the given entity.
|
// DeleteOne returns a builder for deleting the given entity.
|
||||||
func (c *MetaClient) DeleteOne(m *Meta) *MetaDeleteOne {
|
func (c *MetaClient) DeleteOne(m *Meta) *MetaDeleteOne {
|
||||||
return c.DeleteOneID(m.ID)
|
return c.DeleteOneID(m.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteOneID returns a delete builder for the given id.
|
// DeleteOne returns a builder for deleting the given entity by its id.
|
||||||
func (c *MetaClient) DeleteOneID(id int) *MetaDeleteOne {
|
func (c *MetaClient) DeleteOneID(id int) *MetaDeleteOne {
|
||||||
builder := c.Delete().Where(meta.ID(id))
|
builder := c.Delete().Where(meta.ID(id))
|
||||||
builder.mutation.id = &id
|
builder.mutation.id = &id
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ type config struct {
|
||||||
// debug enable a debug logging.
|
// debug enable a debug logging.
|
||||||
debug bool
|
debug bool
|
||||||
// log used for logging on debug mode.
|
// log used for logging on debug mode.
|
||||||
log func(...interface{})
|
log func(...any)
|
||||||
// hooks to execute on mutations.
|
// hooks to execute on mutations.
|
||||||
hooks *hooks
|
hooks *hooks
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ func Debug() Option {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log sets the logging function for debug mode.
|
// Log sets the logging function for debug mode.
|
||||||
func Log(fn func(...interface{})) Option {
|
func Log(fn func(...any)) Option {
|
||||||
return func(c *config) {
|
return func(c *config) {
|
||||||
c.log = fn
|
c.log = fn
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -65,8 +65,7 @@ type DecisionEdges struct {
|
||||||
func (e DecisionEdges) OwnerOrErr() (*Alert, error) {
|
func (e DecisionEdges) OwnerOrErr() (*Alert, error) {
|
||||||
if e.loadedTypes[0] {
|
if e.loadedTypes[0] {
|
||||||
if e.Owner == nil {
|
if e.Owner == nil {
|
||||||
// The edge owner was loaded in eager-loading,
|
// Edge was loaded but was not found.
|
||||||
// but was not found.
|
|
||||||
return nil, &NotFoundError{label: alert.Label}
|
return nil, &NotFoundError{label: alert.Label}
|
||||||
}
|
}
|
||||||
return e.Owner, nil
|
return e.Owner, nil
|
||||||
|
@ -75,8 +74,8 @@ func (e DecisionEdges) OwnerOrErr() (*Alert, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// scanValues returns the types for scanning values from sql.Rows.
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
func (*Decision) scanValues(columns []string) ([]interface{}, error) {
|
func (*Decision) scanValues(columns []string) ([]any, error) {
|
||||||
values := make([]interface{}, len(columns))
|
values := make([]any, len(columns))
|
||||||
for i := range columns {
|
for i := range columns {
|
||||||
switch columns[i] {
|
switch columns[i] {
|
||||||
case decision.FieldSimulated:
|
case decision.FieldSimulated:
|
||||||
|
@ -98,7 +97,7 @@ func (*Decision) scanValues(columns []string) ([]interface{}, error) {
|
||||||
|
|
||||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||||
// to the Decision fields.
|
// to the Decision fields.
|
||||||
func (d *Decision) assignValues(columns []string, values []interface{}) error {
|
func (d *Decision) assignValues(columns []string, values []any) error {
|
||||||
if m, n := len(values), len(columns); m < n {
|
if m, n := len(values), len(columns); m < n {
|
||||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||||
}
|
}
|
||||||
|
@ -224,11 +223,11 @@ func (d *Decision) Update() *DecisionUpdateOne {
|
||||||
// Unwrap unwraps the Decision entity that was returned from a transaction after it was closed,
|
// Unwrap unwraps the Decision entity that was returned from a transaction after it was closed,
|
||||||
// so that all future queries will be executed through the driver which created the transaction.
|
// so that all future queries will be executed through the driver which created the transaction.
|
||||||
func (d *Decision) Unwrap() *Decision {
|
func (d *Decision) Unwrap() *Decision {
|
||||||
tx, ok := d.config.driver.(*txDriver)
|
_tx, ok := d.config.driver.(*txDriver)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("ent: Decision is not a transactional entity")
|
panic("ent: Decision is not a transactional entity")
|
||||||
}
|
}
|
||||||
d.config.driver = tx.drv
|
d.config.driver = _tx.drv
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,40 +235,53 @@ func (d *Decision) Unwrap() *Decision {
|
||||||
func (d *Decision) String() string {
|
func (d *Decision) String() string {
|
||||||
var builder strings.Builder
|
var builder strings.Builder
|
||||||
builder.WriteString("Decision(")
|
builder.WriteString("Decision(")
|
||||||
builder.WriteString(fmt.Sprintf("id=%v", d.ID))
|
builder.WriteString(fmt.Sprintf("id=%v, ", d.ID))
|
||||||
if v := d.CreatedAt; v != nil {
|
if v := d.CreatedAt; v != nil {
|
||||||
builder.WriteString(", created_at=")
|
builder.WriteString("created_at=")
|
||||||
builder.WriteString(v.Format(time.ANSIC))
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
}
|
}
|
||||||
|
builder.WriteString(", ")
|
||||||
if v := d.UpdatedAt; v != nil {
|
if v := d.UpdatedAt; v != nil {
|
||||||
builder.WriteString(", updated_at=")
|
builder.WriteString("updated_at=")
|
||||||
builder.WriteString(v.Format(time.ANSIC))
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
}
|
}
|
||||||
|
builder.WriteString(", ")
|
||||||
if v := d.Until; v != nil {
|
if v := d.Until; v != nil {
|
||||||
builder.WriteString(", until=")
|
builder.WriteString("until=")
|
||||||
builder.WriteString(v.Format(time.ANSIC))
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
}
|
}
|
||||||
builder.WriteString(", scenario=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("scenario=")
|
||||||
builder.WriteString(d.Scenario)
|
builder.WriteString(d.Scenario)
|
||||||
builder.WriteString(", type=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("type=")
|
||||||
builder.WriteString(d.Type)
|
builder.WriteString(d.Type)
|
||||||
builder.WriteString(", start_ip=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("start_ip=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", d.StartIP))
|
builder.WriteString(fmt.Sprintf("%v", d.StartIP))
|
||||||
builder.WriteString(", end_ip=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("end_ip=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", d.EndIP))
|
builder.WriteString(fmt.Sprintf("%v", d.EndIP))
|
||||||
builder.WriteString(", start_suffix=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("start_suffix=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", d.StartSuffix))
|
builder.WriteString(fmt.Sprintf("%v", d.StartSuffix))
|
||||||
builder.WriteString(", end_suffix=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("end_suffix=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", d.EndSuffix))
|
builder.WriteString(fmt.Sprintf("%v", d.EndSuffix))
|
||||||
builder.WriteString(", ip_size=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("ip_size=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", d.IPSize))
|
builder.WriteString(fmt.Sprintf("%v", d.IPSize))
|
||||||
builder.WriteString(", scope=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("scope=")
|
||||||
builder.WriteString(d.Scope)
|
builder.WriteString(d.Scope)
|
||||||
builder.WriteString(", value=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("value=")
|
||||||
builder.WriteString(d.Value)
|
builder.WriteString(d.Value)
|
||||||
builder.WriteString(", origin=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("origin=")
|
||||||
builder.WriteString(d.Origin)
|
builder.WriteString(d.Origin)
|
||||||
builder.WriteString(", simulated=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("simulated=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", d.Simulated))
|
builder.WriteString(fmt.Sprintf("%v", d.Simulated))
|
||||||
builder.WriteByte(')')
|
builder.WriteByte(')')
|
||||||
return builder.String()
|
return builder.String()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package decision
|
package decision
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package decision
|
package decision
|
||||||
|
|
||||||
|
@ -34,13 +34,7 @@ func IDNEQ(id int) predicate.Decision {
|
||||||
// IDIn applies the In predicate on the ID field.
|
// IDIn applies the In predicate on the ID field.
|
||||||
func IDIn(ids ...int) predicate.Decision {
|
func IDIn(ids ...int) predicate.Decision {
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
v := make([]any, len(ids))
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(ids) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
v := make([]interface{}, len(ids))
|
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = ids[i]
|
v[i] = ids[i]
|
||||||
}
|
}
|
||||||
|
@ -51,13 +45,7 @@ func IDIn(ids ...int) predicate.Decision {
|
||||||
// IDNotIn applies the NotIn predicate on the ID field.
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
func IDNotIn(ids ...int) predicate.Decision {
|
func IDNotIn(ids ...int) predicate.Decision {
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
v := make([]any, len(ids))
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(ids) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
v := make([]interface{}, len(ids))
|
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = ids[i]
|
v[i] = ids[i]
|
||||||
}
|
}
|
||||||
|
@ -207,34 +195,22 @@ func CreatedAtNEQ(v time.Time) predicate.Decision {
|
||||||
|
|
||||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||||
func CreatedAtIn(vs ...time.Time) predicate.Decision {
|
func CreatedAtIn(vs ...time.Time) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldCreatedAt), v...))
|
s.Where(sql.In(s.C(FieldCreatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||||
func CreatedAtNotIn(vs ...time.Time) predicate.Decision {
|
func CreatedAtNotIn(vs ...time.Time) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
|
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -297,34 +273,22 @@ func UpdatedAtNEQ(v time.Time) predicate.Decision {
|
||||||
|
|
||||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||||
func UpdatedAtIn(vs ...time.Time) predicate.Decision {
|
func UpdatedAtIn(vs ...time.Time) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
|
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||||
func UpdatedAtNotIn(vs ...time.Time) predicate.Decision {
|
func UpdatedAtNotIn(vs ...time.Time) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
|
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -387,34 +351,22 @@ func UntilNEQ(v time.Time) predicate.Decision {
|
||||||
|
|
||||||
// UntilIn applies the In predicate on the "until" field.
|
// UntilIn applies the In predicate on the "until" field.
|
||||||
func UntilIn(vs ...time.Time) predicate.Decision {
|
func UntilIn(vs ...time.Time) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldUntil), v...))
|
s.Where(sql.In(s.C(FieldUntil), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// UntilNotIn applies the NotIn predicate on the "until" field.
|
// UntilNotIn applies the NotIn predicate on the "until" field.
|
||||||
func UntilNotIn(vs ...time.Time) predicate.Decision {
|
func UntilNotIn(vs ...time.Time) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldUntil), v...))
|
s.Where(sql.NotIn(s.C(FieldUntil), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -477,34 +429,22 @@ func ScenarioNEQ(v string) predicate.Decision {
|
||||||
|
|
||||||
// ScenarioIn applies the In predicate on the "scenario" field.
|
// ScenarioIn applies the In predicate on the "scenario" field.
|
||||||
func ScenarioIn(vs ...string) predicate.Decision {
|
func ScenarioIn(vs ...string) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldScenario), v...))
|
s.Where(sql.In(s.C(FieldScenario), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScenarioNotIn applies the NotIn predicate on the "scenario" field.
|
// ScenarioNotIn applies the NotIn predicate on the "scenario" field.
|
||||||
func ScenarioNotIn(vs ...string) predicate.Decision {
|
func ScenarioNotIn(vs ...string) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldScenario), v...))
|
s.Where(sql.NotIn(s.C(FieldScenario), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -588,34 +528,22 @@ func TypeNEQ(v string) predicate.Decision {
|
||||||
|
|
||||||
// TypeIn applies the In predicate on the "type" field.
|
// TypeIn applies the In predicate on the "type" field.
|
||||||
func TypeIn(vs ...string) predicate.Decision {
|
func TypeIn(vs ...string) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldType), v...))
|
s.Where(sql.In(s.C(FieldType), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TypeNotIn applies the NotIn predicate on the "type" field.
|
// TypeNotIn applies the NotIn predicate on the "type" field.
|
||||||
func TypeNotIn(vs ...string) predicate.Decision {
|
func TypeNotIn(vs ...string) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldType), v...))
|
s.Where(sql.NotIn(s.C(FieldType), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -699,34 +627,22 @@ func StartIPNEQ(v int64) predicate.Decision {
|
||||||
|
|
||||||
// StartIPIn applies the In predicate on the "start_ip" field.
|
// StartIPIn applies the In predicate on the "start_ip" field.
|
||||||
func StartIPIn(vs ...int64) predicate.Decision {
|
func StartIPIn(vs ...int64) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldStartIP), v...))
|
s.Where(sql.In(s.C(FieldStartIP), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartIPNotIn applies the NotIn predicate on the "start_ip" field.
|
// StartIPNotIn applies the NotIn predicate on the "start_ip" field.
|
||||||
func StartIPNotIn(vs ...int64) predicate.Decision {
|
func StartIPNotIn(vs ...int64) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldStartIP), v...))
|
s.Where(sql.NotIn(s.C(FieldStartIP), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -789,34 +705,22 @@ func EndIPNEQ(v int64) predicate.Decision {
|
||||||
|
|
||||||
// EndIPIn applies the In predicate on the "end_ip" field.
|
// EndIPIn applies the In predicate on the "end_ip" field.
|
||||||
func EndIPIn(vs ...int64) predicate.Decision {
|
func EndIPIn(vs ...int64) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldEndIP), v...))
|
s.Where(sql.In(s.C(FieldEndIP), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// EndIPNotIn applies the NotIn predicate on the "end_ip" field.
|
// EndIPNotIn applies the NotIn predicate on the "end_ip" field.
|
||||||
func EndIPNotIn(vs ...int64) predicate.Decision {
|
func EndIPNotIn(vs ...int64) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldEndIP), v...))
|
s.Where(sql.NotIn(s.C(FieldEndIP), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -879,34 +783,22 @@ func StartSuffixNEQ(v int64) predicate.Decision {
|
||||||
|
|
||||||
// StartSuffixIn applies the In predicate on the "start_suffix" field.
|
// StartSuffixIn applies the In predicate on the "start_suffix" field.
|
||||||
func StartSuffixIn(vs ...int64) predicate.Decision {
|
func StartSuffixIn(vs ...int64) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldStartSuffix), v...))
|
s.Where(sql.In(s.C(FieldStartSuffix), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartSuffixNotIn applies the NotIn predicate on the "start_suffix" field.
|
// StartSuffixNotIn applies the NotIn predicate on the "start_suffix" field.
|
||||||
func StartSuffixNotIn(vs ...int64) predicate.Decision {
|
func StartSuffixNotIn(vs ...int64) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldStartSuffix), v...))
|
s.Where(sql.NotIn(s.C(FieldStartSuffix), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -969,34 +861,22 @@ func EndSuffixNEQ(v int64) predicate.Decision {
|
||||||
|
|
||||||
// EndSuffixIn applies the In predicate on the "end_suffix" field.
|
// EndSuffixIn applies the In predicate on the "end_suffix" field.
|
||||||
func EndSuffixIn(vs ...int64) predicate.Decision {
|
func EndSuffixIn(vs ...int64) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldEndSuffix), v...))
|
s.Where(sql.In(s.C(FieldEndSuffix), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// EndSuffixNotIn applies the NotIn predicate on the "end_suffix" field.
|
// EndSuffixNotIn applies the NotIn predicate on the "end_suffix" field.
|
||||||
func EndSuffixNotIn(vs ...int64) predicate.Decision {
|
func EndSuffixNotIn(vs ...int64) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldEndSuffix), v...))
|
s.Where(sql.NotIn(s.C(FieldEndSuffix), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1059,34 +939,22 @@ func IPSizeNEQ(v int64) predicate.Decision {
|
||||||
|
|
||||||
// IPSizeIn applies the In predicate on the "ip_size" field.
|
// IPSizeIn applies the In predicate on the "ip_size" field.
|
||||||
func IPSizeIn(vs ...int64) predicate.Decision {
|
func IPSizeIn(vs ...int64) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldIPSize), v...))
|
s.Where(sql.In(s.C(FieldIPSize), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// IPSizeNotIn applies the NotIn predicate on the "ip_size" field.
|
// IPSizeNotIn applies the NotIn predicate on the "ip_size" field.
|
||||||
func IPSizeNotIn(vs ...int64) predicate.Decision {
|
func IPSizeNotIn(vs ...int64) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldIPSize), v...))
|
s.Where(sql.NotIn(s.C(FieldIPSize), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1149,34 +1017,22 @@ func ScopeNEQ(v string) predicate.Decision {
|
||||||
|
|
||||||
// ScopeIn applies the In predicate on the "scope" field.
|
// ScopeIn applies the In predicate on the "scope" field.
|
||||||
func ScopeIn(vs ...string) predicate.Decision {
|
func ScopeIn(vs ...string) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldScope), v...))
|
s.Where(sql.In(s.C(FieldScope), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScopeNotIn applies the NotIn predicate on the "scope" field.
|
// ScopeNotIn applies the NotIn predicate on the "scope" field.
|
||||||
func ScopeNotIn(vs ...string) predicate.Decision {
|
func ScopeNotIn(vs ...string) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldScope), v...))
|
s.Where(sql.NotIn(s.C(FieldScope), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1260,34 +1116,22 @@ func ValueNEQ(v string) predicate.Decision {
|
||||||
|
|
||||||
// ValueIn applies the In predicate on the "value" field.
|
// ValueIn applies the In predicate on the "value" field.
|
||||||
func ValueIn(vs ...string) predicate.Decision {
|
func ValueIn(vs ...string) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldValue), v...))
|
s.Where(sql.In(s.C(FieldValue), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValueNotIn applies the NotIn predicate on the "value" field.
|
// ValueNotIn applies the NotIn predicate on the "value" field.
|
||||||
func ValueNotIn(vs ...string) predicate.Decision {
|
func ValueNotIn(vs ...string) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldValue), v...))
|
s.Where(sql.NotIn(s.C(FieldValue), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1371,34 +1215,22 @@ func OriginNEQ(v string) predicate.Decision {
|
||||||
|
|
||||||
// OriginIn applies the In predicate on the "origin" field.
|
// OriginIn applies the In predicate on the "origin" field.
|
||||||
func OriginIn(vs ...string) predicate.Decision {
|
func OriginIn(vs ...string) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldOrigin), v...))
|
s.Where(sql.In(s.C(FieldOrigin), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// OriginNotIn applies the NotIn predicate on the "origin" field.
|
// OriginNotIn applies the NotIn predicate on the "origin" field.
|
||||||
func OriginNotIn(vs ...string) predicate.Decision {
|
func OriginNotIn(vs ...string) predicate.Decision {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Decision(func(s *sql.Selector) {
|
return predicate.Decision(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldOrigin), v...))
|
s.Where(sql.NotIn(s.C(FieldOrigin), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -236,9 +236,15 @@ func (dc *DecisionCreate) Save(ctx context.Context) (*Decision, error) {
|
||||||
}
|
}
|
||||||
mut = dc.hooks[i](mut)
|
mut = dc.hooks[i](mut)
|
||||||
}
|
}
|
||||||
if _, err := mut.Mutate(ctx, dc.mutation); err != nil {
|
v, err := mut.Mutate(ctx, dc.mutation)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
nv, ok := v.(*Decision)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected node type %T returned from DecisionMutation", v)
|
||||||
|
}
|
||||||
|
node = nv
|
||||||
}
|
}
|
||||||
return node, err
|
return node, err
|
||||||
}
|
}
|
||||||
|
@ -308,7 +314,7 @@ func (dc *DecisionCreate) sqlSave(ctx context.Context) (*Decision, error) {
|
||||||
_node, _spec := dc.createSpec()
|
_node, _spec := dc.createSpec()
|
||||||
if err := sqlgraph.CreateNode(ctx, dc.driver, _spec); err != nil {
|
if err := sqlgraph.CreateNode(ctx, dc.driver, _spec); err != nil {
|
||||||
if sqlgraph.IsConstraintError(err) {
|
if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -496,7 +502,7 @@ func (dcb *DecisionCreateBulk) Save(ctx context.Context) ([]*Decision, error) {
|
||||||
// Invoke the actual operation on the latest mutation in the chain.
|
// Invoke the actual operation on the latest mutation in the chain.
|
||||||
if err = sqlgraph.BatchCreate(ctx, dcb.driver, spec); err != nil {
|
if err = sqlgraph.BatchCreate(ctx, dcb.driver, spec); err != nil {
|
||||||
if sqlgraph.IsConstraintError(err) {
|
if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -504,11 +510,11 @@ func (dcb *DecisionCreateBulk) Save(ctx context.Context) ([]*Decision, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
mutation.id = &nodes[i].ID
|
mutation.id = &nodes[i].ID
|
||||||
mutation.done = true
|
|
||||||
if specs[i].ID.Value != nil {
|
if specs[i].ID.Value != nil {
|
||||||
id := specs[i].ID.Value.(int64)
|
id := specs[i].ID.Value.(int64)
|
||||||
nodes[i].ID = int(id)
|
nodes[i].ID = int(id)
|
||||||
}
|
}
|
||||||
|
mutation.done = true
|
||||||
return nodes[i], nil
|
return nodes[i], nil
|
||||||
})
|
})
|
||||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -84,7 +84,11 @@ func (dd *DecisionDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sqlgraph.DeleteNodes(ctx, dd.driver, _spec)
|
affected, err := sqlgraph.DeleteNodes(ctx, dd.driver, _spec)
|
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return affected, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecisionDeleteOne is the builder for deleting a single Decision entity.
|
// DecisionDeleteOne is the builder for deleting a single Decision entity.
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
|
@ -25,9 +24,8 @@ type DecisionQuery struct {
|
||||||
order []OrderFunc
|
order []OrderFunc
|
||||||
fields []string
|
fields []string
|
||||||
predicates []predicate.Decision
|
predicates []predicate.Decision
|
||||||
// eager-loading edges.
|
withOwner *AlertQuery
|
||||||
withOwner *AlertQuery
|
withFKs bool
|
||||||
withFKs bool
|
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
sql *sql.Selector
|
sql *sql.Selector
|
||||||
path func(context.Context) (*sql.Selector, error)
|
path func(context.Context) (*sql.Selector, error)
|
||||||
|
@ -300,17 +298,18 @@ func (dq *DecisionQuery) WithOwner(opts ...func(*AlertQuery)) *DecisionQuery {
|
||||||
// GroupBy(decision.FieldCreatedAt).
|
// GroupBy(decision.FieldCreatedAt).
|
||||||
// Aggregate(ent.Count()).
|
// Aggregate(ent.Count()).
|
||||||
// Scan(ctx, &v)
|
// Scan(ctx, &v)
|
||||||
//
|
|
||||||
func (dq *DecisionQuery) GroupBy(field string, fields ...string) *DecisionGroupBy {
|
func (dq *DecisionQuery) GroupBy(field string, fields ...string) *DecisionGroupBy {
|
||||||
group := &DecisionGroupBy{config: dq.config}
|
grbuild := &DecisionGroupBy{config: dq.config}
|
||||||
group.fields = append([]string{field}, fields...)
|
grbuild.fields = append([]string{field}, fields...)
|
||||||
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
||||||
if err := dq.prepareQuery(ctx); err != nil {
|
if err := dq.prepareQuery(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return dq.sqlQuery(ctx), nil
|
return dq.sqlQuery(ctx), nil
|
||||||
}
|
}
|
||||||
return group
|
grbuild.label = decision.Label
|
||||||
|
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan
|
||||||
|
return grbuild
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select allows the selection one or more fields/columns for the given query,
|
// Select allows the selection one or more fields/columns for the given query,
|
||||||
|
@ -325,10 +324,12 @@ func (dq *DecisionQuery) GroupBy(field string, fields ...string) *DecisionGroupB
|
||||||
// client.Decision.Query().
|
// client.Decision.Query().
|
||||||
// Select(decision.FieldCreatedAt).
|
// Select(decision.FieldCreatedAt).
|
||||||
// Scan(ctx, &v)
|
// Scan(ctx, &v)
|
||||||
//
|
|
||||||
func (dq *DecisionQuery) Select(fields ...string) *DecisionSelect {
|
func (dq *DecisionQuery) Select(fields ...string) *DecisionSelect {
|
||||||
dq.fields = append(dq.fields, fields...)
|
dq.fields = append(dq.fields, fields...)
|
||||||
return &DecisionSelect{DecisionQuery: dq}
|
selbuild := &DecisionSelect{DecisionQuery: dq}
|
||||||
|
selbuild.label = decision.Label
|
||||||
|
selbuild.flds, selbuild.scan = &dq.fields, selbuild.Scan
|
||||||
|
return selbuild
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dq *DecisionQuery) prepareQuery(ctx context.Context) error {
|
func (dq *DecisionQuery) prepareQuery(ctx context.Context) error {
|
||||||
|
@ -347,7 +348,7 @@ func (dq *DecisionQuery) prepareQuery(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dq *DecisionQuery) sqlAll(ctx context.Context) ([]*Decision, error) {
|
func (dq *DecisionQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Decision, error) {
|
||||||
var (
|
var (
|
||||||
nodes = []*Decision{}
|
nodes = []*Decision{}
|
||||||
withFKs = dq.withFKs
|
withFKs = dq.withFKs
|
||||||
|
@ -362,56 +363,61 @@ func (dq *DecisionQuery) sqlAll(ctx context.Context) ([]*Decision, error) {
|
||||||
if withFKs {
|
if withFKs {
|
||||||
_spec.Node.Columns = append(_spec.Node.Columns, decision.ForeignKeys...)
|
_spec.Node.Columns = append(_spec.Node.Columns, decision.ForeignKeys...)
|
||||||
}
|
}
|
||||||
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
return (*Decision).scanValues(nil, columns)
|
||||||
|
}
|
||||||
|
_spec.Assign = func(columns []string, values []any) error {
|
||||||
node := &Decision{config: dq.config}
|
node := &Decision{config: dq.config}
|
||||||
nodes = append(nodes, node)
|
nodes = append(nodes, node)
|
||||||
return node.scanValues(columns)
|
|
||||||
}
|
|
||||||
_spec.Assign = func(columns []string, values []interface{}) error {
|
|
||||||
if len(nodes) == 0 {
|
|
||||||
return fmt.Errorf("ent: Assign called without calling ScanValues")
|
|
||||||
}
|
|
||||||
node := nodes[len(nodes)-1]
|
|
||||||
node.Edges.loadedTypes = loadedTypes
|
node.Edges.loadedTypes = loadedTypes
|
||||||
return node.assignValues(columns, values)
|
return node.assignValues(columns, values)
|
||||||
}
|
}
|
||||||
|
for i := range hooks {
|
||||||
|
hooks[i](ctx, _spec)
|
||||||
|
}
|
||||||
if err := sqlgraph.QueryNodes(ctx, dq.driver, _spec); err != nil {
|
if err := sqlgraph.QueryNodes(ctx, dq.driver, _spec); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(nodes) == 0 {
|
if len(nodes) == 0 {
|
||||||
return nodes, nil
|
return nodes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if query := dq.withOwner; query != nil {
|
if query := dq.withOwner; query != nil {
|
||||||
ids := make([]int, 0, len(nodes))
|
if err := dq.loadOwner(ctx, query, nodes, nil,
|
||||||
nodeids := make(map[int][]*Decision)
|
func(n *Decision, e *Alert) { n.Edges.Owner = e }); err != nil {
|
||||||
for i := range nodes {
|
|
||||||
if nodes[i].alert_decisions == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
fk := *nodes[i].alert_decisions
|
|
||||||
if _, ok := nodeids[fk]; !ok {
|
|
||||||
ids = append(ids, fk)
|
|
||||||
}
|
|
||||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
|
||||||
}
|
|
||||||
query.Where(alert.IDIn(ids...))
|
|
||||||
neighbors, err := query.All(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, n := range neighbors {
|
}
|
||||||
nodes, ok := nodeids[n.ID]
|
return nodes, nil
|
||||||
if !ok {
|
}
|
||||||
return nil, fmt.Errorf(`unexpected foreign-key "alert_decisions" returned %v`, n.ID)
|
|
||||||
}
|
func (dq *DecisionQuery) loadOwner(ctx context.Context, query *AlertQuery, nodes []*Decision, init func(*Decision), assign func(*Decision, *Alert)) error {
|
||||||
for i := range nodes {
|
ids := make([]int, 0, len(nodes))
|
||||||
nodes[i].Edges.Owner = n
|
nodeids := make(map[int][]*Decision)
|
||||||
}
|
for i := range nodes {
|
||||||
|
if nodes[i].alert_decisions == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fk := *nodes[i].alert_decisions
|
||||||
|
if _, ok := nodeids[fk]; !ok {
|
||||||
|
ids = append(ids, fk)
|
||||||
|
}
|
||||||
|
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||||
|
}
|
||||||
|
query.Where(alert.IDIn(ids...))
|
||||||
|
neighbors, err := query.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, n := range neighbors {
|
||||||
|
nodes, ok := nodeids[n.ID]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(`unexpected foreign-key "alert_decisions" returned %v`, n.ID)
|
||||||
|
}
|
||||||
|
for i := range nodes {
|
||||||
|
assign(nodes[i], n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
return nodes, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dq *DecisionQuery) sqlCount(ctx context.Context) (int, error) {
|
func (dq *DecisionQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
|
@ -424,11 +430,14 @@ func (dq *DecisionQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dq *DecisionQuery) sqlExist(ctx context.Context) (bool, error) {
|
func (dq *DecisionQuery) sqlExist(ctx context.Context) (bool, error) {
|
||||||
n, err := dq.sqlCount(ctx)
|
switch _, err := dq.FirstID(ctx); {
|
||||||
if err != nil {
|
case IsNotFound(err):
|
||||||
|
return false, nil
|
||||||
|
case err != nil:
|
||||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||||
|
default:
|
||||||
|
return true, nil
|
||||||
}
|
}
|
||||||
return n > 0, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dq *DecisionQuery) querySpec() *sqlgraph.QuerySpec {
|
func (dq *DecisionQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
|
@ -514,6 +523,7 @@ func (dq *DecisionQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||||
// DecisionGroupBy is the group-by builder for Decision entities.
|
// DecisionGroupBy is the group-by builder for Decision entities.
|
||||||
type DecisionGroupBy struct {
|
type DecisionGroupBy struct {
|
||||||
config
|
config
|
||||||
|
selector
|
||||||
fields []string
|
fields []string
|
||||||
fns []AggregateFunc
|
fns []AggregateFunc
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
|
@ -528,7 +538,7 @@ func (dgb *DecisionGroupBy) Aggregate(fns ...AggregateFunc) *DecisionGroupBy {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan applies the group-by query and scans the result into the given value.
|
// Scan applies the group-by query and scans the result into the given value.
|
||||||
func (dgb *DecisionGroupBy) Scan(ctx context.Context, v interface{}) error {
|
func (dgb *DecisionGroupBy) Scan(ctx context.Context, v any) error {
|
||||||
query, err := dgb.path(ctx)
|
query, err := dgb.path(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -537,210 +547,7 @@ func (dgb *DecisionGroupBy) Scan(ctx context.Context, v interface{}) error {
|
||||||
return dgb.sqlScan(ctx, v)
|
return dgb.sqlScan(ctx, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScanX is like Scan, but panics if an error occurs.
|
func (dgb *DecisionGroupBy) sqlScan(ctx context.Context, v any) error {
|
||||||
func (dgb *DecisionGroupBy) ScanX(ctx context.Context, v interface{}) {
|
|
||||||
if err := dgb.Scan(ctx, v); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strings returns list of strings from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (dgb *DecisionGroupBy) Strings(ctx context.Context) ([]string, error) {
|
|
||||||
if len(dgb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: DecisionGroupBy.Strings is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []string
|
|
||||||
if err := dgb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringsX is like Strings, but panics if an error occurs.
|
|
||||||
func (dgb *DecisionGroupBy) StringsX(ctx context.Context) []string {
|
|
||||||
v, err := dgb.Strings(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns a single string from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (dgb *DecisionGroupBy) String(ctx context.Context) (_ string, err error) {
|
|
||||||
var v []string
|
|
||||||
if v, err = dgb.Strings(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{decision.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: DecisionGroupBy.Strings returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringX is like String, but panics if an error occurs.
|
|
||||||
func (dgb *DecisionGroupBy) StringX(ctx context.Context) string {
|
|
||||||
v, err := dgb.String(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ints returns list of ints from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (dgb *DecisionGroupBy) Ints(ctx context.Context) ([]int, error) {
|
|
||||||
if len(dgb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: DecisionGroupBy.Ints is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []int
|
|
||||||
if err := dgb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntsX is like Ints, but panics if an error occurs.
|
|
||||||
func (dgb *DecisionGroupBy) IntsX(ctx context.Context) []int {
|
|
||||||
v, err := dgb.Ints(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int returns a single int from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (dgb *DecisionGroupBy) Int(ctx context.Context) (_ int, err error) {
|
|
||||||
var v []int
|
|
||||||
if v, err = dgb.Ints(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{decision.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: DecisionGroupBy.Ints returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntX is like Int, but panics if an error occurs.
|
|
||||||
func (dgb *DecisionGroupBy) IntX(ctx context.Context) int {
|
|
||||||
v, err := dgb.Int(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64s returns list of float64s from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (dgb *DecisionGroupBy) Float64s(ctx context.Context) ([]float64, error) {
|
|
||||||
if len(dgb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: DecisionGroupBy.Float64s is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []float64
|
|
||||||
if err := dgb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64sX is like Float64s, but panics if an error occurs.
|
|
||||||
func (dgb *DecisionGroupBy) Float64sX(ctx context.Context) []float64 {
|
|
||||||
v, err := dgb.Float64s(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64 returns a single float64 from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (dgb *DecisionGroupBy) Float64(ctx context.Context) (_ float64, err error) {
|
|
||||||
var v []float64
|
|
||||||
if v, err = dgb.Float64s(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{decision.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: DecisionGroupBy.Float64s returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64X is like Float64, but panics if an error occurs.
|
|
||||||
func (dgb *DecisionGroupBy) Float64X(ctx context.Context) float64 {
|
|
||||||
v, err := dgb.Float64(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bools returns list of bools from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (dgb *DecisionGroupBy) Bools(ctx context.Context) ([]bool, error) {
|
|
||||||
if len(dgb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: DecisionGroupBy.Bools is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []bool
|
|
||||||
if err := dgb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolsX is like Bools, but panics if an error occurs.
|
|
||||||
func (dgb *DecisionGroupBy) BoolsX(ctx context.Context) []bool {
|
|
||||||
v, err := dgb.Bools(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bool returns a single bool from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (dgb *DecisionGroupBy) Bool(ctx context.Context) (_ bool, err error) {
|
|
||||||
var v []bool
|
|
||||||
if v, err = dgb.Bools(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{decision.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: DecisionGroupBy.Bools returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolX is like Bool, but panics if an error occurs.
|
|
||||||
func (dgb *DecisionGroupBy) BoolX(ctx context.Context) bool {
|
|
||||||
v, err := dgb.Bool(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dgb *DecisionGroupBy) sqlScan(ctx context.Context, v interface{}) error {
|
|
||||||
for _, f := range dgb.fields {
|
for _, f := range dgb.fields {
|
||||||
if !decision.ValidColumn(f) {
|
if !decision.ValidColumn(f) {
|
||||||
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
|
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
|
||||||
|
@ -781,12 +588,13 @@ func (dgb *DecisionGroupBy) sqlQuery() *sql.Selector {
|
||||||
// DecisionSelect is the builder for selecting fields of Decision entities.
|
// DecisionSelect is the builder for selecting fields of Decision entities.
|
||||||
type DecisionSelect struct {
|
type DecisionSelect struct {
|
||||||
*DecisionQuery
|
*DecisionQuery
|
||||||
|
selector
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
sql *sql.Selector
|
sql *sql.Selector
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan applies the selector query and scans the result into the given value.
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
func (ds *DecisionSelect) Scan(ctx context.Context, v interface{}) error {
|
func (ds *DecisionSelect) Scan(ctx context.Context, v any) error {
|
||||||
if err := ds.prepareQuery(ctx); err != nil {
|
if err := ds.prepareQuery(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -794,202 +602,7 @@ func (ds *DecisionSelect) Scan(ctx context.Context, v interface{}) error {
|
||||||
return ds.sqlScan(ctx, v)
|
return ds.sqlScan(ctx, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScanX is like Scan, but panics if an error occurs.
|
func (ds *DecisionSelect) sqlScan(ctx context.Context, v any) error {
|
||||||
func (ds *DecisionSelect) ScanX(ctx context.Context, v interface{}) {
|
|
||||||
if err := ds.Scan(ctx, v); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ds *DecisionSelect) Strings(ctx context.Context) ([]string, error) {
|
|
||||||
if len(ds.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: DecisionSelect.Strings is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []string
|
|
||||||
if err := ds.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringsX is like Strings, but panics if an error occurs.
|
|
||||||
func (ds *DecisionSelect) StringsX(ctx context.Context) []string {
|
|
||||||
v, err := ds.Strings(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns a single string from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ds *DecisionSelect) String(ctx context.Context) (_ string, err error) {
|
|
||||||
var v []string
|
|
||||||
if v, err = ds.Strings(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{decision.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: DecisionSelect.Strings returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringX is like String, but panics if an error occurs.
|
|
||||||
func (ds *DecisionSelect) StringX(ctx context.Context) string {
|
|
||||||
v, err := ds.String(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ds *DecisionSelect) Ints(ctx context.Context) ([]int, error) {
|
|
||||||
if len(ds.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: DecisionSelect.Ints is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []int
|
|
||||||
if err := ds.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntsX is like Ints, but panics if an error occurs.
|
|
||||||
func (ds *DecisionSelect) IntsX(ctx context.Context) []int {
|
|
||||||
v, err := ds.Ints(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int returns a single int from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ds *DecisionSelect) Int(ctx context.Context) (_ int, err error) {
|
|
||||||
var v []int
|
|
||||||
if v, err = ds.Ints(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{decision.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: DecisionSelect.Ints returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntX is like Int, but panics if an error occurs.
|
|
||||||
func (ds *DecisionSelect) IntX(ctx context.Context) int {
|
|
||||||
v, err := ds.Int(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ds *DecisionSelect) Float64s(ctx context.Context) ([]float64, error) {
|
|
||||||
if len(ds.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: DecisionSelect.Float64s is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []float64
|
|
||||||
if err := ds.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64sX is like Float64s, but panics if an error occurs.
|
|
||||||
func (ds *DecisionSelect) Float64sX(ctx context.Context) []float64 {
|
|
||||||
v, err := ds.Float64s(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ds *DecisionSelect) Float64(ctx context.Context) (_ float64, err error) {
|
|
||||||
var v []float64
|
|
||||||
if v, err = ds.Float64s(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{decision.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: DecisionSelect.Float64s returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64X is like Float64, but panics if an error occurs.
|
|
||||||
func (ds *DecisionSelect) Float64X(ctx context.Context) float64 {
|
|
||||||
v, err := ds.Float64(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ds *DecisionSelect) Bools(ctx context.Context) ([]bool, error) {
|
|
||||||
if len(ds.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: DecisionSelect.Bools is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []bool
|
|
||||||
if err := ds.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolsX is like Bools, but panics if an error occurs.
|
|
||||||
func (ds *DecisionSelect) BoolsX(ctx context.Context) []bool {
|
|
||||||
v, err := ds.Bools(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ds *DecisionSelect) Bool(ctx context.Context) (_ bool, err error) {
|
|
||||||
var v []bool
|
|
||||||
if v, err = ds.Bools(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{decision.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: DecisionSelect.Bools returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolX is like Bool, but panics if an error occurs.
|
|
||||||
func (ds *DecisionSelect) BoolX(ctx context.Context) bool {
|
|
||||||
v, err := ds.Bool(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ds *DecisionSelect) sqlScan(ctx context.Context, v interface{}) error {
|
|
||||||
rows := &sql.Rows{}
|
rows := &sql.Rows{}
|
||||||
query, args := ds.sql.Query()
|
query, args := ds.sql.Query()
|
||||||
if err := ds.driver.Query(ctx, query, args, rows); err != nil {
|
if err := ds.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -587,7 +587,7 @@ func (du *DecisionUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
err = &NotFoundError{decision.Label}
|
err = &NotFoundError{decision.Label}
|
||||||
} else if sqlgraph.IsConstraintError(err) {
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -888,9 +888,15 @@ func (duo *DecisionUpdateOne) Save(ctx context.Context) (*Decision, error) {
|
||||||
}
|
}
|
||||||
mut = duo.hooks[i](mut)
|
mut = duo.hooks[i](mut)
|
||||||
}
|
}
|
||||||
if _, err := mut.Mutate(ctx, duo.mutation); err != nil {
|
v, err := mut.Mutate(ctx, duo.mutation)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
nv, ok := v.(*Decision)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected node type %T returned from DecisionMutation", v)
|
||||||
|
}
|
||||||
|
node = nv
|
||||||
}
|
}
|
||||||
return node, err
|
return node, err
|
||||||
}
|
}
|
||||||
|
@ -1187,7 +1193,7 @@ func (duo *DecisionUpdateOne) sqlSave(ctx context.Context) (_node *Decision, err
|
||||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
err = &NotFoundError{decision.Label}
|
err = &NotFoundError{decision.Label}
|
||||||
} else if sqlgraph.IsConstraintError(err) {
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"entgo.io/ent"
|
"entgo.io/ent"
|
||||||
"entgo.io/ent/dialect/sql"
|
"entgo.io/ent/dialect/sql"
|
||||||
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
|
"github.com/crowdsecurity/crowdsec/pkg/database/ent/alert"
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/database/ent/bouncer"
|
"github.com/crowdsecurity/crowdsec/pkg/database/ent/bouncer"
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/database/ent/decision"
|
"github.com/crowdsecurity/crowdsec/pkg/database/ent/decision"
|
||||||
|
@ -89,7 +91,6 @@ type AggregateFunc func(*sql.Selector) string
|
||||||
// GroupBy(field1, field2).
|
// GroupBy(field1, field2).
|
||||||
// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
|
// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
|
||||||
// Scan(ctx, &v)
|
// Scan(ctx, &v)
|
||||||
//
|
|
||||||
func As(fn AggregateFunc, end string) AggregateFunc {
|
func As(fn AggregateFunc, end string) AggregateFunc {
|
||||||
return func(s *sql.Selector) string {
|
return func(s *sql.Selector) string {
|
||||||
return sql.As(fn(s), end)
|
return sql.As(fn(s), end)
|
||||||
|
@ -267,3 +268,208 @@ func IsConstraintError(err error) bool {
|
||||||
var e *ConstraintError
|
var e *ConstraintError
|
||||||
return errors.As(err, &e)
|
return errors.As(err, &e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// selector embedded by the different Select/GroupBy builders.
|
||||||
|
type selector struct {
|
||||||
|
label string
|
||||||
|
flds *[]string
|
||||||
|
scan func(context.Context, any) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// ScanX is like Scan, but panics if an error occurs.
|
||||||
|
func (s *selector) ScanX(ctx context.Context, v any) {
|
||||||
|
if err := s.scan(ctx, v); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
|
||||||
|
func (s *selector) Strings(ctx context.Context) ([]string, error) {
|
||||||
|
if len(*s.flds) > 1 {
|
||||||
|
return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field")
|
||||||
|
}
|
||||||
|
var v []string
|
||||||
|
if err := s.scan(ctx, &v); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// StringsX is like Strings, but panics if an error occurs.
|
||||||
|
func (s *selector) StringsX(ctx context.Context) []string {
|
||||||
|
v, err := s.Strings(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// String returns a single string from a selector. It is only allowed when selecting one field.
|
||||||
|
func (s *selector) String(ctx context.Context) (_ string, err error) {
|
||||||
|
var v []string
|
||||||
|
if v, err = s.Strings(ctx); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(v) {
|
||||||
|
case 1:
|
||||||
|
return v[0], nil
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{s.label}
|
||||||
|
default:
|
||||||
|
err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// StringX is like String, but panics if an error occurs.
|
||||||
|
func (s *selector) StringX(ctx context.Context) string {
|
||||||
|
v, err := s.String(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
|
||||||
|
func (s *selector) Ints(ctx context.Context) ([]int, error) {
|
||||||
|
if len(*s.flds) > 1 {
|
||||||
|
return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field")
|
||||||
|
}
|
||||||
|
var v []int
|
||||||
|
if err := s.scan(ctx, &v); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IntsX is like Ints, but panics if an error occurs.
|
||||||
|
func (s *selector) IntsX(ctx context.Context) []int {
|
||||||
|
v, err := s.Ints(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Int returns a single int from a selector. It is only allowed when selecting one field.
|
||||||
|
func (s *selector) Int(ctx context.Context) (_ int, err error) {
|
||||||
|
var v []int
|
||||||
|
if v, err = s.Ints(ctx); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(v) {
|
||||||
|
case 1:
|
||||||
|
return v[0], nil
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{s.label}
|
||||||
|
default:
|
||||||
|
err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// IntX is like Int, but panics if an error occurs.
|
||||||
|
func (s *selector) IntX(ctx context.Context) int {
|
||||||
|
v, err := s.Int(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
|
||||||
|
func (s *selector) Float64s(ctx context.Context) ([]float64, error) {
|
||||||
|
if len(*s.flds) > 1 {
|
||||||
|
return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field")
|
||||||
|
}
|
||||||
|
var v []float64
|
||||||
|
if err := s.scan(ctx, &v); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Float64sX is like Float64s, but panics if an error occurs.
|
||||||
|
func (s *selector) Float64sX(ctx context.Context) []float64 {
|
||||||
|
v, err := s.Float64s(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
|
||||||
|
func (s *selector) Float64(ctx context.Context) (_ float64, err error) {
|
||||||
|
var v []float64
|
||||||
|
if v, err = s.Float64s(ctx); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(v) {
|
||||||
|
case 1:
|
||||||
|
return v[0], nil
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{s.label}
|
||||||
|
default:
|
||||||
|
err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Float64X is like Float64, but panics if an error occurs.
|
||||||
|
func (s *selector) Float64X(ctx context.Context) float64 {
|
||||||
|
v, err := s.Float64(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
|
||||||
|
func (s *selector) Bools(ctx context.Context) ([]bool, error) {
|
||||||
|
if len(*s.flds) > 1 {
|
||||||
|
return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field")
|
||||||
|
}
|
||||||
|
var v []bool
|
||||||
|
if err := s.scan(ctx, &v); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return v, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// BoolsX is like Bools, but panics if an error occurs.
|
||||||
|
func (s *selector) BoolsX(ctx context.Context) []bool {
|
||||||
|
v, err := s.Bools(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
|
||||||
|
func (s *selector) Bool(ctx context.Context) (_ bool, err error) {
|
||||||
|
var v []bool
|
||||||
|
if v, err = s.Bools(ctx); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch len(v) {
|
||||||
|
case 1:
|
||||||
|
return v[0], nil
|
||||||
|
case 0:
|
||||||
|
err = &NotFoundError{s.label}
|
||||||
|
default:
|
||||||
|
err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// BoolX is like Bool, but panics if an error occurs.
|
||||||
|
func (s *selector) BoolX(ctx context.Context) bool {
|
||||||
|
v, err := s.Bool(ctx)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
// queryHook describes an internal hook for the different sqlAll methods.
|
||||||
|
type queryHook func(context.Context, *sqlgraph.QuerySpec)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package enttest
|
package enttest
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import (
|
||||||
_ "github.com/crowdsecurity/crowdsec/pkg/database/ent/runtime"
|
_ "github.com/crowdsecurity/crowdsec/pkg/database/ent/runtime"
|
||||||
|
|
||||||
"entgo.io/ent/dialect/sql/schema"
|
"entgo.io/ent/dialect/sql/schema"
|
||||||
|
"github.com/crowdsecurity/crowdsec/pkg/database/ent/migrate"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
@ -17,7 +18,7 @@ type (
|
||||||
// testing.T and testing.B and used by enttest.
|
// testing.T and testing.B and used by enttest.
|
||||||
TestingT interface {
|
TestingT interface {
|
||||||
FailNow()
|
FailNow()
|
||||||
Error(...interface{})
|
Error(...any)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Option configures client creation.
|
// Option configures client creation.
|
||||||
|
@ -59,10 +60,7 @@ func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Cl
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
if err := c.Schema.Create(context.Background(), o.migrateOpts...); err != nil {
|
migrateSchema(t, c, o)
|
||||||
t.Error(err)
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,9 +68,17 @@ func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Cl
|
||||||
func NewClient(t TestingT, opts ...Option) *ent.Client {
|
func NewClient(t TestingT, opts ...Option) *ent.Client {
|
||||||
o := newOptions(opts)
|
o := newOptions(opts)
|
||||||
c := ent.NewClient(o.opts...)
|
c := ent.NewClient(o.opts...)
|
||||||
if err := c.Schema.Create(context.Background(), o.migrateOpts...); err != nil {
|
migrateSchema(t, c, o)
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
func migrateSchema(t TestingT, c *ent.Client, o *options) {
|
||||||
|
tables, err := schema.CopyTables(migrate.Tables)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
t.FailNow()
|
||||||
|
}
|
||||||
|
if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
return c
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -45,8 +45,7 @@ type EventEdges struct {
|
||||||
func (e EventEdges) OwnerOrErr() (*Alert, error) {
|
func (e EventEdges) OwnerOrErr() (*Alert, error) {
|
||||||
if e.loadedTypes[0] {
|
if e.loadedTypes[0] {
|
||||||
if e.Owner == nil {
|
if e.Owner == nil {
|
||||||
// The edge owner was loaded in eager-loading,
|
// Edge was loaded but was not found.
|
||||||
// but was not found.
|
|
||||||
return nil, &NotFoundError{label: alert.Label}
|
return nil, &NotFoundError{label: alert.Label}
|
||||||
}
|
}
|
||||||
return e.Owner, nil
|
return e.Owner, nil
|
||||||
|
@ -55,8 +54,8 @@ func (e EventEdges) OwnerOrErr() (*Alert, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// scanValues returns the types for scanning values from sql.Rows.
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
func (*Event) scanValues(columns []string) ([]interface{}, error) {
|
func (*Event) scanValues(columns []string) ([]any, error) {
|
||||||
values := make([]interface{}, len(columns))
|
values := make([]any, len(columns))
|
||||||
for i := range columns {
|
for i := range columns {
|
||||||
switch columns[i] {
|
switch columns[i] {
|
||||||
case event.FieldID:
|
case event.FieldID:
|
||||||
|
@ -76,7 +75,7 @@ func (*Event) scanValues(columns []string) ([]interface{}, error) {
|
||||||
|
|
||||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||||
// to the Event fields.
|
// to the Event fields.
|
||||||
func (e *Event) assignValues(columns []string, values []interface{}) error {
|
func (e *Event) assignValues(columns []string, values []any) error {
|
||||||
if m, n := len(values), len(columns); m < n {
|
if m, n := len(values), len(columns); m < n {
|
||||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||||
}
|
}
|
||||||
|
@ -141,11 +140,11 @@ func (e *Event) Update() *EventUpdateOne {
|
||||||
// Unwrap unwraps the Event entity that was returned from a transaction after it was closed,
|
// Unwrap unwraps the Event entity that was returned from a transaction after it was closed,
|
||||||
// so that all future queries will be executed through the driver which created the transaction.
|
// so that all future queries will be executed through the driver which created the transaction.
|
||||||
func (e *Event) Unwrap() *Event {
|
func (e *Event) Unwrap() *Event {
|
||||||
tx, ok := e.config.driver.(*txDriver)
|
_tx, ok := e.config.driver.(*txDriver)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("ent: Event is not a transactional entity")
|
panic("ent: Event is not a transactional entity")
|
||||||
}
|
}
|
||||||
e.config.driver = tx.drv
|
e.config.driver = _tx.drv
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,18 +152,21 @@ func (e *Event) Unwrap() *Event {
|
||||||
func (e *Event) String() string {
|
func (e *Event) String() string {
|
||||||
var builder strings.Builder
|
var builder strings.Builder
|
||||||
builder.WriteString("Event(")
|
builder.WriteString("Event(")
|
||||||
builder.WriteString(fmt.Sprintf("id=%v", e.ID))
|
builder.WriteString(fmt.Sprintf("id=%v, ", e.ID))
|
||||||
if v := e.CreatedAt; v != nil {
|
if v := e.CreatedAt; v != nil {
|
||||||
builder.WriteString(", created_at=")
|
builder.WriteString("created_at=")
|
||||||
builder.WriteString(v.Format(time.ANSIC))
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
}
|
}
|
||||||
|
builder.WriteString(", ")
|
||||||
if v := e.UpdatedAt; v != nil {
|
if v := e.UpdatedAt; v != nil {
|
||||||
builder.WriteString(", updated_at=")
|
builder.WriteString("updated_at=")
|
||||||
builder.WriteString(v.Format(time.ANSIC))
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
}
|
}
|
||||||
builder.WriteString(", time=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("time=")
|
||||||
builder.WriteString(e.Time.Format(time.ANSIC))
|
builder.WriteString(e.Time.Format(time.ANSIC))
|
||||||
builder.WriteString(", serialized=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("serialized=")
|
||||||
builder.WriteString(e.Serialized)
|
builder.WriteString(e.Serialized)
|
||||||
builder.WriteByte(')')
|
builder.WriteByte(')')
|
||||||
return builder.String()
|
return builder.String()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package event
|
package event
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package event
|
package event
|
||||||
|
|
||||||
|
@ -34,13 +34,7 @@ func IDNEQ(id int) predicate.Event {
|
||||||
// IDIn applies the In predicate on the ID field.
|
// IDIn applies the In predicate on the ID field.
|
||||||
func IDIn(ids ...int) predicate.Event {
|
func IDIn(ids ...int) predicate.Event {
|
||||||
return predicate.Event(func(s *sql.Selector) {
|
return predicate.Event(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
v := make([]any, len(ids))
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(ids) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
v := make([]interface{}, len(ids))
|
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = ids[i]
|
v[i] = ids[i]
|
||||||
}
|
}
|
||||||
|
@ -51,13 +45,7 @@ func IDIn(ids ...int) predicate.Event {
|
||||||
// IDNotIn applies the NotIn predicate on the ID field.
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
func IDNotIn(ids ...int) predicate.Event {
|
func IDNotIn(ids ...int) predicate.Event {
|
||||||
return predicate.Event(func(s *sql.Selector) {
|
return predicate.Event(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
v := make([]any, len(ids))
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(ids) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
v := make([]interface{}, len(ids))
|
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = ids[i]
|
v[i] = ids[i]
|
||||||
}
|
}
|
||||||
|
@ -137,34 +125,22 @@ func CreatedAtNEQ(v time.Time) predicate.Event {
|
||||||
|
|
||||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||||
func CreatedAtIn(vs ...time.Time) predicate.Event {
|
func CreatedAtIn(vs ...time.Time) predicate.Event {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Event(func(s *sql.Selector) {
|
return predicate.Event(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldCreatedAt), v...))
|
s.Where(sql.In(s.C(FieldCreatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||||
func CreatedAtNotIn(vs ...time.Time) predicate.Event {
|
func CreatedAtNotIn(vs ...time.Time) predicate.Event {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Event(func(s *sql.Selector) {
|
return predicate.Event(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
|
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -227,34 +203,22 @@ func UpdatedAtNEQ(v time.Time) predicate.Event {
|
||||||
|
|
||||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||||
func UpdatedAtIn(vs ...time.Time) predicate.Event {
|
func UpdatedAtIn(vs ...time.Time) predicate.Event {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Event(func(s *sql.Selector) {
|
return predicate.Event(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
|
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||||
func UpdatedAtNotIn(vs ...time.Time) predicate.Event {
|
func UpdatedAtNotIn(vs ...time.Time) predicate.Event {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Event(func(s *sql.Selector) {
|
return predicate.Event(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
|
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -317,34 +281,22 @@ func TimeNEQ(v time.Time) predicate.Event {
|
||||||
|
|
||||||
// TimeIn applies the In predicate on the "time" field.
|
// TimeIn applies the In predicate on the "time" field.
|
||||||
func TimeIn(vs ...time.Time) predicate.Event {
|
func TimeIn(vs ...time.Time) predicate.Event {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Event(func(s *sql.Selector) {
|
return predicate.Event(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldTime), v...))
|
s.Where(sql.In(s.C(FieldTime), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// TimeNotIn applies the NotIn predicate on the "time" field.
|
// TimeNotIn applies the NotIn predicate on the "time" field.
|
||||||
func TimeNotIn(vs ...time.Time) predicate.Event {
|
func TimeNotIn(vs ...time.Time) predicate.Event {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Event(func(s *sql.Selector) {
|
return predicate.Event(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldTime), v...))
|
s.Where(sql.NotIn(s.C(FieldTime), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -393,34 +345,22 @@ func SerializedNEQ(v string) predicate.Event {
|
||||||
|
|
||||||
// SerializedIn applies the In predicate on the "serialized" field.
|
// SerializedIn applies the In predicate on the "serialized" field.
|
||||||
func SerializedIn(vs ...string) predicate.Event {
|
func SerializedIn(vs ...string) predicate.Event {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Event(func(s *sql.Selector) {
|
return predicate.Event(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldSerialized), v...))
|
s.Where(sql.In(s.C(FieldSerialized), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SerializedNotIn applies the NotIn predicate on the "serialized" field.
|
// SerializedNotIn applies the NotIn predicate on the "serialized" field.
|
||||||
func SerializedNotIn(vs ...string) predicate.Event {
|
func SerializedNotIn(vs ...string) predicate.Event {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Event(func(s *sql.Selector) {
|
return predicate.Event(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldSerialized), v...))
|
s.Where(sql.NotIn(s.C(FieldSerialized), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -120,9 +120,15 @@ func (ec *EventCreate) Save(ctx context.Context) (*Event, error) {
|
||||||
}
|
}
|
||||||
mut = ec.hooks[i](mut)
|
mut = ec.hooks[i](mut)
|
||||||
}
|
}
|
||||||
if _, err := mut.Mutate(ctx, ec.mutation); err != nil {
|
v, err := mut.Mutate(ctx, ec.mutation)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
nv, ok := v.(*Event)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected node type %T returned from EventMutation", v)
|
||||||
|
}
|
||||||
|
node = nv
|
||||||
}
|
}
|
||||||
return node, err
|
return node, err
|
||||||
}
|
}
|
||||||
|
@ -181,7 +187,7 @@ func (ec *EventCreate) sqlSave(ctx context.Context) (*Event, error) {
|
||||||
_node, _spec := ec.createSpec()
|
_node, _spec := ec.createSpec()
|
||||||
if err := sqlgraph.CreateNode(ctx, ec.driver, _spec); err != nil {
|
if err := sqlgraph.CreateNode(ctx, ec.driver, _spec); err != nil {
|
||||||
if sqlgraph.IsConstraintError(err) {
|
if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -289,7 +295,7 @@ func (ecb *EventCreateBulk) Save(ctx context.Context) ([]*Event, error) {
|
||||||
// Invoke the actual operation on the latest mutation in the chain.
|
// Invoke the actual operation on the latest mutation in the chain.
|
||||||
if err = sqlgraph.BatchCreate(ctx, ecb.driver, spec); err != nil {
|
if err = sqlgraph.BatchCreate(ctx, ecb.driver, spec); err != nil {
|
||||||
if sqlgraph.IsConstraintError(err) {
|
if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,11 +303,11 @@ func (ecb *EventCreateBulk) Save(ctx context.Context) ([]*Event, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
mutation.id = &nodes[i].ID
|
mutation.id = &nodes[i].ID
|
||||||
mutation.done = true
|
|
||||||
if specs[i].ID.Value != nil {
|
if specs[i].ID.Value != nil {
|
||||||
id := specs[i].ID.Value.(int64)
|
id := specs[i].ID.Value.(int64)
|
||||||
nodes[i].ID = int(id)
|
nodes[i].ID = int(id)
|
||||||
}
|
}
|
||||||
|
mutation.done = true
|
||||||
return nodes[i], nil
|
return nodes[i], nil
|
||||||
})
|
})
|
||||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -84,7 +84,11 @@ func (ed *EventDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sqlgraph.DeleteNodes(ctx, ed.driver, _spec)
|
affected, err := sqlgraph.DeleteNodes(ctx, ed.driver, _spec)
|
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return affected, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// EventDeleteOne is the builder for deleting a single Event entity.
|
// EventDeleteOne is the builder for deleting a single Event entity.
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
|
@ -25,9 +24,8 @@ type EventQuery struct {
|
||||||
order []OrderFunc
|
order []OrderFunc
|
||||||
fields []string
|
fields []string
|
||||||
predicates []predicate.Event
|
predicates []predicate.Event
|
||||||
// eager-loading edges.
|
withOwner *AlertQuery
|
||||||
withOwner *AlertQuery
|
withFKs bool
|
||||||
withFKs bool
|
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
sql *sql.Selector
|
sql *sql.Selector
|
||||||
path func(context.Context) (*sql.Selector, error)
|
path func(context.Context) (*sql.Selector, error)
|
||||||
|
@ -300,17 +298,18 @@ func (eq *EventQuery) WithOwner(opts ...func(*AlertQuery)) *EventQuery {
|
||||||
// GroupBy(event.FieldCreatedAt).
|
// GroupBy(event.FieldCreatedAt).
|
||||||
// Aggregate(ent.Count()).
|
// Aggregate(ent.Count()).
|
||||||
// Scan(ctx, &v)
|
// Scan(ctx, &v)
|
||||||
//
|
|
||||||
func (eq *EventQuery) GroupBy(field string, fields ...string) *EventGroupBy {
|
func (eq *EventQuery) GroupBy(field string, fields ...string) *EventGroupBy {
|
||||||
group := &EventGroupBy{config: eq.config}
|
grbuild := &EventGroupBy{config: eq.config}
|
||||||
group.fields = append([]string{field}, fields...)
|
grbuild.fields = append([]string{field}, fields...)
|
||||||
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
||||||
if err := eq.prepareQuery(ctx); err != nil {
|
if err := eq.prepareQuery(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return eq.sqlQuery(ctx), nil
|
return eq.sqlQuery(ctx), nil
|
||||||
}
|
}
|
||||||
return group
|
grbuild.label = event.Label
|
||||||
|
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan
|
||||||
|
return grbuild
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select allows the selection one or more fields/columns for the given query,
|
// Select allows the selection one or more fields/columns for the given query,
|
||||||
|
@ -325,10 +324,12 @@ func (eq *EventQuery) GroupBy(field string, fields ...string) *EventGroupBy {
|
||||||
// client.Event.Query().
|
// client.Event.Query().
|
||||||
// Select(event.FieldCreatedAt).
|
// Select(event.FieldCreatedAt).
|
||||||
// Scan(ctx, &v)
|
// Scan(ctx, &v)
|
||||||
//
|
|
||||||
func (eq *EventQuery) Select(fields ...string) *EventSelect {
|
func (eq *EventQuery) Select(fields ...string) *EventSelect {
|
||||||
eq.fields = append(eq.fields, fields...)
|
eq.fields = append(eq.fields, fields...)
|
||||||
return &EventSelect{EventQuery: eq}
|
selbuild := &EventSelect{EventQuery: eq}
|
||||||
|
selbuild.label = event.Label
|
||||||
|
selbuild.flds, selbuild.scan = &eq.fields, selbuild.Scan
|
||||||
|
return selbuild
|
||||||
}
|
}
|
||||||
|
|
||||||
func (eq *EventQuery) prepareQuery(ctx context.Context) error {
|
func (eq *EventQuery) prepareQuery(ctx context.Context) error {
|
||||||
|
@ -347,7 +348,7 @@ func (eq *EventQuery) prepareQuery(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (eq *EventQuery) sqlAll(ctx context.Context) ([]*Event, error) {
|
func (eq *EventQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Event, error) {
|
||||||
var (
|
var (
|
||||||
nodes = []*Event{}
|
nodes = []*Event{}
|
||||||
withFKs = eq.withFKs
|
withFKs = eq.withFKs
|
||||||
|
@ -362,56 +363,61 @@ func (eq *EventQuery) sqlAll(ctx context.Context) ([]*Event, error) {
|
||||||
if withFKs {
|
if withFKs {
|
||||||
_spec.Node.Columns = append(_spec.Node.Columns, event.ForeignKeys...)
|
_spec.Node.Columns = append(_spec.Node.Columns, event.ForeignKeys...)
|
||||||
}
|
}
|
||||||
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
return (*Event).scanValues(nil, columns)
|
||||||
|
}
|
||||||
|
_spec.Assign = func(columns []string, values []any) error {
|
||||||
node := &Event{config: eq.config}
|
node := &Event{config: eq.config}
|
||||||
nodes = append(nodes, node)
|
nodes = append(nodes, node)
|
||||||
return node.scanValues(columns)
|
|
||||||
}
|
|
||||||
_spec.Assign = func(columns []string, values []interface{}) error {
|
|
||||||
if len(nodes) == 0 {
|
|
||||||
return fmt.Errorf("ent: Assign called without calling ScanValues")
|
|
||||||
}
|
|
||||||
node := nodes[len(nodes)-1]
|
|
||||||
node.Edges.loadedTypes = loadedTypes
|
node.Edges.loadedTypes = loadedTypes
|
||||||
return node.assignValues(columns, values)
|
return node.assignValues(columns, values)
|
||||||
}
|
}
|
||||||
|
for i := range hooks {
|
||||||
|
hooks[i](ctx, _spec)
|
||||||
|
}
|
||||||
if err := sqlgraph.QueryNodes(ctx, eq.driver, _spec); err != nil {
|
if err := sqlgraph.QueryNodes(ctx, eq.driver, _spec); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(nodes) == 0 {
|
if len(nodes) == 0 {
|
||||||
return nodes, nil
|
return nodes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if query := eq.withOwner; query != nil {
|
if query := eq.withOwner; query != nil {
|
||||||
ids := make([]int, 0, len(nodes))
|
if err := eq.loadOwner(ctx, query, nodes, nil,
|
||||||
nodeids := make(map[int][]*Event)
|
func(n *Event, e *Alert) { n.Edges.Owner = e }); err != nil {
|
||||||
for i := range nodes {
|
|
||||||
if nodes[i].alert_events == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
fk := *nodes[i].alert_events
|
|
||||||
if _, ok := nodeids[fk]; !ok {
|
|
||||||
ids = append(ids, fk)
|
|
||||||
}
|
|
||||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
|
||||||
}
|
|
||||||
query.Where(alert.IDIn(ids...))
|
|
||||||
neighbors, err := query.All(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, n := range neighbors {
|
}
|
||||||
nodes, ok := nodeids[n.ID]
|
return nodes, nil
|
||||||
if !ok {
|
}
|
||||||
return nil, fmt.Errorf(`unexpected foreign-key "alert_events" returned %v`, n.ID)
|
|
||||||
}
|
func (eq *EventQuery) loadOwner(ctx context.Context, query *AlertQuery, nodes []*Event, init func(*Event), assign func(*Event, *Alert)) error {
|
||||||
for i := range nodes {
|
ids := make([]int, 0, len(nodes))
|
||||||
nodes[i].Edges.Owner = n
|
nodeids := make(map[int][]*Event)
|
||||||
}
|
for i := range nodes {
|
||||||
|
if nodes[i].alert_events == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fk := *nodes[i].alert_events
|
||||||
|
if _, ok := nodeids[fk]; !ok {
|
||||||
|
ids = append(ids, fk)
|
||||||
|
}
|
||||||
|
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||||
|
}
|
||||||
|
query.Where(alert.IDIn(ids...))
|
||||||
|
neighbors, err := query.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, n := range neighbors {
|
||||||
|
nodes, ok := nodeids[n.ID]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(`unexpected foreign-key "alert_events" returned %v`, n.ID)
|
||||||
|
}
|
||||||
|
for i := range nodes {
|
||||||
|
assign(nodes[i], n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
return nodes, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (eq *EventQuery) sqlCount(ctx context.Context) (int, error) {
|
func (eq *EventQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
|
@ -424,11 +430,14 @@ func (eq *EventQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (eq *EventQuery) sqlExist(ctx context.Context) (bool, error) {
|
func (eq *EventQuery) sqlExist(ctx context.Context) (bool, error) {
|
||||||
n, err := eq.sqlCount(ctx)
|
switch _, err := eq.FirstID(ctx); {
|
||||||
if err != nil {
|
case IsNotFound(err):
|
||||||
|
return false, nil
|
||||||
|
case err != nil:
|
||||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||||
|
default:
|
||||||
|
return true, nil
|
||||||
}
|
}
|
||||||
return n > 0, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (eq *EventQuery) querySpec() *sqlgraph.QuerySpec {
|
func (eq *EventQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
|
@ -514,6 +523,7 @@ func (eq *EventQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||||
// EventGroupBy is the group-by builder for Event entities.
|
// EventGroupBy is the group-by builder for Event entities.
|
||||||
type EventGroupBy struct {
|
type EventGroupBy struct {
|
||||||
config
|
config
|
||||||
|
selector
|
||||||
fields []string
|
fields []string
|
||||||
fns []AggregateFunc
|
fns []AggregateFunc
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
|
@ -528,7 +538,7 @@ func (egb *EventGroupBy) Aggregate(fns ...AggregateFunc) *EventGroupBy {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan applies the group-by query and scans the result into the given value.
|
// Scan applies the group-by query and scans the result into the given value.
|
||||||
func (egb *EventGroupBy) Scan(ctx context.Context, v interface{}) error {
|
func (egb *EventGroupBy) Scan(ctx context.Context, v any) error {
|
||||||
query, err := egb.path(ctx)
|
query, err := egb.path(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -537,210 +547,7 @@ func (egb *EventGroupBy) Scan(ctx context.Context, v interface{}) error {
|
||||||
return egb.sqlScan(ctx, v)
|
return egb.sqlScan(ctx, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScanX is like Scan, but panics if an error occurs.
|
func (egb *EventGroupBy) sqlScan(ctx context.Context, v any) error {
|
||||||
func (egb *EventGroupBy) ScanX(ctx context.Context, v interface{}) {
|
|
||||||
if err := egb.Scan(ctx, v); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strings returns list of strings from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (egb *EventGroupBy) Strings(ctx context.Context) ([]string, error) {
|
|
||||||
if len(egb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: EventGroupBy.Strings is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []string
|
|
||||||
if err := egb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringsX is like Strings, but panics if an error occurs.
|
|
||||||
func (egb *EventGroupBy) StringsX(ctx context.Context) []string {
|
|
||||||
v, err := egb.Strings(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns a single string from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (egb *EventGroupBy) String(ctx context.Context) (_ string, err error) {
|
|
||||||
var v []string
|
|
||||||
if v, err = egb.Strings(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{event.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: EventGroupBy.Strings returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringX is like String, but panics if an error occurs.
|
|
||||||
func (egb *EventGroupBy) StringX(ctx context.Context) string {
|
|
||||||
v, err := egb.String(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ints returns list of ints from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (egb *EventGroupBy) Ints(ctx context.Context) ([]int, error) {
|
|
||||||
if len(egb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: EventGroupBy.Ints is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []int
|
|
||||||
if err := egb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntsX is like Ints, but panics if an error occurs.
|
|
||||||
func (egb *EventGroupBy) IntsX(ctx context.Context) []int {
|
|
||||||
v, err := egb.Ints(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int returns a single int from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (egb *EventGroupBy) Int(ctx context.Context) (_ int, err error) {
|
|
||||||
var v []int
|
|
||||||
if v, err = egb.Ints(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{event.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: EventGroupBy.Ints returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntX is like Int, but panics if an error occurs.
|
|
||||||
func (egb *EventGroupBy) IntX(ctx context.Context) int {
|
|
||||||
v, err := egb.Int(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64s returns list of float64s from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (egb *EventGroupBy) Float64s(ctx context.Context) ([]float64, error) {
|
|
||||||
if len(egb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: EventGroupBy.Float64s is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []float64
|
|
||||||
if err := egb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64sX is like Float64s, but panics if an error occurs.
|
|
||||||
func (egb *EventGroupBy) Float64sX(ctx context.Context) []float64 {
|
|
||||||
v, err := egb.Float64s(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64 returns a single float64 from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (egb *EventGroupBy) Float64(ctx context.Context) (_ float64, err error) {
|
|
||||||
var v []float64
|
|
||||||
if v, err = egb.Float64s(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{event.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: EventGroupBy.Float64s returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64X is like Float64, but panics if an error occurs.
|
|
||||||
func (egb *EventGroupBy) Float64X(ctx context.Context) float64 {
|
|
||||||
v, err := egb.Float64(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bools returns list of bools from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (egb *EventGroupBy) Bools(ctx context.Context) ([]bool, error) {
|
|
||||||
if len(egb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: EventGroupBy.Bools is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []bool
|
|
||||||
if err := egb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolsX is like Bools, but panics if an error occurs.
|
|
||||||
func (egb *EventGroupBy) BoolsX(ctx context.Context) []bool {
|
|
||||||
v, err := egb.Bools(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bool returns a single bool from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (egb *EventGroupBy) Bool(ctx context.Context) (_ bool, err error) {
|
|
||||||
var v []bool
|
|
||||||
if v, err = egb.Bools(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{event.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: EventGroupBy.Bools returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolX is like Bool, but panics if an error occurs.
|
|
||||||
func (egb *EventGroupBy) BoolX(ctx context.Context) bool {
|
|
||||||
v, err := egb.Bool(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
func (egb *EventGroupBy) sqlScan(ctx context.Context, v interface{}) error {
|
|
||||||
for _, f := range egb.fields {
|
for _, f := range egb.fields {
|
||||||
if !event.ValidColumn(f) {
|
if !event.ValidColumn(f) {
|
||||||
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
|
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
|
||||||
|
@ -781,12 +588,13 @@ func (egb *EventGroupBy) sqlQuery() *sql.Selector {
|
||||||
// EventSelect is the builder for selecting fields of Event entities.
|
// EventSelect is the builder for selecting fields of Event entities.
|
||||||
type EventSelect struct {
|
type EventSelect struct {
|
||||||
*EventQuery
|
*EventQuery
|
||||||
|
selector
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
sql *sql.Selector
|
sql *sql.Selector
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan applies the selector query and scans the result into the given value.
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
func (es *EventSelect) Scan(ctx context.Context, v interface{}) error {
|
func (es *EventSelect) Scan(ctx context.Context, v any) error {
|
||||||
if err := es.prepareQuery(ctx); err != nil {
|
if err := es.prepareQuery(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -794,202 +602,7 @@ func (es *EventSelect) Scan(ctx context.Context, v interface{}) error {
|
||||||
return es.sqlScan(ctx, v)
|
return es.sqlScan(ctx, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScanX is like Scan, but panics if an error occurs.
|
func (es *EventSelect) sqlScan(ctx context.Context, v any) error {
|
||||||
func (es *EventSelect) ScanX(ctx context.Context, v interface{}) {
|
|
||||||
if err := es.Scan(ctx, v); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
|
|
||||||
func (es *EventSelect) Strings(ctx context.Context) ([]string, error) {
|
|
||||||
if len(es.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: EventSelect.Strings is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []string
|
|
||||||
if err := es.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringsX is like Strings, but panics if an error occurs.
|
|
||||||
func (es *EventSelect) StringsX(ctx context.Context) []string {
|
|
||||||
v, err := es.Strings(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns a single string from a selector. It is only allowed when selecting one field.
|
|
||||||
func (es *EventSelect) String(ctx context.Context) (_ string, err error) {
|
|
||||||
var v []string
|
|
||||||
if v, err = es.Strings(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{event.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: EventSelect.Strings returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringX is like String, but panics if an error occurs.
|
|
||||||
func (es *EventSelect) StringX(ctx context.Context) string {
|
|
||||||
v, err := es.String(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
|
|
||||||
func (es *EventSelect) Ints(ctx context.Context) ([]int, error) {
|
|
||||||
if len(es.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: EventSelect.Ints is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []int
|
|
||||||
if err := es.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntsX is like Ints, but panics if an error occurs.
|
|
||||||
func (es *EventSelect) IntsX(ctx context.Context) []int {
|
|
||||||
v, err := es.Ints(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int returns a single int from a selector. It is only allowed when selecting one field.
|
|
||||||
func (es *EventSelect) Int(ctx context.Context) (_ int, err error) {
|
|
||||||
var v []int
|
|
||||||
if v, err = es.Ints(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{event.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: EventSelect.Ints returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntX is like Int, but panics if an error occurs.
|
|
||||||
func (es *EventSelect) IntX(ctx context.Context) int {
|
|
||||||
v, err := es.Int(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
|
|
||||||
func (es *EventSelect) Float64s(ctx context.Context) ([]float64, error) {
|
|
||||||
if len(es.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: EventSelect.Float64s is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []float64
|
|
||||||
if err := es.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64sX is like Float64s, but panics if an error occurs.
|
|
||||||
func (es *EventSelect) Float64sX(ctx context.Context) []float64 {
|
|
||||||
v, err := es.Float64s(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
|
|
||||||
func (es *EventSelect) Float64(ctx context.Context) (_ float64, err error) {
|
|
||||||
var v []float64
|
|
||||||
if v, err = es.Float64s(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{event.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: EventSelect.Float64s returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64X is like Float64, but panics if an error occurs.
|
|
||||||
func (es *EventSelect) Float64X(ctx context.Context) float64 {
|
|
||||||
v, err := es.Float64(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
|
|
||||||
func (es *EventSelect) Bools(ctx context.Context) ([]bool, error) {
|
|
||||||
if len(es.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: EventSelect.Bools is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []bool
|
|
||||||
if err := es.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolsX is like Bools, but panics if an error occurs.
|
|
||||||
func (es *EventSelect) BoolsX(ctx context.Context) []bool {
|
|
||||||
v, err := es.Bools(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
|
|
||||||
func (es *EventSelect) Bool(ctx context.Context) (_ bool, err error) {
|
|
||||||
var v []bool
|
|
||||||
if v, err = es.Bools(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{event.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: EventSelect.Bools returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolX is like Bool, but panics if an error occurs.
|
|
||||||
func (es *EventSelect) BoolX(ctx context.Context) bool {
|
|
||||||
v, err := es.Bool(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
func (es *EventSelect) sqlScan(ctx context.Context, v interface{}) error {
|
|
||||||
rows := &sql.Rows{}
|
rows := &sql.Rows{}
|
||||||
query, args := es.sql.Query()
|
query, args := es.sql.Query()
|
||||||
if err := es.driver.Query(ctx, query, args, rows); err != nil {
|
if err := es.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ func (eu *EventUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
err = &NotFoundError{event.Label}
|
err = &NotFoundError{event.Label}
|
||||||
} else if sqlgraph.IsConstraintError(err) {
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -395,9 +395,15 @@ func (euo *EventUpdateOne) Save(ctx context.Context) (*Event, error) {
|
||||||
}
|
}
|
||||||
mut = euo.hooks[i](mut)
|
mut = euo.hooks[i](mut)
|
||||||
}
|
}
|
||||||
if _, err := mut.Mutate(ctx, euo.mutation); err != nil {
|
v, err := mut.Mutate(ctx, euo.mutation)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
nv, ok := v.(*Event)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected node type %T returned from EventMutation", v)
|
||||||
|
}
|
||||||
|
node = nv
|
||||||
}
|
}
|
||||||
return node, err
|
return node, err
|
||||||
}
|
}
|
||||||
|
@ -563,7 +569,7 @@ func (euo *EventUpdateOne) sqlSave(ctx context.Context) (_node *Event, err error
|
||||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
err = &NotFoundError{event.Label}
|
err = &NotFoundError{event.Label}
|
||||||
} else if sqlgraph.IsConstraintError(err) {
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package hook
|
package hook
|
||||||
|
|
||||||
|
@ -182,7 +182,6 @@ func HasFields(field string, fields ...string) Condition {
|
||||||
// If executes the given hook under condition.
|
// If executes the given hook under condition.
|
||||||
//
|
//
|
||||||
// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))
|
// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))
|
||||||
//
|
|
||||||
func If(hk ent.Hook, cond Condition) ent.Hook {
|
func If(hk ent.Hook, cond Condition) ent.Hook {
|
||||||
return func(next ent.Mutator) ent.Mutator {
|
return func(next ent.Mutator) ent.Mutator {
|
||||||
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
|
||||||
|
@ -197,7 +196,6 @@ func If(hk ent.Hook, cond Condition) ent.Hook {
|
||||||
// On executes the given hook only for the given operation.
|
// On executes the given hook only for the given operation.
|
||||||
//
|
//
|
||||||
// hook.On(Log, ent.Delete|ent.Create)
|
// hook.On(Log, ent.Delete|ent.Create)
|
||||||
//
|
|
||||||
func On(hk ent.Hook, op ent.Op) ent.Hook {
|
func On(hk ent.Hook, op ent.Op) ent.Hook {
|
||||||
return If(hk, HasOp(op))
|
return If(hk, HasOp(op))
|
||||||
}
|
}
|
||||||
|
@ -205,7 +203,6 @@ func On(hk ent.Hook, op ent.Op) ent.Hook {
|
||||||
// Unless skips the given hook only for the given operation.
|
// Unless skips the given hook only for the given operation.
|
||||||
//
|
//
|
||||||
// hook.Unless(Log, ent.Update|ent.UpdateOne)
|
// hook.Unless(Log, ent.Update|ent.UpdateOne)
|
||||||
//
|
|
||||||
func Unless(hk ent.Hook, op ent.Op) ent.Hook {
|
func Unless(hk ent.Hook, op ent.Op) ent.Hook {
|
||||||
return If(hk, Not(HasOp(op)))
|
return If(hk, Not(HasOp(op)))
|
||||||
}
|
}
|
||||||
|
@ -226,7 +223,6 @@ func FixedError(err error) ent.Hook {
|
||||||
// Reject(ent.Delete|ent.Update),
|
// Reject(ent.Delete|ent.Update),
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
func Reject(op ent.Op) ent.Hook {
|
func Reject(op ent.Op) ent.Hook {
|
||||||
hk := FixedError(fmt.Errorf("%s operation is not allowed", op))
|
hk := FixedError(fmt.Errorf("%s operation is not allowed", op))
|
||||||
return On(hk, op)
|
return On(hk, op)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -64,8 +64,8 @@ func (e MachineEdges) AlertsOrErr() ([]*Alert, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// scanValues returns the types for scanning values from sql.Rows.
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
func (*Machine) scanValues(columns []string) ([]interface{}, error) {
|
func (*Machine) scanValues(columns []string) ([]any, error) {
|
||||||
values := make([]interface{}, len(columns))
|
values := make([]any, len(columns))
|
||||||
for i := range columns {
|
for i := range columns {
|
||||||
switch columns[i] {
|
switch columns[i] {
|
||||||
case machine.FieldIsValidated:
|
case machine.FieldIsValidated:
|
||||||
|
@ -85,7 +85,7 @@ func (*Machine) scanValues(columns []string) ([]interface{}, error) {
|
||||||
|
|
||||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||||
// to the Machine fields.
|
// to the Machine fields.
|
||||||
func (m *Machine) assignValues(columns []string, values []interface{}) error {
|
func (m *Machine) assignValues(columns []string, values []any) error {
|
||||||
if m, n := len(values), len(columns); m < n {
|
if m, n := len(values), len(columns); m < n {
|
||||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||||
}
|
}
|
||||||
|
@ -193,11 +193,11 @@ func (m *Machine) Update() *MachineUpdateOne {
|
||||||
// Unwrap unwraps the Machine entity that was returned from a transaction after it was closed,
|
// Unwrap unwraps the Machine entity that was returned from a transaction after it was closed,
|
||||||
// so that all future queries will be executed through the driver which created the transaction.
|
// so that all future queries will be executed through the driver which created the transaction.
|
||||||
func (m *Machine) Unwrap() *Machine {
|
func (m *Machine) Unwrap() *Machine {
|
||||||
tx, ok := m.config.driver.(*txDriver)
|
_tx, ok := m.config.driver.(*txDriver)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("ent: Machine is not a transactional entity")
|
panic("ent: Machine is not a transactional entity")
|
||||||
}
|
}
|
||||||
m.config.driver = tx.drv
|
m.config.driver = _tx.drv
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,37 +205,48 @@ func (m *Machine) Unwrap() *Machine {
|
||||||
func (m *Machine) String() string {
|
func (m *Machine) String() string {
|
||||||
var builder strings.Builder
|
var builder strings.Builder
|
||||||
builder.WriteString("Machine(")
|
builder.WriteString("Machine(")
|
||||||
builder.WriteString(fmt.Sprintf("id=%v", m.ID))
|
builder.WriteString(fmt.Sprintf("id=%v, ", m.ID))
|
||||||
if v := m.CreatedAt; v != nil {
|
if v := m.CreatedAt; v != nil {
|
||||||
builder.WriteString(", created_at=")
|
builder.WriteString("created_at=")
|
||||||
builder.WriteString(v.Format(time.ANSIC))
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
}
|
}
|
||||||
|
builder.WriteString(", ")
|
||||||
if v := m.UpdatedAt; v != nil {
|
if v := m.UpdatedAt; v != nil {
|
||||||
builder.WriteString(", updated_at=")
|
builder.WriteString("updated_at=")
|
||||||
builder.WriteString(v.Format(time.ANSIC))
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
}
|
}
|
||||||
|
builder.WriteString(", ")
|
||||||
if v := m.LastPush; v != nil {
|
if v := m.LastPush; v != nil {
|
||||||
builder.WriteString(", last_push=")
|
builder.WriteString("last_push=")
|
||||||
builder.WriteString(v.Format(time.ANSIC))
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
}
|
}
|
||||||
|
builder.WriteString(", ")
|
||||||
if v := m.LastHeartbeat; v != nil {
|
if v := m.LastHeartbeat; v != nil {
|
||||||
builder.WriteString(", last_heartbeat=")
|
builder.WriteString("last_heartbeat=")
|
||||||
builder.WriteString(v.Format(time.ANSIC))
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
}
|
}
|
||||||
builder.WriteString(", machineId=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("machineId=")
|
||||||
builder.WriteString(m.MachineId)
|
builder.WriteString(m.MachineId)
|
||||||
builder.WriteString(", password=<sensitive>")
|
builder.WriteString(", ")
|
||||||
builder.WriteString(", ipAddress=")
|
builder.WriteString("password=<sensitive>")
|
||||||
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("ipAddress=")
|
||||||
builder.WriteString(m.IpAddress)
|
builder.WriteString(m.IpAddress)
|
||||||
builder.WriteString(", scenarios=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("scenarios=")
|
||||||
builder.WriteString(m.Scenarios)
|
builder.WriteString(m.Scenarios)
|
||||||
builder.WriteString(", version=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("version=")
|
||||||
builder.WriteString(m.Version)
|
builder.WriteString(m.Version)
|
||||||
builder.WriteString(", isValidated=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("isValidated=")
|
||||||
builder.WriteString(fmt.Sprintf("%v", m.IsValidated))
|
builder.WriteString(fmt.Sprintf("%v", m.IsValidated))
|
||||||
builder.WriteString(", status=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("status=")
|
||||||
builder.WriteString(m.Status)
|
builder.WriteString(m.Status)
|
||||||
builder.WriteString(", auth_type=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("auth_type=")
|
||||||
builder.WriteString(m.AuthType)
|
builder.WriteString(m.AuthType)
|
||||||
builder.WriteByte(')')
|
builder.WriteByte(')')
|
||||||
return builder.String()
|
return builder.String()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package machine
|
package machine
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package machine
|
package machine
|
||||||
|
|
||||||
|
@ -34,13 +34,7 @@ func IDNEQ(id int) predicate.Machine {
|
||||||
// IDIn applies the In predicate on the ID field.
|
// IDIn applies the In predicate on the ID field.
|
||||||
func IDIn(ids ...int) predicate.Machine {
|
func IDIn(ids ...int) predicate.Machine {
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
v := make([]any, len(ids))
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(ids) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
v := make([]interface{}, len(ids))
|
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = ids[i]
|
v[i] = ids[i]
|
||||||
}
|
}
|
||||||
|
@ -51,13 +45,7 @@ func IDIn(ids ...int) predicate.Machine {
|
||||||
// IDNotIn applies the NotIn predicate on the ID field.
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
func IDNotIn(ids ...int) predicate.Machine {
|
func IDNotIn(ids ...int) predicate.Machine {
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
v := make([]any, len(ids))
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(ids) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
v := make([]interface{}, len(ids))
|
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = ids[i]
|
v[i] = ids[i]
|
||||||
}
|
}
|
||||||
|
@ -193,34 +181,22 @@ func CreatedAtNEQ(v time.Time) predicate.Machine {
|
||||||
|
|
||||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||||
func CreatedAtIn(vs ...time.Time) predicate.Machine {
|
func CreatedAtIn(vs ...time.Time) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldCreatedAt), v...))
|
s.Where(sql.In(s.C(FieldCreatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||||
func CreatedAtNotIn(vs ...time.Time) predicate.Machine {
|
func CreatedAtNotIn(vs ...time.Time) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
|
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -283,34 +259,22 @@ func UpdatedAtNEQ(v time.Time) predicate.Machine {
|
||||||
|
|
||||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||||
func UpdatedAtIn(vs ...time.Time) predicate.Machine {
|
func UpdatedAtIn(vs ...time.Time) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
|
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||||
func UpdatedAtNotIn(vs ...time.Time) predicate.Machine {
|
func UpdatedAtNotIn(vs ...time.Time) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
|
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -373,34 +337,22 @@ func LastPushNEQ(v time.Time) predicate.Machine {
|
||||||
|
|
||||||
// LastPushIn applies the In predicate on the "last_push" field.
|
// LastPushIn applies the In predicate on the "last_push" field.
|
||||||
func LastPushIn(vs ...time.Time) predicate.Machine {
|
func LastPushIn(vs ...time.Time) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldLastPush), v...))
|
s.Where(sql.In(s.C(FieldLastPush), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// LastPushNotIn applies the NotIn predicate on the "last_push" field.
|
// LastPushNotIn applies the NotIn predicate on the "last_push" field.
|
||||||
func LastPushNotIn(vs ...time.Time) predicate.Machine {
|
func LastPushNotIn(vs ...time.Time) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldLastPush), v...))
|
s.Where(sql.NotIn(s.C(FieldLastPush), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -463,34 +415,22 @@ func LastHeartbeatNEQ(v time.Time) predicate.Machine {
|
||||||
|
|
||||||
// LastHeartbeatIn applies the In predicate on the "last_heartbeat" field.
|
// LastHeartbeatIn applies the In predicate on the "last_heartbeat" field.
|
||||||
func LastHeartbeatIn(vs ...time.Time) predicate.Machine {
|
func LastHeartbeatIn(vs ...time.Time) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldLastHeartbeat), v...))
|
s.Where(sql.In(s.C(FieldLastHeartbeat), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// LastHeartbeatNotIn applies the NotIn predicate on the "last_heartbeat" field.
|
// LastHeartbeatNotIn applies the NotIn predicate on the "last_heartbeat" field.
|
||||||
func LastHeartbeatNotIn(vs ...time.Time) predicate.Machine {
|
func LastHeartbeatNotIn(vs ...time.Time) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldLastHeartbeat), v...))
|
s.Where(sql.NotIn(s.C(FieldLastHeartbeat), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -553,34 +493,22 @@ func MachineIdNEQ(v string) predicate.Machine {
|
||||||
|
|
||||||
// MachineIdIn applies the In predicate on the "machineId" field.
|
// MachineIdIn applies the In predicate on the "machineId" field.
|
||||||
func MachineIdIn(vs ...string) predicate.Machine {
|
func MachineIdIn(vs ...string) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldMachineId), v...))
|
s.Where(sql.In(s.C(FieldMachineId), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// MachineIdNotIn applies the NotIn predicate on the "machineId" field.
|
// MachineIdNotIn applies the NotIn predicate on the "machineId" field.
|
||||||
func MachineIdNotIn(vs ...string) predicate.Machine {
|
func MachineIdNotIn(vs ...string) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldMachineId), v...))
|
s.Where(sql.NotIn(s.C(FieldMachineId), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -664,34 +592,22 @@ func PasswordNEQ(v string) predicate.Machine {
|
||||||
|
|
||||||
// PasswordIn applies the In predicate on the "password" field.
|
// PasswordIn applies the In predicate on the "password" field.
|
||||||
func PasswordIn(vs ...string) predicate.Machine {
|
func PasswordIn(vs ...string) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldPassword), v...))
|
s.Where(sql.In(s.C(FieldPassword), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// PasswordNotIn applies the NotIn predicate on the "password" field.
|
// PasswordNotIn applies the NotIn predicate on the "password" field.
|
||||||
func PasswordNotIn(vs ...string) predicate.Machine {
|
func PasswordNotIn(vs ...string) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldPassword), v...))
|
s.Where(sql.NotIn(s.C(FieldPassword), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -775,34 +691,22 @@ func IpAddressNEQ(v string) predicate.Machine {
|
||||||
|
|
||||||
// IpAddressIn applies the In predicate on the "ipAddress" field.
|
// IpAddressIn applies the In predicate on the "ipAddress" field.
|
||||||
func IpAddressIn(vs ...string) predicate.Machine {
|
func IpAddressIn(vs ...string) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldIpAddress), v...))
|
s.Where(sql.In(s.C(FieldIpAddress), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// IpAddressNotIn applies the NotIn predicate on the "ipAddress" field.
|
// IpAddressNotIn applies the NotIn predicate on the "ipAddress" field.
|
||||||
func IpAddressNotIn(vs ...string) predicate.Machine {
|
func IpAddressNotIn(vs ...string) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldIpAddress), v...))
|
s.Where(sql.NotIn(s.C(FieldIpAddress), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -886,34 +790,22 @@ func ScenariosNEQ(v string) predicate.Machine {
|
||||||
|
|
||||||
// ScenariosIn applies the In predicate on the "scenarios" field.
|
// ScenariosIn applies the In predicate on the "scenarios" field.
|
||||||
func ScenariosIn(vs ...string) predicate.Machine {
|
func ScenariosIn(vs ...string) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldScenarios), v...))
|
s.Where(sql.In(s.C(FieldScenarios), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScenariosNotIn applies the NotIn predicate on the "scenarios" field.
|
// ScenariosNotIn applies the NotIn predicate on the "scenarios" field.
|
||||||
func ScenariosNotIn(vs ...string) predicate.Machine {
|
func ScenariosNotIn(vs ...string) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldScenarios), v...))
|
s.Where(sql.NotIn(s.C(FieldScenarios), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1011,34 +903,22 @@ func VersionNEQ(v string) predicate.Machine {
|
||||||
|
|
||||||
// VersionIn applies the In predicate on the "version" field.
|
// VersionIn applies the In predicate on the "version" field.
|
||||||
func VersionIn(vs ...string) predicate.Machine {
|
func VersionIn(vs ...string) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldVersion), v...))
|
s.Where(sql.In(s.C(FieldVersion), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// VersionNotIn applies the NotIn predicate on the "version" field.
|
// VersionNotIn applies the NotIn predicate on the "version" field.
|
||||||
func VersionNotIn(vs ...string) predicate.Machine {
|
func VersionNotIn(vs ...string) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldVersion), v...))
|
s.Where(sql.NotIn(s.C(FieldVersion), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1150,34 +1030,22 @@ func StatusNEQ(v string) predicate.Machine {
|
||||||
|
|
||||||
// StatusIn applies the In predicate on the "status" field.
|
// StatusIn applies the In predicate on the "status" field.
|
||||||
func StatusIn(vs ...string) predicate.Machine {
|
func StatusIn(vs ...string) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldStatus), v...))
|
s.Where(sql.In(s.C(FieldStatus), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// StatusNotIn applies the NotIn predicate on the "status" field.
|
// StatusNotIn applies the NotIn predicate on the "status" field.
|
||||||
func StatusNotIn(vs ...string) predicate.Machine {
|
func StatusNotIn(vs ...string) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldStatus), v...))
|
s.Where(sql.NotIn(s.C(FieldStatus), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1275,34 +1143,22 @@ func AuthTypeNEQ(v string) predicate.Machine {
|
||||||
|
|
||||||
// AuthTypeIn applies the In predicate on the "auth_type" field.
|
// AuthTypeIn applies the In predicate on the "auth_type" field.
|
||||||
func AuthTypeIn(vs ...string) predicate.Machine {
|
func AuthTypeIn(vs ...string) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldAuthType), v...))
|
s.Where(sql.In(s.C(FieldAuthType), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuthTypeNotIn applies the NotIn predicate on the "auth_type" field.
|
// AuthTypeNotIn applies the NotIn predicate on the "auth_type" field.
|
||||||
func AuthTypeNotIn(vs ...string) predicate.Machine {
|
func AuthTypeNotIn(vs ...string) predicate.Machine {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Machine(func(s *sql.Selector) {
|
return predicate.Machine(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldAuthType), v...))
|
s.Where(sql.NotIn(s.C(FieldAuthType), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -220,9 +220,15 @@ func (mc *MachineCreate) Save(ctx context.Context) (*Machine, error) {
|
||||||
}
|
}
|
||||||
mut = mc.hooks[i](mut)
|
mut = mc.hooks[i](mut)
|
||||||
}
|
}
|
||||||
if _, err := mut.Mutate(ctx, mc.mutation); err != nil {
|
v, err := mut.Mutate(ctx, mc.mutation)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
nv, ok := v.(*Machine)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected node type %T returned from MachineMutation", v)
|
||||||
|
}
|
||||||
|
node = nv
|
||||||
}
|
}
|
||||||
return node, err
|
return node, err
|
||||||
}
|
}
|
||||||
|
@ -306,7 +312,7 @@ func (mc *MachineCreate) sqlSave(ctx context.Context) (*Machine, error) {
|
||||||
_node, _spec := mc.createSpec()
|
_node, _spec := mc.createSpec()
|
||||||
if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil {
|
if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil {
|
||||||
if sqlgraph.IsConstraintError(err) {
|
if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -477,7 +483,7 @@ func (mcb *MachineCreateBulk) Save(ctx context.Context) ([]*Machine, error) {
|
||||||
// Invoke the actual operation on the latest mutation in the chain.
|
// Invoke the actual operation on the latest mutation in the chain.
|
||||||
if err = sqlgraph.BatchCreate(ctx, mcb.driver, spec); err != nil {
|
if err = sqlgraph.BatchCreate(ctx, mcb.driver, spec); err != nil {
|
||||||
if sqlgraph.IsConstraintError(err) {
|
if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -485,11 +491,11 @@ func (mcb *MachineCreateBulk) Save(ctx context.Context) ([]*Machine, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
mutation.id = &nodes[i].ID
|
mutation.id = &nodes[i].ID
|
||||||
mutation.done = true
|
|
||||||
if specs[i].ID.Value != nil {
|
if specs[i].ID.Value != nil {
|
||||||
id := specs[i].ID.Value.(int64)
|
id := specs[i].ID.Value.(int64)
|
||||||
nodes[i].ID = int(id)
|
nodes[i].ID = int(id)
|
||||||
}
|
}
|
||||||
|
mutation.done = true
|
||||||
return nodes[i], nil
|
return nodes[i], nil
|
||||||
})
|
})
|
||||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -84,7 +84,11 @@ func (md *MachineDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sqlgraph.DeleteNodes(ctx, md.driver, _spec)
|
affected, err := sqlgraph.DeleteNodes(ctx, md.driver, _spec)
|
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return affected, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// MachineDeleteOne is the builder for deleting a single Machine entity.
|
// MachineDeleteOne is the builder for deleting a single Machine entity.
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
|
@ -26,7 +25,6 @@ type MachineQuery struct {
|
||||||
order []OrderFunc
|
order []OrderFunc
|
||||||
fields []string
|
fields []string
|
||||||
predicates []predicate.Machine
|
predicates []predicate.Machine
|
||||||
// eager-loading edges.
|
|
||||||
withAlerts *AlertQuery
|
withAlerts *AlertQuery
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
sql *sql.Selector
|
sql *sql.Selector
|
||||||
|
@ -300,17 +298,18 @@ func (mq *MachineQuery) WithAlerts(opts ...func(*AlertQuery)) *MachineQuery {
|
||||||
// GroupBy(machine.FieldCreatedAt).
|
// GroupBy(machine.FieldCreatedAt).
|
||||||
// Aggregate(ent.Count()).
|
// Aggregate(ent.Count()).
|
||||||
// Scan(ctx, &v)
|
// Scan(ctx, &v)
|
||||||
//
|
|
||||||
func (mq *MachineQuery) GroupBy(field string, fields ...string) *MachineGroupBy {
|
func (mq *MachineQuery) GroupBy(field string, fields ...string) *MachineGroupBy {
|
||||||
group := &MachineGroupBy{config: mq.config}
|
grbuild := &MachineGroupBy{config: mq.config}
|
||||||
group.fields = append([]string{field}, fields...)
|
grbuild.fields = append([]string{field}, fields...)
|
||||||
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
||||||
if err := mq.prepareQuery(ctx); err != nil {
|
if err := mq.prepareQuery(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return mq.sqlQuery(ctx), nil
|
return mq.sqlQuery(ctx), nil
|
||||||
}
|
}
|
||||||
return group
|
grbuild.label = machine.Label
|
||||||
|
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan
|
||||||
|
return grbuild
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select allows the selection one or more fields/columns for the given query,
|
// Select allows the selection one or more fields/columns for the given query,
|
||||||
|
@ -325,10 +324,12 @@ func (mq *MachineQuery) GroupBy(field string, fields ...string) *MachineGroupBy
|
||||||
// client.Machine.Query().
|
// client.Machine.Query().
|
||||||
// Select(machine.FieldCreatedAt).
|
// Select(machine.FieldCreatedAt).
|
||||||
// Scan(ctx, &v)
|
// Scan(ctx, &v)
|
||||||
//
|
|
||||||
func (mq *MachineQuery) Select(fields ...string) *MachineSelect {
|
func (mq *MachineQuery) Select(fields ...string) *MachineSelect {
|
||||||
mq.fields = append(mq.fields, fields...)
|
mq.fields = append(mq.fields, fields...)
|
||||||
return &MachineSelect{MachineQuery: mq}
|
selbuild := &MachineSelect{MachineQuery: mq}
|
||||||
|
selbuild.label = machine.Label
|
||||||
|
selbuild.flds, selbuild.scan = &mq.fields, selbuild.Scan
|
||||||
|
return selbuild
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mq *MachineQuery) prepareQuery(ctx context.Context) error {
|
func (mq *MachineQuery) prepareQuery(ctx context.Context) error {
|
||||||
|
@ -347,7 +348,7 @@ func (mq *MachineQuery) prepareQuery(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mq *MachineQuery) sqlAll(ctx context.Context) ([]*Machine, error) {
|
func (mq *MachineQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Machine, error) {
|
||||||
var (
|
var (
|
||||||
nodes = []*Machine{}
|
nodes = []*Machine{}
|
||||||
_spec = mq.querySpec()
|
_spec = mq.querySpec()
|
||||||
|
@ -355,56 +356,64 @@ func (mq *MachineQuery) sqlAll(ctx context.Context) ([]*Machine, error) {
|
||||||
mq.withAlerts != nil,
|
mq.withAlerts != nil,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
return (*Machine).scanValues(nil, columns)
|
||||||
|
}
|
||||||
|
_spec.Assign = func(columns []string, values []any) error {
|
||||||
node := &Machine{config: mq.config}
|
node := &Machine{config: mq.config}
|
||||||
nodes = append(nodes, node)
|
nodes = append(nodes, node)
|
||||||
return node.scanValues(columns)
|
|
||||||
}
|
|
||||||
_spec.Assign = func(columns []string, values []interface{}) error {
|
|
||||||
if len(nodes) == 0 {
|
|
||||||
return fmt.Errorf("ent: Assign called without calling ScanValues")
|
|
||||||
}
|
|
||||||
node := nodes[len(nodes)-1]
|
|
||||||
node.Edges.loadedTypes = loadedTypes
|
node.Edges.loadedTypes = loadedTypes
|
||||||
return node.assignValues(columns, values)
|
return node.assignValues(columns, values)
|
||||||
}
|
}
|
||||||
|
for i := range hooks {
|
||||||
|
hooks[i](ctx, _spec)
|
||||||
|
}
|
||||||
if err := sqlgraph.QueryNodes(ctx, mq.driver, _spec); err != nil {
|
if err := sqlgraph.QueryNodes(ctx, mq.driver, _spec); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(nodes) == 0 {
|
if len(nodes) == 0 {
|
||||||
return nodes, nil
|
return nodes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if query := mq.withAlerts; query != nil {
|
if query := mq.withAlerts; query != nil {
|
||||||
fks := make([]driver.Value, 0, len(nodes))
|
if err := mq.loadAlerts(ctx, query, nodes,
|
||||||
nodeids := make(map[int]*Machine)
|
func(n *Machine) { n.Edges.Alerts = []*Alert{} },
|
||||||
for i := range nodes {
|
func(n *Machine, e *Alert) { n.Edges.Alerts = append(n.Edges.Alerts, e) }); err != nil {
|
||||||
fks = append(fks, nodes[i].ID)
|
|
||||||
nodeids[nodes[i].ID] = nodes[i]
|
|
||||||
nodes[i].Edges.Alerts = []*Alert{}
|
|
||||||
}
|
|
||||||
query.withFKs = true
|
|
||||||
query.Where(predicate.Alert(func(s *sql.Selector) {
|
|
||||||
s.Where(sql.InValues(machine.AlertsColumn, fks...))
|
|
||||||
}))
|
|
||||||
neighbors, err := query.All(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, n := range neighbors {
|
}
|
||||||
fk := n.machine_alerts
|
return nodes, nil
|
||||||
if fk == nil {
|
}
|
||||||
return nil, fmt.Errorf(`foreign-key "machine_alerts" is nil for node %v`, n.ID)
|
|
||||||
}
|
func (mq *MachineQuery) loadAlerts(ctx context.Context, query *AlertQuery, nodes []*Machine, init func(*Machine), assign func(*Machine, *Alert)) error {
|
||||||
node, ok := nodeids[*fk]
|
fks := make([]driver.Value, 0, len(nodes))
|
||||||
if !ok {
|
nodeids := make(map[int]*Machine)
|
||||||
return nil, fmt.Errorf(`unexpected foreign-key "machine_alerts" returned %v for node %v`, *fk, n.ID)
|
for i := range nodes {
|
||||||
}
|
fks = append(fks, nodes[i].ID)
|
||||||
node.Edges.Alerts = append(node.Edges.Alerts, n)
|
nodeids[nodes[i].ID] = nodes[i]
|
||||||
|
if init != nil {
|
||||||
|
init(nodes[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
query.withFKs = true
|
||||||
return nodes, nil
|
query.Where(predicate.Alert(func(s *sql.Selector) {
|
||||||
|
s.Where(sql.InValues(machine.AlertsColumn, fks...))
|
||||||
|
}))
|
||||||
|
neighbors, err := query.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, n := range neighbors {
|
||||||
|
fk := n.machine_alerts
|
||||||
|
if fk == nil {
|
||||||
|
return fmt.Errorf(`foreign-key "machine_alerts" is nil for node %v`, n.ID)
|
||||||
|
}
|
||||||
|
node, ok := nodeids[*fk]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(`unexpected foreign-key "machine_alerts" returned %v for node %v`, *fk, n.ID)
|
||||||
|
}
|
||||||
|
assign(node, n)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mq *MachineQuery) sqlCount(ctx context.Context) (int, error) {
|
func (mq *MachineQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
|
@ -417,11 +426,14 @@ func (mq *MachineQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mq *MachineQuery) sqlExist(ctx context.Context) (bool, error) {
|
func (mq *MachineQuery) sqlExist(ctx context.Context) (bool, error) {
|
||||||
n, err := mq.sqlCount(ctx)
|
switch _, err := mq.FirstID(ctx); {
|
||||||
if err != nil {
|
case IsNotFound(err):
|
||||||
|
return false, nil
|
||||||
|
case err != nil:
|
||||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||||
|
default:
|
||||||
|
return true, nil
|
||||||
}
|
}
|
||||||
return n > 0, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mq *MachineQuery) querySpec() *sqlgraph.QuerySpec {
|
func (mq *MachineQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
|
@ -507,6 +519,7 @@ func (mq *MachineQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||||
// MachineGroupBy is the group-by builder for Machine entities.
|
// MachineGroupBy is the group-by builder for Machine entities.
|
||||||
type MachineGroupBy struct {
|
type MachineGroupBy struct {
|
||||||
config
|
config
|
||||||
|
selector
|
||||||
fields []string
|
fields []string
|
||||||
fns []AggregateFunc
|
fns []AggregateFunc
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
|
@ -521,7 +534,7 @@ func (mgb *MachineGroupBy) Aggregate(fns ...AggregateFunc) *MachineGroupBy {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan applies the group-by query and scans the result into the given value.
|
// Scan applies the group-by query and scans the result into the given value.
|
||||||
func (mgb *MachineGroupBy) Scan(ctx context.Context, v interface{}) error {
|
func (mgb *MachineGroupBy) Scan(ctx context.Context, v any) error {
|
||||||
query, err := mgb.path(ctx)
|
query, err := mgb.path(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -530,210 +543,7 @@ func (mgb *MachineGroupBy) Scan(ctx context.Context, v interface{}) error {
|
||||||
return mgb.sqlScan(ctx, v)
|
return mgb.sqlScan(ctx, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScanX is like Scan, but panics if an error occurs.
|
func (mgb *MachineGroupBy) sqlScan(ctx context.Context, v any) error {
|
||||||
func (mgb *MachineGroupBy) ScanX(ctx context.Context, v interface{}) {
|
|
||||||
if err := mgb.Scan(ctx, v); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strings returns list of strings from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (mgb *MachineGroupBy) Strings(ctx context.Context) ([]string, error) {
|
|
||||||
if len(mgb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: MachineGroupBy.Strings is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []string
|
|
||||||
if err := mgb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringsX is like Strings, but panics if an error occurs.
|
|
||||||
func (mgb *MachineGroupBy) StringsX(ctx context.Context) []string {
|
|
||||||
v, err := mgb.Strings(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns a single string from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (mgb *MachineGroupBy) String(ctx context.Context) (_ string, err error) {
|
|
||||||
var v []string
|
|
||||||
if v, err = mgb.Strings(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{machine.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: MachineGroupBy.Strings returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringX is like String, but panics if an error occurs.
|
|
||||||
func (mgb *MachineGroupBy) StringX(ctx context.Context) string {
|
|
||||||
v, err := mgb.String(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ints returns list of ints from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (mgb *MachineGroupBy) Ints(ctx context.Context) ([]int, error) {
|
|
||||||
if len(mgb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: MachineGroupBy.Ints is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []int
|
|
||||||
if err := mgb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntsX is like Ints, but panics if an error occurs.
|
|
||||||
func (mgb *MachineGroupBy) IntsX(ctx context.Context) []int {
|
|
||||||
v, err := mgb.Ints(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int returns a single int from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (mgb *MachineGroupBy) Int(ctx context.Context) (_ int, err error) {
|
|
||||||
var v []int
|
|
||||||
if v, err = mgb.Ints(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{machine.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: MachineGroupBy.Ints returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntX is like Int, but panics if an error occurs.
|
|
||||||
func (mgb *MachineGroupBy) IntX(ctx context.Context) int {
|
|
||||||
v, err := mgb.Int(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64s returns list of float64s from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (mgb *MachineGroupBy) Float64s(ctx context.Context) ([]float64, error) {
|
|
||||||
if len(mgb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: MachineGroupBy.Float64s is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []float64
|
|
||||||
if err := mgb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64sX is like Float64s, but panics if an error occurs.
|
|
||||||
func (mgb *MachineGroupBy) Float64sX(ctx context.Context) []float64 {
|
|
||||||
v, err := mgb.Float64s(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64 returns a single float64 from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (mgb *MachineGroupBy) Float64(ctx context.Context) (_ float64, err error) {
|
|
||||||
var v []float64
|
|
||||||
if v, err = mgb.Float64s(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{machine.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: MachineGroupBy.Float64s returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64X is like Float64, but panics if an error occurs.
|
|
||||||
func (mgb *MachineGroupBy) Float64X(ctx context.Context) float64 {
|
|
||||||
v, err := mgb.Float64(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bools returns list of bools from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (mgb *MachineGroupBy) Bools(ctx context.Context) ([]bool, error) {
|
|
||||||
if len(mgb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: MachineGroupBy.Bools is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []bool
|
|
||||||
if err := mgb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolsX is like Bools, but panics if an error occurs.
|
|
||||||
func (mgb *MachineGroupBy) BoolsX(ctx context.Context) []bool {
|
|
||||||
v, err := mgb.Bools(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bool returns a single bool from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (mgb *MachineGroupBy) Bool(ctx context.Context) (_ bool, err error) {
|
|
||||||
var v []bool
|
|
||||||
if v, err = mgb.Bools(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{machine.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: MachineGroupBy.Bools returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolX is like Bool, but panics if an error occurs.
|
|
||||||
func (mgb *MachineGroupBy) BoolX(ctx context.Context) bool {
|
|
||||||
v, err := mgb.Bool(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mgb *MachineGroupBy) sqlScan(ctx context.Context, v interface{}) error {
|
|
||||||
for _, f := range mgb.fields {
|
for _, f := range mgb.fields {
|
||||||
if !machine.ValidColumn(f) {
|
if !machine.ValidColumn(f) {
|
||||||
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
|
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
|
||||||
|
@ -774,12 +584,13 @@ func (mgb *MachineGroupBy) sqlQuery() *sql.Selector {
|
||||||
// MachineSelect is the builder for selecting fields of Machine entities.
|
// MachineSelect is the builder for selecting fields of Machine entities.
|
||||||
type MachineSelect struct {
|
type MachineSelect struct {
|
||||||
*MachineQuery
|
*MachineQuery
|
||||||
|
selector
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
sql *sql.Selector
|
sql *sql.Selector
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan applies the selector query and scans the result into the given value.
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
func (ms *MachineSelect) Scan(ctx context.Context, v interface{}) error {
|
func (ms *MachineSelect) Scan(ctx context.Context, v any) error {
|
||||||
if err := ms.prepareQuery(ctx); err != nil {
|
if err := ms.prepareQuery(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -787,202 +598,7 @@ func (ms *MachineSelect) Scan(ctx context.Context, v interface{}) error {
|
||||||
return ms.sqlScan(ctx, v)
|
return ms.sqlScan(ctx, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScanX is like Scan, but panics if an error occurs.
|
func (ms *MachineSelect) sqlScan(ctx context.Context, v any) error {
|
||||||
func (ms *MachineSelect) ScanX(ctx context.Context, v interface{}) {
|
|
||||||
if err := ms.Scan(ctx, v); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ms *MachineSelect) Strings(ctx context.Context) ([]string, error) {
|
|
||||||
if len(ms.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: MachineSelect.Strings is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []string
|
|
||||||
if err := ms.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringsX is like Strings, but panics if an error occurs.
|
|
||||||
func (ms *MachineSelect) StringsX(ctx context.Context) []string {
|
|
||||||
v, err := ms.Strings(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns a single string from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ms *MachineSelect) String(ctx context.Context) (_ string, err error) {
|
|
||||||
var v []string
|
|
||||||
if v, err = ms.Strings(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{machine.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: MachineSelect.Strings returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringX is like String, but panics if an error occurs.
|
|
||||||
func (ms *MachineSelect) StringX(ctx context.Context) string {
|
|
||||||
v, err := ms.String(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ms *MachineSelect) Ints(ctx context.Context) ([]int, error) {
|
|
||||||
if len(ms.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: MachineSelect.Ints is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []int
|
|
||||||
if err := ms.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntsX is like Ints, but panics if an error occurs.
|
|
||||||
func (ms *MachineSelect) IntsX(ctx context.Context) []int {
|
|
||||||
v, err := ms.Ints(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int returns a single int from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ms *MachineSelect) Int(ctx context.Context) (_ int, err error) {
|
|
||||||
var v []int
|
|
||||||
if v, err = ms.Ints(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{machine.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: MachineSelect.Ints returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntX is like Int, but panics if an error occurs.
|
|
||||||
func (ms *MachineSelect) IntX(ctx context.Context) int {
|
|
||||||
v, err := ms.Int(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ms *MachineSelect) Float64s(ctx context.Context) ([]float64, error) {
|
|
||||||
if len(ms.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: MachineSelect.Float64s is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []float64
|
|
||||||
if err := ms.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64sX is like Float64s, but panics if an error occurs.
|
|
||||||
func (ms *MachineSelect) Float64sX(ctx context.Context) []float64 {
|
|
||||||
v, err := ms.Float64s(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ms *MachineSelect) Float64(ctx context.Context) (_ float64, err error) {
|
|
||||||
var v []float64
|
|
||||||
if v, err = ms.Float64s(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{machine.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: MachineSelect.Float64s returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64X is like Float64, but panics if an error occurs.
|
|
||||||
func (ms *MachineSelect) Float64X(ctx context.Context) float64 {
|
|
||||||
v, err := ms.Float64(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ms *MachineSelect) Bools(ctx context.Context) ([]bool, error) {
|
|
||||||
if len(ms.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: MachineSelect.Bools is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []bool
|
|
||||||
if err := ms.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolsX is like Bools, but panics if an error occurs.
|
|
||||||
func (ms *MachineSelect) BoolsX(ctx context.Context) []bool {
|
|
||||||
v, err := ms.Bools(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ms *MachineSelect) Bool(ctx context.Context) (_ bool, err error) {
|
|
||||||
var v []bool
|
|
||||||
if v, err = ms.Bools(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{machine.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: MachineSelect.Bools returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolX is like Bool, but panics if an error occurs.
|
|
||||||
func (ms *MachineSelect) BoolX(ctx context.Context) bool {
|
|
||||||
v, err := ms.Bool(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ms *MachineSelect) sqlScan(ctx context.Context, v interface{}) error {
|
|
||||||
rows := &sql.Rows{}
|
rows := &sql.Rows{}
|
||||||
query, args := ms.sql.Query()
|
query, args := ms.sql.Query()
|
||||||
if err := ms.driver.Query(ctx, query, args, rows); err != nil {
|
if err := ms.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -517,7 +517,7 @@ func (mu *MachineUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
err = &NotFoundError{machine.Label}
|
err = &NotFoundError{machine.Label}
|
||||||
} else if sqlgraph.IsConstraintError(err) {
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -766,9 +766,15 @@ func (muo *MachineUpdateOne) Save(ctx context.Context) (*Machine, error) {
|
||||||
}
|
}
|
||||||
mut = muo.hooks[i](mut)
|
mut = muo.hooks[i](mut)
|
||||||
}
|
}
|
||||||
if _, err := mut.Mutate(ctx, muo.mutation); err != nil {
|
v, err := mut.Mutate(ctx, muo.mutation)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
nv, ok := v.(*Machine)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected node type %T returned from MachineMutation", v)
|
||||||
|
}
|
||||||
|
node = nv
|
||||||
}
|
}
|
||||||
return node, err
|
return node, err
|
||||||
}
|
}
|
||||||
|
@ -1047,7 +1053,7 @@ func (muo *MachineUpdateOne) sqlSave(ctx context.Context) (_node *Machine, err e
|
||||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
err = &NotFoundError{machine.Label}
|
err = &NotFoundError{machine.Label}
|
||||||
} else if sqlgraph.IsConstraintError(err) {
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -45,8 +45,7 @@ type MetaEdges struct {
|
||||||
func (e MetaEdges) OwnerOrErr() (*Alert, error) {
|
func (e MetaEdges) OwnerOrErr() (*Alert, error) {
|
||||||
if e.loadedTypes[0] {
|
if e.loadedTypes[0] {
|
||||||
if e.Owner == nil {
|
if e.Owner == nil {
|
||||||
// The edge owner was loaded in eager-loading,
|
// Edge was loaded but was not found.
|
||||||
// but was not found.
|
|
||||||
return nil, &NotFoundError{label: alert.Label}
|
return nil, &NotFoundError{label: alert.Label}
|
||||||
}
|
}
|
||||||
return e.Owner, nil
|
return e.Owner, nil
|
||||||
|
@ -55,8 +54,8 @@ func (e MetaEdges) OwnerOrErr() (*Alert, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// scanValues returns the types for scanning values from sql.Rows.
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
func (*Meta) scanValues(columns []string) ([]interface{}, error) {
|
func (*Meta) scanValues(columns []string) ([]any, error) {
|
||||||
values := make([]interface{}, len(columns))
|
values := make([]any, len(columns))
|
||||||
for i := range columns {
|
for i := range columns {
|
||||||
switch columns[i] {
|
switch columns[i] {
|
||||||
case meta.FieldID:
|
case meta.FieldID:
|
||||||
|
@ -76,7 +75,7 @@ func (*Meta) scanValues(columns []string) ([]interface{}, error) {
|
||||||
|
|
||||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||||
// to the Meta fields.
|
// to the Meta fields.
|
||||||
func (m *Meta) assignValues(columns []string, values []interface{}) error {
|
func (m *Meta) assignValues(columns []string, values []any) error {
|
||||||
if m, n := len(values), len(columns); m < n {
|
if m, n := len(values), len(columns); m < n {
|
||||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||||
}
|
}
|
||||||
|
@ -141,11 +140,11 @@ func (m *Meta) Update() *MetaUpdateOne {
|
||||||
// Unwrap unwraps the Meta entity that was returned from a transaction after it was closed,
|
// Unwrap unwraps the Meta entity that was returned from a transaction after it was closed,
|
||||||
// so that all future queries will be executed through the driver which created the transaction.
|
// so that all future queries will be executed through the driver which created the transaction.
|
||||||
func (m *Meta) Unwrap() *Meta {
|
func (m *Meta) Unwrap() *Meta {
|
||||||
tx, ok := m.config.driver.(*txDriver)
|
_tx, ok := m.config.driver.(*txDriver)
|
||||||
if !ok {
|
if !ok {
|
||||||
panic("ent: Meta is not a transactional entity")
|
panic("ent: Meta is not a transactional entity")
|
||||||
}
|
}
|
||||||
m.config.driver = tx.drv
|
m.config.driver = _tx.drv
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,18 +152,21 @@ func (m *Meta) Unwrap() *Meta {
|
||||||
func (m *Meta) String() string {
|
func (m *Meta) String() string {
|
||||||
var builder strings.Builder
|
var builder strings.Builder
|
||||||
builder.WriteString("Meta(")
|
builder.WriteString("Meta(")
|
||||||
builder.WriteString(fmt.Sprintf("id=%v", m.ID))
|
builder.WriteString(fmt.Sprintf("id=%v, ", m.ID))
|
||||||
if v := m.CreatedAt; v != nil {
|
if v := m.CreatedAt; v != nil {
|
||||||
builder.WriteString(", created_at=")
|
builder.WriteString("created_at=")
|
||||||
builder.WriteString(v.Format(time.ANSIC))
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
}
|
}
|
||||||
|
builder.WriteString(", ")
|
||||||
if v := m.UpdatedAt; v != nil {
|
if v := m.UpdatedAt; v != nil {
|
||||||
builder.WriteString(", updated_at=")
|
builder.WriteString("updated_at=")
|
||||||
builder.WriteString(v.Format(time.ANSIC))
|
builder.WriteString(v.Format(time.ANSIC))
|
||||||
}
|
}
|
||||||
builder.WriteString(", key=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("key=")
|
||||||
builder.WriteString(m.Key)
|
builder.WriteString(m.Key)
|
||||||
builder.WriteString(", value=")
|
builder.WriteString(", ")
|
||||||
|
builder.WriteString("value=")
|
||||||
builder.WriteString(m.Value)
|
builder.WriteString(m.Value)
|
||||||
builder.WriteByte(')')
|
builder.WriteByte(')')
|
||||||
return builder.String()
|
return builder.String()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package meta
|
package meta
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package meta
|
package meta
|
||||||
|
|
||||||
|
@ -34,13 +34,7 @@ func IDNEQ(id int) predicate.Meta {
|
||||||
// IDIn applies the In predicate on the ID field.
|
// IDIn applies the In predicate on the ID field.
|
||||||
func IDIn(ids ...int) predicate.Meta {
|
func IDIn(ids ...int) predicate.Meta {
|
||||||
return predicate.Meta(func(s *sql.Selector) {
|
return predicate.Meta(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
v := make([]any, len(ids))
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(ids) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
v := make([]interface{}, len(ids))
|
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = ids[i]
|
v[i] = ids[i]
|
||||||
}
|
}
|
||||||
|
@ -51,13 +45,7 @@ func IDIn(ids ...int) predicate.Meta {
|
||||||
// IDNotIn applies the NotIn predicate on the ID field.
|
// IDNotIn applies the NotIn predicate on the ID field.
|
||||||
func IDNotIn(ids ...int) predicate.Meta {
|
func IDNotIn(ids ...int) predicate.Meta {
|
||||||
return predicate.Meta(func(s *sql.Selector) {
|
return predicate.Meta(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
v := make([]any, len(ids))
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(ids) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
v := make([]interface{}, len(ids))
|
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = ids[i]
|
v[i] = ids[i]
|
||||||
}
|
}
|
||||||
|
@ -137,34 +125,22 @@ func CreatedAtNEQ(v time.Time) predicate.Meta {
|
||||||
|
|
||||||
// CreatedAtIn applies the In predicate on the "created_at" field.
|
// CreatedAtIn applies the In predicate on the "created_at" field.
|
||||||
func CreatedAtIn(vs ...time.Time) predicate.Meta {
|
func CreatedAtIn(vs ...time.Time) predicate.Meta {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Meta(func(s *sql.Selector) {
|
return predicate.Meta(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldCreatedAt), v...))
|
s.Where(sql.In(s.C(FieldCreatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
|
||||||
func CreatedAtNotIn(vs ...time.Time) predicate.Meta {
|
func CreatedAtNotIn(vs ...time.Time) predicate.Meta {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Meta(func(s *sql.Selector) {
|
return predicate.Meta(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
|
s.Where(sql.NotIn(s.C(FieldCreatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -227,34 +203,22 @@ func UpdatedAtNEQ(v time.Time) predicate.Meta {
|
||||||
|
|
||||||
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
// UpdatedAtIn applies the In predicate on the "updated_at" field.
|
||||||
func UpdatedAtIn(vs ...time.Time) predicate.Meta {
|
func UpdatedAtIn(vs ...time.Time) predicate.Meta {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Meta(func(s *sql.Selector) {
|
return predicate.Meta(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
|
s.Where(sql.In(s.C(FieldUpdatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
|
||||||
func UpdatedAtNotIn(vs ...time.Time) predicate.Meta {
|
func UpdatedAtNotIn(vs ...time.Time) predicate.Meta {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Meta(func(s *sql.Selector) {
|
return predicate.Meta(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
|
s.Where(sql.NotIn(s.C(FieldUpdatedAt), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -317,34 +281,22 @@ func KeyNEQ(v string) predicate.Meta {
|
||||||
|
|
||||||
// KeyIn applies the In predicate on the "key" field.
|
// KeyIn applies the In predicate on the "key" field.
|
||||||
func KeyIn(vs ...string) predicate.Meta {
|
func KeyIn(vs ...string) predicate.Meta {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Meta(func(s *sql.Selector) {
|
return predicate.Meta(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldKey), v...))
|
s.Where(sql.In(s.C(FieldKey), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeyNotIn applies the NotIn predicate on the "key" field.
|
// KeyNotIn applies the NotIn predicate on the "key" field.
|
||||||
func KeyNotIn(vs ...string) predicate.Meta {
|
func KeyNotIn(vs ...string) predicate.Meta {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Meta(func(s *sql.Selector) {
|
return predicate.Meta(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldKey), v...))
|
s.Where(sql.NotIn(s.C(FieldKey), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -428,34 +380,22 @@ func ValueNEQ(v string) predicate.Meta {
|
||||||
|
|
||||||
// ValueIn applies the In predicate on the "value" field.
|
// ValueIn applies the In predicate on the "value" field.
|
||||||
func ValueIn(vs ...string) predicate.Meta {
|
func ValueIn(vs ...string) predicate.Meta {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Meta(func(s *sql.Selector) {
|
return predicate.Meta(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.In(s.C(FieldValue), v...))
|
s.Where(sql.In(s.C(FieldValue), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValueNotIn applies the NotIn predicate on the "value" field.
|
// ValueNotIn applies the NotIn predicate on the "value" field.
|
||||||
func ValueNotIn(vs ...string) predicate.Meta {
|
func ValueNotIn(vs ...string) predicate.Meta {
|
||||||
v := make([]interface{}, len(vs))
|
v := make([]any, len(vs))
|
||||||
for i := range v {
|
for i := range v {
|
||||||
v[i] = vs[i]
|
v[i] = vs[i]
|
||||||
}
|
}
|
||||||
return predicate.Meta(func(s *sql.Selector) {
|
return predicate.Meta(func(s *sql.Selector) {
|
||||||
// if not arguments were provided, append the FALSE constants,
|
|
||||||
// since we can't apply "IN ()". This will make this predicate falsy.
|
|
||||||
if len(v) == 0 {
|
|
||||||
s.Where(sql.False())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.Where(sql.NotIn(s.C(FieldValue), v...))
|
s.Where(sql.NotIn(s.C(FieldValue), v...))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -120,9 +120,15 @@ func (mc *MetaCreate) Save(ctx context.Context) (*Meta, error) {
|
||||||
}
|
}
|
||||||
mut = mc.hooks[i](mut)
|
mut = mc.hooks[i](mut)
|
||||||
}
|
}
|
||||||
if _, err := mut.Mutate(ctx, mc.mutation); err != nil {
|
v, err := mut.Mutate(ctx, mc.mutation)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
nv, ok := v.(*Meta)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected node type %T returned from MetaMutation", v)
|
||||||
|
}
|
||||||
|
node = nv
|
||||||
}
|
}
|
||||||
return node, err
|
return node, err
|
||||||
}
|
}
|
||||||
|
@ -181,7 +187,7 @@ func (mc *MetaCreate) sqlSave(ctx context.Context) (*Meta, error) {
|
||||||
_node, _spec := mc.createSpec()
|
_node, _spec := mc.createSpec()
|
||||||
if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil {
|
if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil {
|
||||||
if sqlgraph.IsConstraintError(err) {
|
if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -289,7 +295,7 @@ func (mcb *MetaCreateBulk) Save(ctx context.Context) ([]*Meta, error) {
|
||||||
// Invoke the actual operation on the latest mutation in the chain.
|
// Invoke the actual operation on the latest mutation in the chain.
|
||||||
if err = sqlgraph.BatchCreate(ctx, mcb.driver, spec); err != nil {
|
if err = sqlgraph.BatchCreate(ctx, mcb.driver, spec); err != nil {
|
||||||
if sqlgraph.IsConstraintError(err) {
|
if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,11 +303,11 @@ func (mcb *MetaCreateBulk) Save(ctx context.Context) ([]*Meta, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
mutation.id = &nodes[i].ID
|
mutation.id = &nodes[i].ID
|
||||||
mutation.done = true
|
|
||||||
if specs[i].ID.Value != nil {
|
if specs[i].ID.Value != nil {
|
||||||
id := specs[i].ID.Value.(int64)
|
id := specs[i].ID.Value.(int64)
|
||||||
nodes[i].ID = int(id)
|
nodes[i].ID = int(id)
|
||||||
}
|
}
|
||||||
|
mutation.done = true
|
||||||
return nodes[i], nil
|
return nodes[i], nil
|
||||||
})
|
})
|
||||||
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
for i := len(builder.hooks) - 1; i >= 0; i-- {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -84,7 +84,11 @@ func (md *MetaDelete) sqlExec(ctx context.Context) (int, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sqlgraph.DeleteNodes(ctx, md.driver, _spec)
|
affected, err := sqlgraph.DeleteNodes(ctx, md.driver, _spec)
|
||||||
|
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||||
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
|
}
|
||||||
|
return affected, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// MetaDeleteOne is the builder for deleting a single Meta entity.
|
// MetaDeleteOne is the builder for deleting a single Meta entity.
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
|
@ -25,9 +24,8 @@ type MetaQuery struct {
|
||||||
order []OrderFunc
|
order []OrderFunc
|
||||||
fields []string
|
fields []string
|
||||||
predicates []predicate.Meta
|
predicates []predicate.Meta
|
||||||
// eager-loading edges.
|
withOwner *AlertQuery
|
||||||
withOwner *AlertQuery
|
withFKs bool
|
||||||
withFKs bool
|
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
sql *sql.Selector
|
sql *sql.Selector
|
||||||
path func(context.Context) (*sql.Selector, error)
|
path func(context.Context) (*sql.Selector, error)
|
||||||
|
@ -300,17 +298,18 @@ func (mq *MetaQuery) WithOwner(opts ...func(*AlertQuery)) *MetaQuery {
|
||||||
// GroupBy(meta.FieldCreatedAt).
|
// GroupBy(meta.FieldCreatedAt).
|
||||||
// Aggregate(ent.Count()).
|
// Aggregate(ent.Count()).
|
||||||
// Scan(ctx, &v)
|
// Scan(ctx, &v)
|
||||||
//
|
|
||||||
func (mq *MetaQuery) GroupBy(field string, fields ...string) *MetaGroupBy {
|
func (mq *MetaQuery) GroupBy(field string, fields ...string) *MetaGroupBy {
|
||||||
group := &MetaGroupBy{config: mq.config}
|
grbuild := &MetaGroupBy{config: mq.config}
|
||||||
group.fields = append([]string{field}, fields...)
|
grbuild.fields = append([]string{field}, fields...)
|
||||||
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) {
|
||||||
if err := mq.prepareQuery(ctx); err != nil {
|
if err := mq.prepareQuery(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return mq.sqlQuery(ctx), nil
|
return mq.sqlQuery(ctx), nil
|
||||||
}
|
}
|
||||||
return group
|
grbuild.label = meta.Label
|
||||||
|
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan
|
||||||
|
return grbuild
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select allows the selection one or more fields/columns for the given query,
|
// Select allows the selection one or more fields/columns for the given query,
|
||||||
|
@ -325,10 +324,12 @@ func (mq *MetaQuery) GroupBy(field string, fields ...string) *MetaGroupBy {
|
||||||
// client.Meta.Query().
|
// client.Meta.Query().
|
||||||
// Select(meta.FieldCreatedAt).
|
// Select(meta.FieldCreatedAt).
|
||||||
// Scan(ctx, &v)
|
// Scan(ctx, &v)
|
||||||
//
|
|
||||||
func (mq *MetaQuery) Select(fields ...string) *MetaSelect {
|
func (mq *MetaQuery) Select(fields ...string) *MetaSelect {
|
||||||
mq.fields = append(mq.fields, fields...)
|
mq.fields = append(mq.fields, fields...)
|
||||||
return &MetaSelect{MetaQuery: mq}
|
selbuild := &MetaSelect{MetaQuery: mq}
|
||||||
|
selbuild.label = meta.Label
|
||||||
|
selbuild.flds, selbuild.scan = &mq.fields, selbuild.Scan
|
||||||
|
return selbuild
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mq *MetaQuery) prepareQuery(ctx context.Context) error {
|
func (mq *MetaQuery) prepareQuery(ctx context.Context) error {
|
||||||
|
@ -347,7 +348,7 @@ func (mq *MetaQuery) prepareQuery(ctx context.Context) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mq *MetaQuery) sqlAll(ctx context.Context) ([]*Meta, error) {
|
func (mq *MetaQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Meta, error) {
|
||||||
var (
|
var (
|
||||||
nodes = []*Meta{}
|
nodes = []*Meta{}
|
||||||
withFKs = mq.withFKs
|
withFKs = mq.withFKs
|
||||||
|
@ -362,56 +363,61 @@ func (mq *MetaQuery) sqlAll(ctx context.Context) ([]*Meta, error) {
|
||||||
if withFKs {
|
if withFKs {
|
||||||
_spec.Node.Columns = append(_spec.Node.Columns, meta.ForeignKeys...)
|
_spec.Node.Columns = append(_spec.Node.Columns, meta.ForeignKeys...)
|
||||||
}
|
}
|
||||||
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
|
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||||
|
return (*Meta).scanValues(nil, columns)
|
||||||
|
}
|
||||||
|
_spec.Assign = func(columns []string, values []any) error {
|
||||||
node := &Meta{config: mq.config}
|
node := &Meta{config: mq.config}
|
||||||
nodes = append(nodes, node)
|
nodes = append(nodes, node)
|
||||||
return node.scanValues(columns)
|
|
||||||
}
|
|
||||||
_spec.Assign = func(columns []string, values []interface{}) error {
|
|
||||||
if len(nodes) == 0 {
|
|
||||||
return fmt.Errorf("ent: Assign called without calling ScanValues")
|
|
||||||
}
|
|
||||||
node := nodes[len(nodes)-1]
|
|
||||||
node.Edges.loadedTypes = loadedTypes
|
node.Edges.loadedTypes = loadedTypes
|
||||||
return node.assignValues(columns, values)
|
return node.assignValues(columns, values)
|
||||||
}
|
}
|
||||||
|
for i := range hooks {
|
||||||
|
hooks[i](ctx, _spec)
|
||||||
|
}
|
||||||
if err := sqlgraph.QueryNodes(ctx, mq.driver, _spec); err != nil {
|
if err := sqlgraph.QueryNodes(ctx, mq.driver, _spec); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(nodes) == 0 {
|
if len(nodes) == 0 {
|
||||||
return nodes, nil
|
return nodes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if query := mq.withOwner; query != nil {
|
if query := mq.withOwner; query != nil {
|
||||||
ids := make([]int, 0, len(nodes))
|
if err := mq.loadOwner(ctx, query, nodes, nil,
|
||||||
nodeids := make(map[int][]*Meta)
|
func(n *Meta, e *Alert) { n.Edges.Owner = e }); err != nil {
|
||||||
for i := range nodes {
|
|
||||||
if nodes[i].alert_metas == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
fk := *nodes[i].alert_metas
|
|
||||||
if _, ok := nodeids[fk]; !ok {
|
|
||||||
ids = append(ids, fk)
|
|
||||||
}
|
|
||||||
nodeids[fk] = append(nodeids[fk], nodes[i])
|
|
||||||
}
|
|
||||||
query.Where(alert.IDIn(ids...))
|
|
||||||
neighbors, err := query.All(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, n := range neighbors {
|
}
|
||||||
nodes, ok := nodeids[n.ID]
|
return nodes, nil
|
||||||
if !ok {
|
}
|
||||||
return nil, fmt.Errorf(`unexpected foreign-key "alert_metas" returned %v`, n.ID)
|
|
||||||
}
|
func (mq *MetaQuery) loadOwner(ctx context.Context, query *AlertQuery, nodes []*Meta, init func(*Meta), assign func(*Meta, *Alert)) error {
|
||||||
for i := range nodes {
|
ids := make([]int, 0, len(nodes))
|
||||||
nodes[i].Edges.Owner = n
|
nodeids := make(map[int][]*Meta)
|
||||||
}
|
for i := range nodes {
|
||||||
|
if nodes[i].alert_metas == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fk := *nodes[i].alert_metas
|
||||||
|
if _, ok := nodeids[fk]; !ok {
|
||||||
|
ids = append(ids, fk)
|
||||||
|
}
|
||||||
|
nodeids[fk] = append(nodeids[fk], nodes[i])
|
||||||
|
}
|
||||||
|
query.Where(alert.IDIn(ids...))
|
||||||
|
neighbors, err := query.All(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, n := range neighbors {
|
||||||
|
nodes, ok := nodeids[n.ID]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf(`unexpected foreign-key "alert_metas" returned %v`, n.ID)
|
||||||
|
}
|
||||||
|
for i := range nodes {
|
||||||
|
assign(nodes[i], n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
return nodes, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mq *MetaQuery) sqlCount(ctx context.Context) (int, error) {
|
func (mq *MetaQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
|
@ -424,11 +430,14 @@ func (mq *MetaQuery) sqlCount(ctx context.Context) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mq *MetaQuery) sqlExist(ctx context.Context) (bool, error) {
|
func (mq *MetaQuery) sqlExist(ctx context.Context) (bool, error) {
|
||||||
n, err := mq.sqlCount(ctx)
|
switch _, err := mq.FirstID(ctx); {
|
||||||
if err != nil {
|
case IsNotFound(err):
|
||||||
|
return false, nil
|
||||||
|
case err != nil:
|
||||||
return false, fmt.Errorf("ent: check existence: %w", err)
|
return false, fmt.Errorf("ent: check existence: %w", err)
|
||||||
|
default:
|
||||||
|
return true, nil
|
||||||
}
|
}
|
||||||
return n > 0, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mq *MetaQuery) querySpec() *sqlgraph.QuerySpec {
|
func (mq *MetaQuery) querySpec() *sqlgraph.QuerySpec {
|
||||||
|
@ -514,6 +523,7 @@ func (mq *MetaQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||||
// MetaGroupBy is the group-by builder for Meta entities.
|
// MetaGroupBy is the group-by builder for Meta entities.
|
||||||
type MetaGroupBy struct {
|
type MetaGroupBy struct {
|
||||||
config
|
config
|
||||||
|
selector
|
||||||
fields []string
|
fields []string
|
||||||
fns []AggregateFunc
|
fns []AggregateFunc
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
|
@ -528,7 +538,7 @@ func (mgb *MetaGroupBy) Aggregate(fns ...AggregateFunc) *MetaGroupBy {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan applies the group-by query and scans the result into the given value.
|
// Scan applies the group-by query and scans the result into the given value.
|
||||||
func (mgb *MetaGroupBy) Scan(ctx context.Context, v interface{}) error {
|
func (mgb *MetaGroupBy) Scan(ctx context.Context, v any) error {
|
||||||
query, err := mgb.path(ctx)
|
query, err := mgb.path(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -537,210 +547,7 @@ func (mgb *MetaGroupBy) Scan(ctx context.Context, v interface{}) error {
|
||||||
return mgb.sqlScan(ctx, v)
|
return mgb.sqlScan(ctx, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScanX is like Scan, but panics if an error occurs.
|
func (mgb *MetaGroupBy) sqlScan(ctx context.Context, v any) error {
|
||||||
func (mgb *MetaGroupBy) ScanX(ctx context.Context, v interface{}) {
|
|
||||||
if err := mgb.Scan(ctx, v); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strings returns list of strings from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (mgb *MetaGroupBy) Strings(ctx context.Context) ([]string, error) {
|
|
||||||
if len(mgb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: MetaGroupBy.Strings is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []string
|
|
||||||
if err := mgb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringsX is like Strings, but panics if an error occurs.
|
|
||||||
func (mgb *MetaGroupBy) StringsX(ctx context.Context) []string {
|
|
||||||
v, err := mgb.Strings(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns a single string from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (mgb *MetaGroupBy) String(ctx context.Context) (_ string, err error) {
|
|
||||||
var v []string
|
|
||||||
if v, err = mgb.Strings(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{meta.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: MetaGroupBy.Strings returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringX is like String, but panics if an error occurs.
|
|
||||||
func (mgb *MetaGroupBy) StringX(ctx context.Context) string {
|
|
||||||
v, err := mgb.String(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ints returns list of ints from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (mgb *MetaGroupBy) Ints(ctx context.Context) ([]int, error) {
|
|
||||||
if len(mgb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: MetaGroupBy.Ints is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []int
|
|
||||||
if err := mgb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntsX is like Ints, but panics if an error occurs.
|
|
||||||
func (mgb *MetaGroupBy) IntsX(ctx context.Context) []int {
|
|
||||||
v, err := mgb.Ints(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int returns a single int from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (mgb *MetaGroupBy) Int(ctx context.Context) (_ int, err error) {
|
|
||||||
var v []int
|
|
||||||
if v, err = mgb.Ints(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{meta.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: MetaGroupBy.Ints returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntX is like Int, but panics if an error occurs.
|
|
||||||
func (mgb *MetaGroupBy) IntX(ctx context.Context) int {
|
|
||||||
v, err := mgb.Int(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64s returns list of float64s from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (mgb *MetaGroupBy) Float64s(ctx context.Context) ([]float64, error) {
|
|
||||||
if len(mgb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: MetaGroupBy.Float64s is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []float64
|
|
||||||
if err := mgb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64sX is like Float64s, but panics if an error occurs.
|
|
||||||
func (mgb *MetaGroupBy) Float64sX(ctx context.Context) []float64 {
|
|
||||||
v, err := mgb.Float64s(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64 returns a single float64 from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (mgb *MetaGroupBy) Float64(ctx context.Context) (_ float64, err error) {
|
|
||||||
var v []float64
|
|
||||||
if v, err = mgb.Float64s(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{meta.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: MetaGroupBy.Float64s returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64X is like Float64, but panics if an error occurs.
|
|
||||||
func (mgb *MetaGroupBy) Float64X(ctx context.Context) float64 {
|
|
||||||
v, err := mgb.Float64(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bools returns list of bools from group-by.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (mgb *MetaGroupBy) Bools(ctx context.Context) ([]bool, error) {
|
|
||||||
if len(mgb.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: MetaGroupBy.Bools is not achievable when grouping more than 1 field")
|
|
||||||
}
|
|
||||||
var v []bool
|
|
||||||
if err := mgb.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolsX is like Bools, but panics if an error occurs.
|
|
||||||
func (mgb *MetaGroupBy) BoolsX(ctx context.Context) []bool {
|
|
||||||
v, err := mgb.Bools(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bool returns a single bool from a group-by query.
|
|
||||||
// It is only allowed when executing a group-by query with one field.
|
|
||||||
func (mgb *MetaGroupBy) Bool(ctx context.Context) (_ bool, err error) {
|
|
||||||
var v []bool
|
|
||||||
if v, err = mgb.Bools(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{meta.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: MetaGroupBy.Bools returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolX is like Bool, but panics if an error occurs.
|
|
||||||
func (mgb *MetaGroupBy) BoolX(ctx context.Context) bool {
|
|
||||||
v, err := mgb.Bool(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mgb *MetaGroupBy) sqlScan(ctx context.Context, v interface{}) error {
|
|
||||||
for _, f := range mgb.fields {
|
for _, f := range mgb.fields {
|
||||||
if !meta.ValidColumn(f) {
|
if !meta.ValidColumn(f) {
|
||||||
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
|
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
|
||||||
|
@ -781,12 +588,13 @@ func (mgb *MetaGroupBy) sqlQuery() *sql.Selector {
|
||||||
// MetaSelect is the builder for selecting fields of Meta entities.
|
// MetaSelect is the builder for selecting fields of Meta entities.
|
||||||
type MetaSelect struct {
|
type MetaSelect struct {
|
||||||
*MetaQuery
|
*MetaQuery
|
||||||
|
selector
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
sql *sql.Selector
|
sql *sql.Selector
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scan applies the selector query and scans the result into the given value.
|
// Scan applies the selector query and scans the result into the given value.
|
||||||
func (ms *MetaSelect) Scan(ctx context.Context, v interface{}) error {
|
func (ms *MetaSelect) Scan(ctx context.Context, v any) error {
|
||||||
if err := ms.prepareQuery(ctx); err != nil {
|
if err := ms.prepareQuery(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -794,202 +602,7 @@ func (ms *MetaSelect) Scan(ctx context.Context, v interface{}) error {
|
||||||
return ms.sqlScan(ctx, v)
|
return ms.sqlScan(ctx, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ScanX is like Scan, but panics if an error occurs.
|
func (ms *MetaSelect) sqlScan(ctx context.Context, v any) error {
|
||||||
func (ms *MetaSelect) ScanX(ctx context.Context, v interface{}) {
|
|
||||||
if err := ms.Scan(ctx, v); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ms *MetaSelect) Strings(ctx context.Context) ([]string, error) {
|
|
||||||
if len(ms.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: MetaSelect.Strings is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []string
|
|
||||||
if err := ms.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringsX is like Strings, but panics if an error occurs.
|
|
||||||
func (ms *MetaSelect) StringsX(ctx context.Context) []string {
|
|
||||||
v, err := ms.Strings(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns a single string from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ms *MetaSelect) String(ctx context.Context) (_ string, err error) {
|
|
||||||
var v []string
|
|
||||||
if v, err = ms.Strings(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{meta.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: MetaSelect.Strings returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// StringX is like String, but panics if an error occurs.
|
|
||||||
func (ms *MetaSelect) StringX(ctx context.Context) string {
|
|
||||||
v, err := ms.String(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ms *MetaSelect) Ints(ctx context.Context) ([]int, error) {
|
|
||||||
if len(ms.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: MetaSelect.Ints is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []int
|
|
||||||
if err := ms.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntsX is like Ints, but panics if an error occurs.
|
|
||||||
func (ms *MetaSelect) IntsX(ctx context.Context) []int {
|
|
||||||
v, err := ms.Ints(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int returns a single int from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ms *MetaSelect) Int(ctx context.Context) (_ int, err error) {
|
|
||||||
var v []int
|
|
||||||
if v, err = ms.Ints(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{meta.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: MetaSelect.Ints returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// IntX is like Int, but panics if an error occurs.
|
|
||||||
func (ms *MetaSelect) IntX(ctx context.Context) int {
|
|
||||||
v, err := ms.Int(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ms *MetaSelect) Float64s(ctx context.Context) ([]float64, error) {
|
|
||||||
if len(ms.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: MetaSelect.Float64s is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []float64
|
|
||||||
if err := ms.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64sX is like Float64s, but panics if an error occurs.
|
|
||||||
func (ms *MetaSelect) Float64sX(ctx context.Context) []float64 {
|
|
||||||
v, err := ms.Float64s(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ms *MetaSelect) Float64(ctx context.Context) (_ float64, err error) {
|
|
||||||
var v []float64
|
|
||||||
if v, err = ms.Float64s(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{meta.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: MetaSelect.Float64s returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Float64X is like Float64, but panics if an error occurs.
|
|
||||||
func (ms *MetaSelect) Float64X(ctx context.Context) float64 {
|
|
||||||
v, err := ms.Float64(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ms *MetaSelect) Bools(ctx context.Context) ([]bool, error) {
|
|
||||||
if len(ms.fields) > 1 {
|
|
||||||
return nil, errors.New("ent: MetaSelect.Bools is not achievable when selecting more than 1 field")
|
|
||||||
}
|
|
||||||
var v []bool
|
|
||||||
if err := ms.Scan(ctx, &v); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolsX is like Bools, but panics if an error occurs.
|
|
||||||
func (ms *MetaSelect) BoolsX(ctx context.Context) []bool {
|
|
||||||
v, err := ms.Bools(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
|
|
||||||
func (ms *MetaSelect) Bool(ctx context.Context) (_ bool, err error) {
|
|
||||||
var v []bool
|
|
||||||
if v, err = ms.Bools(ctx); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
switch len(v) {
|
|
||||||
case 1:
|
|
||||||
return v[0], nil
|
|
||||||
case 0:
|
|
||||||
err = &NotFoundError{meta.Label}
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("ent: MetaSelect.Bools returned %d results when one was expected", len(v))
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// BoolX is like Bool, but panics if an error occurs.
|
|
||||||
func (ms *MetaSelect) BoolX(ctx context.Context) bool {
|
|
||||||
v, err := ms.Bool(ctx)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ms *MetaSelect) sqlScan(ctx context.Context, v interface{}) error {
|
|
||||||
rows := &sql.Rows{}
|
rows := &sql.Rows{}
|
||||||
query, args := ms.sql.Query()
|
query, args := ms.sql.Query()
|
||||||
if err := ms.driver.Query(ctx, query, args, rows); err != nil {
|
if err := ms.driver.Query(ctx, query, args, rows); err != nil {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ func (mu *MetaUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
err = &NotFoundError{meta.Label}
|
err = &NotFoundError{meta.Label}
|
||||||
} else if sqlgraph.IsConstraintError(err) {
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
@ -395,9 +395,15 @@ func (muo *MetaUpdateOne) Save(ctx context.Context) (*Meta, error) {
|
||||||
}
|
}
|
||||||
mut = muo.hooks[i](mut)
|
mut = muo.hooks[i](mut)
|
||||||
}
|
}
|
||||||
if _, err := mut.Mutate(ctx, muo.mutation); err != nil {
|
v, err := mut.Mutate(ctx, muo.mutation)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
nv, ok := v.(*Meta)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("unexpected node type %T returned from MetaMutation", v)
|
||||||
|
}
|
||||||
|
node = nv
|
||||||
}
|
}
|
||||||
return node, err
|
return node, err
|
||||||
}
|
}
|
||||||
|
@ -563,7 +569,7 @@ func (muo *MetaUpdateOne) sqlSave(ctx context.Context) (_node *Meta, err error)
|
||||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||||
err = &NotFoundError{meta.Label}
|
err = &NotFoundError{meta.Label}
|
||||||
} else if sqlgraph.IsConstraintError(err) {
|
} else if sqlgraph.IsConstraintError(err) {
|
||||||
err = &ConstraintError{err.Error(), err}
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package migrate
|
package migrate
|
||||||
|
|
||||||
|
@ -28,9 +28,6 @@ var (
|
||||||
// and therefore, it's recommended to enable this option to get more
|
// and therefore, it's recommended to enable this option to get more
|
||||||
// flexibility in the schema changes.
|
// flexibility in the schema changes.
|
||||||
WithDropIndex = schema.WithDropIndex
|
WithDropIndex = schema.WithDropIndex
|
||||||
// WithFixture sets the foreign-key renaming option to the migration when upgrading
|
|
||||||
// ent from v0.1.0 (issue-#285). Defaults to false.
|
|
||||||
WithFixture = schema.WithFixture
|
|
||||||
// WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true.
|
// WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true.
|
||||||
WithForeignKeys = schema.WithForeignKeys
|
WithForeignKeys = schema.WithForeignKeys
|
||||||
)
|
)
|
||||||
|
@ -45,27 +42,23 @@ func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} }
|
||||||
|
|
||||||
// Create creates all schema resources.
|
// Create creates all schema resources.
|
||||||
func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error {
|
func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error {
|
||||||
|
return Create(ctx, s, Tables, opts...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create creates all table resources using the given schema driver.
|
||||||
|
func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error {
|
||||||
migrate, err := schema.NewMigrate(s.drv, opts...)
|
migrate, err := schema.NewMigrate(s.drv, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("ent/migrate: %w", err)
|
return fmt.Errorf("ent/migrate: %w", err)
|
||||||
}
|
}
|
||||||
return migrate.Create(ctx, Tables...)
|
return migrate.Create(ctx, tables...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteTo writes the schema changes to w instead of running them against the database.
|
// WriteTo writes the schema changes to w instead of running them against the database.
|
||||||
//
|
//
|
||||||
// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
|
// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
|
||||||
// log.Fatal(err)
|
// log.Fatal(err)
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error {
|
func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error {
|
||||||
drv := &schema.WriteDriver{
|
return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...)
|
||||||
Writer: w,
|
|
||||||
Driver: s.drv,
|
|
||||||
}
|
|
||||||
migrate, err := schema.NewMigrate(drv, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("ent/migrate: %w", err)
|
|
||||||
}
|
|
||||||
return migrate.Create(ctx, Tables...)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package migrate
|
package migrate
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -4654,8 +4654,6 @@ func (m *DecisionMutation) RemovedEdges() []string {
|
||||||
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
||||||
// the given name in this mutation.
|
// the given name in this mutation.
|
||||||
func (m *DecisionMutation) RemovedIDs(name string) []ent.Value {
|
func (m *DecisionMutation) RemovedIDs(name string) []ent.Value {
|
||||||
switch name {
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5237,8 +5235,6 @@ func (m *EventMutation) RemovedEdges() []string {
|
||||||
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
||||||
// the given name in this mutation.
|
// the given name in this mutation.
|
||||||
func (m *EventMutation) RemovedIDs(name string) []ent.Value {
|
func (m *EventMutation) RemovedIDs(name string) []ent.Value {
|
||||||
switch name {
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6954,8 +6950,6 @@ func (m *MetaMutation) RemovedEdges() []string {
|
||||||
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
||||||
// the given name in this mutation.
|
// the given name in this mutation.
|
||||||
func (m *MetaMutation) RemovedIDs(name string) []ent.Value {
|
func (m *MetaMutation) RemovedIDs(name string) []ent.Value {
|
||||||
switch name {
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package predicate
|
package predicate
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package runtime
|
package runtime
|
||||||
|
|
||||||
// The schema-stitching logic is generated in github.com/crowdsecurity/crowdsec/pkg/database/ent/runtime.go
|
// The schema-stitching logic is generated in github.com/crowdsecurity/crowdsec/pkg/database/ent/runtime.go
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Version = "v0.10.1" // Version of ent codegen.
|
Version = "v0.11.3" // Version of ent codegen.
|
||||||
Sum = "h1:dM5h4Zk6yHGIgw4dCqVzGw3nWgpGYJiV4/kyHEF6PFo=" // Sum of ent codegen.
|
Sum = "h1:F5FBGAWiDCGder7YT+lqMnyzXl6d0xU3xMBM/SO3CMc=" // Sum of ent codegen.
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Code generated by entc, DO NOT EDIT.
|
// Code generated by ent, DO NOT EDIT.
|
||||||
|
|
||||||
package ent
|
package ent
|
||||||
|
|
||||||
|
@ -213,12 +213,12 @@ func (*txDriver) Commit() error { return nil }
|
||||||
func (*txDriver) Rollback() error { return nil }
|
func (*txDriver) Rollback() error { return nil }
|
||||||
|
|
||||||
// Exec calls tx.Exec.
|
// Exec calls tx.Exec.
|
||||||
func (tx *txDriver) Exec(ctx context.Context, query string, args, v interface{}) error {
|
func (tx *txDriver) Exec(ctx context.Context, query string, args, v any) error {
|
||||||
return tx.tx.Exec(ctx, query, args, v)
|
return tx.tx.Exec(ctx, query, args, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query calls tx.Query.
|
// Query calls tx.Query.
|
||||||
func (tx *txDriver) Query(ctx context.Context, query string, args, v interface{}) error {
|
func (tx *txDriver) Query(ctx context.Context, query string, args, v any) error {
|
||||||
return tx.tx.Query(ctx, query, args, v)
|
return tx.tx.Query(ctx, query, args, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue