Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
7319122e
Commit
7319122e
authored
Feb 06, 2026
by
LLLLLLiulei
Browse files
merge upstream/main
parents
029994a8
4809fa4f
Changes
89
Show whitespace changes
Inline
Side-by-side
.github/workflows/backend-ci.yml
View file @
7319122e
...
@@ -19,7 +19,7 @@ jobs:
...
@@ -19,7 +19,7 @@ jobs:
cache
:
true
cache
:
true
-
name
:
Verify Go version
-
name
:
Verify Go version
run
:
|
run
:
|
go version | grep -q 'go1.25.
6
'
go version | grep -q 'go1.25.
7
'
-
name
:
Unit tests
-
name
:
Unit tests
working-directory
:
backend
working-directory
:
backend
run
:
make test-unit
run
:
make test-unit
...
@@ -38,7 +38,7 @@ jobs:
...
@@ -38,7 +38,7 @@ jobs:
cache
:
true
cache
:
true
-
name
:
Verify Go version
-
name
:
Verify Go version
run
:
|
run
:
|
go version | grep -q 'go1.25.
6
'
go version | grep -q 'go1.25.
7
'
-
name
:
golangci-lint
-
name
:
golangci-lint
uses
:
golangci/golangci-lint-action@v9
uses
:
golangci/golangci-lint-action@v9
with
:
with
:
...
...
.github/workflows/release.yml
View file @
7319122e
...
@@ -115,7 +115,7 @@ jobs:
...
@@ -115,7 +115,7 @@ jobs:
-
name
:
Verify Go version
-
name
:
Verify Go version
run
:
|
run
:
|
go version | grep -q 'go1.25.
6
'
go version | grep -q 'go1.25.
7
'
# Docker setup for GoReleaser
# Docker setup for GoReleaser
-
name
:
Set up QEMU
-
name
:
Set up QEMU
...
...
.github/workflows/security-scan.yml
View file @
7319122e
...
@@ -22,7 +22,7 @@ jobs:
...
@@ -22,7 +22,7 @@ jobs:
cache-dependency-path
:
backend/go.sum
cache-dependency-path
:
backend/go.sum
-
name
:
Verify Go version
-
name
:
Verify Go version
run
:
|
run
:
|
go version | grep -q 'go1.25.
6
'
go version | grep -q 'go1.25.
7
'
-
name
:
Run govulncheck
-
name
:
Run govulncheck
working-directory
:
backend
working-directory
:
backend
run
:
|
run
:
|
...
...
Dockerfile
View file @
7319122e
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
# =============================================================================
# =============================================================================
ARG
NODE_IMAGE=node:24-alpine
ARG
NODE_IMAGE=node:24-alpine
ARG
GOLANG_IMAGE=golang:1.25.
6
-alpine
ARG
GOLANG_IMAGE=golang:1.25.
7
-alpine
ARG
ALPINE_IMAGE=alpine:3.20
ARG
ALPINE_IMAGE=alpine:3.20
ARG
GOPROXY=https://goproxy.cn,direct
ARG
GOPROXY=https://goproxy.cn,direct
ARG
GOSUMDB=sum.golang.google.cn
ARG
GOSUMDB=sum.golang.google.cn
...
...
PR_DESCRIPTION.md
deleted
100644 → 0
View file @
029994a8
## 概述
全面增强运维监控系统(Ops)的错误日志管理和告警静默功能,优化前端 UI 组件代码质量和用户体验。本次更新重构了核心服务层和数据访问层,提升系统可维护性和运维效率。
## 主要改动
### 1. 错误日志查询优化
**功能特性:**
-
新增 GetErrorLogByID 接口,支持按 ID 精确查询错误详情
-
优化错误日志过滤逻辑,支持多维度筛选(平台、阶段、来源、所有者等)
-
改进查询参数处理,简化代码结构
-
增强错误分类和标准化处理
-
支持错误解决状态追踪(resolved 字段)
**技术实现:**
-
`ops_handler.go`
- 新增单条错误日志查询接口
-
`ops_repo.go`
- 优化数据查询和过滤条件构建
-
`ops_models.go`
- 扩展错误日志数据模型
-
前端 API 接口同步更新
### 2. 告警静默功能
**功能特性:**
-
支持按规则、平台、分组、区域等维度静默告警
-
可设置静默时长和原因说明
-
静默记录可追溯,记录创建人和创建时间
-
自动过期机制,避免永久静默
**技术实现:**
-
`037_ops_alert_silences.sql`
- 新增告警静默表
-
`ops_alerts.go`
- 告警静默逻辑实现
-
`ops_alerts_handler.go`
- 告警静默 API 接口
-
`OpsAlertEventsCard.vue`
- 前端告警静默操作界面
**数据库结构:**
| 字段 | 类型 | 说明 |
|------|------|------|
| rule_id | BIGINT | 告警规则 ID |
| platform | VARCHAR(64) | 平台标识 |
| group_id | BIGINT | 分组 ID(可选) |
| region | VARCHAR(64) | 区域(可选) |
| until | TIMESTAMPTZ | 静默截止时间 |
| reason | TEXT | 静默原因 |
| created_by | BIGINT | 创建人 ID |
### 3. 错误分类标准化
**功能特性:**
-
统一错误阶段分类(request|auth|routing|upstream|network|internal)
-
规范错误归属分类(client|provider|platform)
-
标准化错误来源分类(client_request|upstream_http|gateway)
-
自动迁移历史数据到新分类体系
**技术实现:**
-
`038_ops_errors_resolution_retry_results_and_standardize_classification.sql`
- 分类标准化迁移
-
自动映射历史遗留分类到新标准
-
自动解决已恢复的上游错误(客户端状态码 < 400)
### 4. Gateway 服务集成
**功能特性:**
-
完善各 Gateway 服务的 Ops 集成
-
统一错误日志记录接口
-
增强上游错误追踪能力
**涉及服务:**
-
`antigravity_gateway_service.go`
- Antigravity 网关集成
-
`gateway_service.go`
- 通用网关集成
-
`gemini_messages_compat_service.go`
- Gemini 兼容层集成
-
`openai_gateway_service.go`
- OpenAI 网关集成
### 5. 前端 UI 优化
**代码重构:**
-
大幅简化错误详情模态框代码(从 828 行优化到 450 行)
-
优化错误日志表格组件,提升可读性
-
清理未使用的 i18n 翻译,减少冗余
-
统一组件代码风格和格式
-
优化骨架屏组件,更好匹配实际看板布局
**布局改进:**
-
修复模态框内容溢出和滚动问题
-
优化表格布局,使用 flex 布局确保正确显示
-
改进看板头部布局和交互
-
提升响应式体验
-
骨架屏支持全屏模式适配
**交互优化:**
-
优化告警事件卡片功能和展示
-
改进错误详情展示逻辑
-
增强请求详情模态框
-
完善运行时设置卡片
-
改进加载动画效果
### 6. 国际化完善
**文案补充:**
-
补充错误日志相关的英文翻译
-
添加告警静默功能的中英文文案
-
完善提示文本和错误信息
-
统一术语翻译标准
## 文件变更
**后端(26 个文件):**
-
`backend/internal/handler/admin/ops_alerts_handler.go`
- 告警接口增强
-
`backend/internal/handler/admin/ops_handler.go`
- 错误日志接口优化
-
`backend/internal/handler/ops_error_logger.go`
- 错误记录器增强
-
`backend/internal/repository/ops_repo.go`
- 数据访问层重构
-
`backend/internal/repository/ops_repo_alerts.go`
- 告警数据访问增强
-
`backend/internal/service/ops_*.go`
- 核心服务层重构(10 个文件)
-
`backend/internal/service/*_gateway_service.go`
- Gateway 集成(4 个文件)
-
`backend/internal/server/routes/admin.go`
- 路由配置更新
-
`backend/migrations/*.sql`
- 数据库迁移(2 个文件)
-
测试文件更新(5 个文件)
**前端(13 个文件):**
-
`frontend/src/views/admin/ops/OpsDashboard.vue`
- 看板主页优化
-
`frontend/src/views/admin/ops/components/*.vue`
- 组件重构(10 个文件)
-
`frontend/src/api/admin/ops.ts`
- API 接口扩展
-
`frontend/src/i18n/locales/*.ts`
- 国际化文本(2 个文件)
## 代码统计
-
44 个文件修改
-
3733 行新增
-
995 行删除
-
净增加 2738 行
## 核心改进
**可维护性提升:**
-
重构核心服务层,职责更清晰
-
简化前端组件代码,降低复杂度
-
统一代码风格和命名规范
-
清理冗余代码和未使用的翻译
-
标准化错误分类体系
**功能完善:**
-
告警静默功能,减少告警噪音
-
错误日志查询优化,提升运维效率
-
Gateway 服务集成完善,统一监控能力
-
错误解决状态追踪,便于问题管理
**用户体验优化:**
-
修复多个 UI 布局问题
-
优化交互流程
-
完善国际化支持
-
提升响应式体验
-
改进加载状态展示
## 测试验证
-
✅ 错误日志查询和过滤功能
-
✅ 告警静默创建和自动过期
-
✅ 错误分类标准化迁移
-
✅ Gateway 服务错误日志记录
-
✅ 前端组件布局和交互
-
✅ 骨架屏全屏模式适配
-
✅ 国际化文本完整性
-
✅ API 接口功能正确性
-
✅ 数据库迁移执行成功
README.md
View file @
7319122e
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<div
align=
"center"
>
<div
align=
"center"
>
[

](https://golang.org/)
[

](https://golang.org/)
[

](https://vuejs.org/)
[

](https://vuejs.org/)
[

](https://www.postgresql.org/)
[

](https://www.postgresql.org/)
[

](https://redis.io/)
[

](https://redis.io/)
...
@@ -44,7 +44,7 @@ Sub2API is an AI API gateway platform designed to distribute and manage API quot
...
@@ -44,7 +44,7 @@ Sub2API is an AI API gateway platform designed to distribute and manage API quot
| Component | Technology |
| Component | Technology |
|-----------|------------|
|-----------|------------|
| Backend | Go 1.25.
5
, Gin, Ent |
| Backend | Go 1.25.
7
, Gin, Ent |
| Frontend | Vue 3.4+, Vite 5+, TailwindCSS |
| Frontend | Vue 3.4+, Vite 5+, TailwindCSS |
| Database | PostgreSQL 15+ |
| Database | PostgreSQL 15+ |
| Cache/Queue | Redis 7+ |
| Cache/Queue | Redis 7+ |
...
...
README_CN.md
View file @
7319122e
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<div
align=
"center"
>
<div
align=
"center"
>
[

](https://golang.org/)
[

](https://golang.org/)
[

](https://vuejs.org/)
[

](https://vuejs.org/)
[

](https://www.postgresql.org/)
[

](https://www.postgresql.org/)
[

](https://redis.io/)
[

](https://redis.io/)
...
@@ -44,7 +44,7 @@ Sub2API 是一个 AI API 网关平台,用于分发和管理 AI 产品订阅(
...
@@ -44,7 +44,7 @@ Sub2API 是一个 AI API 网关平台,用于分发和管理 AI 产品订阅(
| 组件 | 技术 |
| 组件 | 技术 |
|------|------|
|------|------|
| 后端 | Go 1.25.
5
, Gin, Ent |
| 后端 | Go 1.25.
7
, Gin, Ent |
| 前端 | Vue 3.4+, Vite 5+, TailwindCSS |
| 前端 | Vue 3.4+, Vite 5+, TailwindCSS |
| 数据库 | PostgreSQL 15+ |
| 数据库 | PostgreSQL 15+ |
| 缓存/队列 | Redis 7+ |
| 缓存/队列 | Redis 7+ |
...
...
backend/Dockerfile
View file @
7319122e
FROM
golang:1.25.
6
-alpine
FROM
golang:1.25.
7
-alpine
WORKDIR
/app
WORKDIR
/app
...
...
backend/cmd/server/VERSION
View file @
7319122e
0.1.
61
0.1.
70
backend/cmd/server/wire_gen.go
View file @
7319122e
...
@@ -59,8 +59,9 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
...
@@ -59,8 +59,9 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
billingCacheService
:=
service
.
NewBillingCacheService
(
billingCache
,
userRepository
,
userSubscriptionRepository
,
configConfig
)
billingCacheService
:=
service
.
NewBillingCacheService
(
billingCache
,
userRepository
,
userSubscriptionRepository
,
configConfig
)
apiKeyRepository
:=
repository
.
NewAPIKeyRepository
(
client
)
apiKeyRepository
:=
repository
.
NewAPIKeyRepository
(
client
)
groupRepository
:=
repository
.
NewGroupRepository
(
client
,
db
)
groupRepository
:=
repository
.
NewGroupRepository
(
client
,
db
)
userGroupRateRepository
:=
repository
.
NewUserGroupRateRepository
(
db
)
apiKeyCache
:=
repository
.
NewAPIKeyCache
(
redisClient
)
apiKeyCache
:=
repository
.
NewAPIKeyCache
(
redisClient
)
apiKeyService
:=
service
.
NewAPIKeyService
(
apiKeyRepository
,
userRepository
,
groupRepository
,
userSubscriptionRepository
,
apiKeyCache
,
configConfig
)
apiKeyService
:=
service
.
NewAPIKeyService
(
apiKeyRepository
,
userRepository
,
groupRepository
,
userSubscriptionRepository
,
userGroupRateRepository
,
apiKeyCache
,
configConfig
)
apiKeyAuthCacheInvalidator
:=
service
.
ProvideAPIKeyAuthCacheInvalidator
(
apiKeyService
)
apiKeyAuthCacheInvalidator
:=
service
.
ProvideAPIKeyAuthCacheInvalidator
(
apiKeyService
)
promoService
:=
service
.
NewPromoService
(
promoCodeRepository
,
userRepository
,
billingCacheService
,
client
,
apiKeyAuthCacheInvalidator
)
promoService
:=
service
.
NewPromoService
(
promoCodeRepository
,
userRepository
,
billingCacheService
,
client
,
apiKeyAuthCacheInvalidator
)
authService
:=
service
.
NewAuthService
(
userRepository
,
redeemCodeRepository
,
refreshTokenCache
,
configConfig
,
settingService
,
emailService
,
turnstileService
,
emailQueueService
,
promoService
)
authService
:=
service
.
NewAuthService
(
userRepository
,
redeemCodeRepository
,
refreshTokenCache
,
configConfig
,
settingService
,
emailService
,
turnstileService
,
emailQueueService
,
promoService
)
...
@@ -100,7 +101,7 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
...
@@ -100,7 +101,7 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
proxyRepository
:=
repository
.
NewProxyRepository
(
client
,
db
)
proxyRepository
:=
repository
.
NewProxyRepository
(
client
,
db
)
proxyExitInfoProber
:=
repository
.
NewProxyExitInfoProber
(
configConfig
)
proxyExitInfoProber
:=
repository
.
NewProxyExitInfoProber
(
configConfig
)
proxyLatencyCache
:=
repository
.
NewProxyLatencyCache
(
redisClient
)
proxyLatencyCache
:=
repository
.
NewProxyLatencyCache
(
redisClient
)
adminService
:=
service
.
NewAdminService
(
userRepository
,
groupRepository
,
accountRepository
,
proxyRepository
,
apiKeyRepository
,
redeemCodeRepository
,
billingCacheService
,
proxyExitInfoProber
,
proxyLatencyCache
,
apiKeyAuthCacheInvalidator
)
adminService
:=
service
.
NewAdminService
(
userRepository
,
groupRepository
,
accountRepository
,
proxyRepository
,
apiKeyRepository
,
redeemCodeRepository
,
userGroupRateRepository
,
billingCacheService
,
proxyExitInfoProber
,
proxyLatencyCache
,
apiKeyAuthCacheInvalidator
)
adminUserHandler
:=
admin
.
NewUserHandler
(
adminService
)
adminUserHandler
:=
admin
.
NewUserHandler
(
adminService
)
groupHandler
:=
admin
.
NewGroupHandler
(
adminService
)
groupHandler
:=
admin
.
NewGroupHandler
(
adminService
)
claudeOAuthClient
:=
repository
.
NewClaudeOAuthClient
()
claudeOAuthClient
:=
repository
.
NewClaudeOAuthClient
()
...
@@ -153,7 +154,7 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
...
@@ -153,7 +154,7 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
identityService
:=
service
.
NewIdentityService
(
identityCache
)
identityService
:=
service
.
NewIdentityService
(
identityCache
)
deferredService
:=
service
.
ProvideDeferredService
(
accountRepository
,
timingWheelService
)
deferredService
:=
service
.
ProvideDeferredService
(
accountRepository
,
timingWheelService
)
claudeTokenProvider
:=
service
.
NewClaudeTokenProvider
(
accountRepository
,
geminiTokenCache
,
oAuthService
)
claudeTokenProvider
:=
service
.
NewClaudeTokenProvider
(
accountRepository
,
geminiTokenCache
,
oAuthService
)
gatewayService
:=
service
.
NewGatewayService
(
accountRepository
,
groupRepository
,
usageLogRepository
,
userRepository
,
userSubscriptionRepository
,
gatewayCache
,
configConfig
,
schedulerSnapshotService
,
concurrencyService
,
billingService
,
rateLimitService
,
billingCacheService
,
identityService
,
httpUpstream
,
deferredService
,
claudeTokenProvider
,
sessionLimitCache
)
gatewayService
:=
service
.
NewGatewayService
(
accountRepository
,
groupRepository
,
usageLogRepository
,
userRepository
,
userSubscriptionRepository
,
userGroupRateRepository
,
gatewayCache
,
configConfig
,
schedulerSnapshotService
,
concurrencyService
,
billingService
,
rateLimitService
,
billingCacheService
,
identityService
,
httpUpstream
,
deferredService
,
claudeTokenProvider
,
sessionLimitCache
)
openAITokenProvider
:=
service
.
NewOpenAITokenProvider
(
accountRepository
,
geminiTokenCache
,
openAIOAuthService
)
openAITokenProvider
:=
service
.
NewOpenAITokenProvider
(
accountRepository
,
geminiTokenCache
,
openAIOAuthService
)
openAIGatewayService
:=
service
.
NewOpenAIGatewayService
(
accountRepository
,
usageLogRepository
,
userRepository
,
userSubscriptionRepository
,
gatewayCache
,
configConfig
,
schedulerSnapshotService
,
concurrencyService
,
billingService
,
rateLimitService
,
billingCacheService
,
httpUpstream
,
deferredService
,
openAITokenProvider
)
openAIGatewayService
:=
service
.
NewOpenAIGatewayService
(
accountRepository
,
usageLogRepository
,
userRepository
,
userSubscriptionRepository
,
gatewayCache
,
configConfig
,
schedulerSnapshotService
,
concurrencyService
,
billingService
,
rateLimitService
,
billingCacheService
,
httpUpstream
,
deferredService
,
openAITokenProvider
)
geminiMessagesCompatService
:=
service
.
NewGeminiMessagesCompatService
(
accountRepository
,
groupRepository
,
gatewayCache
,
schedulerSnapshotService
,
geminiTokenProvider
,
rateLimitService
,
httpUpstream
,
antigravityGatewayService
,
configConfig
)
geminiMessagesCompatService
:=
service
.
NewGeminiMessagesCompatService
(
accountRepository
,
groupRepository
,
gatewayCache
,
schedulerSnapshotService
,
geminiTokenProvider
,
rateLimitService
,
httpUpstream
,
antigravityGatewayService
,
configConfig
)
...
@@ -173,9 +174,13 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
...
@@ -173,9 +174,13 @@ func initializeApplication(buildInfo handler.BuildInfo) (*Application, error) {
userAttributeValueRepository
:=
repository
.
NewUserAttributeValueRepository
(
client
)
userAttributeValueRepository
:=
repository
.
NewUserAttributeValueRepository
(
client
)
userAttributeService
:=
service
.
NewUserAttributeService
(
userAttributeDefinitionRepository
,
userAttributeValueRepository
)
userAttributeService
:=
service
.
NewUserAttributeService
(
userAttributeDefinitionRepository
,
userAttributeValueRepository
)
userAttributeHandler
:=
admin
.
NewUserAttributeHandler
(
userAttributeService
)
userAttributeHandler
:=
admin
.
NewUserAttributeHandler
(
userAttributeService
)
adminHandlers
:=
handler
.
ProvideAdminHandlers
(
dashboardHandler
,
adminUserHandler
,
groupHandler
,
accountHandler
,
adminAnnouncementHandler
,
oAuthHandler
,
openAIOAuthHandler
,
geminiOAuthHandler
,
antigravityOAuthHandler
,
proxyHandler
,
adminRedeemHandler
,
promoHandler
,
settingHandler
,
opsHandler
,
systemHandler
,
adminSubscriptionHandler
,
adminUsageHandler
,
userAttributeHandler
)
errorPassthroughRepository
:=
repository
.
NewErrorPassthroughRepository
(
client
)
gatewayHandler
:=
handler
.
NewGatewayHandler
(
gatewayService
,
geminiMessagesCompatService
,
antigravityGatewayService
,
userService
,
concurrencyService
,
billingCacheService
,
usageService
,
apiKeyService
,
configConfig
)
errorPassthroughCache
:=
repository
.
NewErrorPassthroughCache
(
redisClient
)
openAIGatewayHandler
:=
handler
.
NewOpenAIGatewayHandler
(
openAIGatewayService
,
concurrencyService
,
billingCacheService
,
apiKeyService
,
configConfig
)
errorPassthroughService
:=
service
.
NewErrorPassthroughService
(
errorPassthroughRepository
,
errorPassthroughCache
)
errorPassthroughHandler
:=
admin
.
NewErrorPassthroughHandler
(
errorPassthroughService
)
adminHandlers
:=
handler
.
ProvideAdminHandlers
(
dashboardHandler
,
adminUserHandler
,
groupHandler
,
accountHandler
,
adminAnnouncementHandler
,
oAuthHandler
,
openAIOAuthHandler
,
geminiOAuthHandler
,
antigravityOAuthHandler
,
proxyHandler
,
adminRedeemHandler
,
promoHandler
,
settingHandler
,
opsHandler
,
systemHandler
,
adminSubscriptionHandler
,
adminUsageHandler
,
userAttributeHandler
,
errorPassthroughHandler
)
gatewayHandler
:=
handler
.
NewGatewayHandler
(
gatewayService
,
geminiMessagesCompatService
,
antigravityGatewayService
,
userService
,
concurrencyService
,
billingCacheService
,
usageService
,
apiKeyService
,
errorPassthroughService
,
configConfig
)
openAIGatewayHandler
:=
handler
.
NewOpenAIGatewayHandler
(
openAIGatewayService
,
concurrencyService
,
billingCacheService
,
apiKeyService
,
errorPassthroughService
,
configConfig
)
handlerSettingHandler
:=
handler
.
ProvideSettingHandler
(
settingService
,
buildInfo
)
handlerSettingHandler
:=
handler
.
ProvideSettingHandler
(
settingService
,
buildInfo
)
totpHandler
:=
handler
.
NewTotpHandler
(
totpService
)
totpHandler
:=
handler
.
NewTotpHandler
(
totpService
)
handlers
:=
handler
.
ProvideHandlers
(
authHandler
,
userHandler
,
apiKeyHandler
,
usageHandler
,
redeemHandler
,
subscriptionHandler
,
announcementHandler
,
adminHandlers
,
gatewayHandler
,
openAIGatewayHandler
,
handlerSettingHandler
,
totpHandler
)
handlers
:=
handler
.
ProvideHandlers
(
authHandler
,
userHandler
,
apiKeyHandler
,
usageHandler
,
redeemHandler
,
subscriptionHandler
,
announcementHandler
,
adminHandlers
,
gatewayHandler
,
openAIGatewayHandler
,
handlerSettingHandler
,
totpHandler
)
...
...
backend/ent/client.go
View file @
7319122e
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"github.com/Wei-Shaw/sub2api/ent/announcement"
"github.com/Wei-Shaw/sub2api/ent/announcement"
"github.com/Wei-Shaw/sub2api/ent/announcementread"
"github.com/Wei-Shaw/sub2api/ent/announcementread"
"github.com/Wei-Shaw/sub2api/ent/apikey"
"github.com/Wei-Shaw/sub2api/ent/apikey"
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
"github.com/Wei-Shaw/sub2api/ent/group"
"github.com/Wei-Shaw/sub2api/ent/group"
"github.com/Wei-Shaw/sub2api/ent/promocode"
"github.com/Wei-Shaw/sub2api/ent/promocode"
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
...
@@ -52,6 +53,8 @@ type Client struct {
...
@@ -52,6 +53,8 @@ type Client struct {
Announcement
*
AnnouncementClient
Announcement
*
AnnouncementClient
// AnnouncementRead is the client for interacting with the AnnouncementRead builders.
// AnnouncementRead is the client for interacting with the AnnouncementRead builders.
AnnouncementRead
*
AnnouncementReadClient
AnnouncementRead
*
AnnouncementReadClient
// ErrorPassthroughRule is the client for interacting with the ErrorPassthroughRule builders.
ErrorPassthroughRule
*
ErrorPassthroughRuleClient
// Group is the client for interacting with the Group builders.
// Group is the client for interacting with the Group builders.
Group
*
GroupClient
Group
*
GroupClient
// PromoCode is the client for interacting with the PromoCode builders.
// PromoCode is the client for interacting with the PromoCode builders.
...
@@ -94,6 +97,7 @@ func (c *Client) init() {
...
@@ -94,6 +97,7 @@ func (c *Client) init() {
c
.
AccountGroup
=
NewAccountGroupClient
(
c
.
config
)
c
.
AccountGroup
=
NewAccountGroupClient
(
c
.
config
)
c
.
Announcement
=
NewAnnouncementClient
(
c
.
config
)
c
.
Announcement
=
NewAnnouncementClient
(
c
.
config
)
c
.
AnnouncementRead
=
NewAnnouncementReadClient
(
c
.
config
)
c
.
AnnouncementRead
=
NewAnnouncementReadClient
(
c
.
config
)
c
.
ErrorPassthroughRule
=
NewErrorPassthroughRuleClient
(
c
.
config
)
c
.
Group
=
NewGroupClient
(
c
.
config
)
c
.
Group
=
NewGroupClient
(
c
.
config
)
c
.
PromoCode
=
NewPromoCodeClient
(
c
.
config
)
c
.
PromoCode
=
NewPromoCodeClient
(
c
.
config
)
c
.
PromoCodeUsage
=
NewPromoCodeUsageClient
(
c
.
config
)
c
.
PromoCodeUsage
=
NewPromoCodeUsageClient
(
c
.
config
)
...
@@ -204,6 +208,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
...
@@ -204,6 +208,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
AccountGroup
:
NewAccountGroupClient
(
cfg
),
AccountGroup
:
NewAccountGroupClient
(
cfg
),
Announcement
:
NewAnnouncementClient
(
cfg
),
Announcement
:
NewAnnouncementClient
(
cfg
),
AnnouncementRead
:
NewAnnouncementReadClient
(
cfg
),
AnnouncementRead
:
NewAnnouncementReadClient
(
cfg
),
ErrorPassthroughRule
:
NewErrorPassthroughRuleClient
(
cfg
),
Group
:
NewGroupClient
(
cfg
),
Group
:
NewGroupClient
(
cfg
),
PromoCode
:
NewPromoCodeClient
(
cfg
),
PromoCode
:
NewPromoCodeClient
(
cfg
),
PromoCodeUsage
:
NewPromoCodeUsageClient
(
cfg
),
PromoCodeUsage
:
NewPromoCodeUsageClient
(
cfg
),
...
@@ -241,6 +246,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
...
@@ -241,6 +246,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
AccountGroup
:
NewAccountGroupClient
(
cfg
),
AccountGroup
:
NewAccountGroupClient
(
cfg
),
Announcement
:
NewAnnouncementClient
(
cfg
),
Announcement
:
NewAnnouncementClient
(
cfg
),
AnnouncementRead
:
NewAnnouncementReadClient
(
cfg
),
AnnouncementRead
:
NewAnnouncementReadClient
(
cfg
),
ErrorPassthroughRule
:
NewErrorPassthroughRuleClient
(
cfg
),
Group
:
NewGroupClient
(
cfg
),
Group
:
NewGroupClient
(
cfg
),
PromoCode
:
NewPromoCodeClient
(
cfg
),
PromoCode
:
NewPromoCodeClient
(
cfg
),
PromoCodeUsage
:
NewPromoCodeUsageClient
(
cfg
),
PromoCodeUsage
:
NewPromoCodeUsageClient
(
cfg
),
...
@@ -284,9 +290,10 @@ func (c *Client) Close() error {
...
@@ -284,9 +290,10 @@ func (c *Client) Close() error {
func
(
c
*
Client
)
Use
(
hooks
...
Hook
)
{
func
(
c
*
Client
)
Use
(
hooks
...
Hook
)
{
for
_
,
n
:=
range
[]
interface
{
Use
(
...
Hook
)
}{
for
_
,
n
:=
range
[]
interface
{
Use
(
...
Hook
)
}{
c
.
APIKey
,
c
.
Account
,
c
.
AccountGroup
,
c
.
Announcement
,
c
.
AnnouncementRead
,
c
.
APIKey
,
c
.
Account
,
c
.
AccountGroup
,
c
.
Announcement
,
c
.
AnnouncementRead
,
c
.
Group
,
c
.
PromoCode
,
c
.
PromoCodeUsage
,
c
.
Proxy
,
c
.
RedeemCode
,
c
.
Setting
,
c
.
ErrorPassthroughRule
,
c
.
Group
,
c
.
PromoCode
,
c
.
PromoCodeUsage
,
c
.
Proxy
,
c
.
UsageCleanupTask
,
c
.
UsageLog
,
c
.
User
,
c
.
UserAllowedGroup
,
c
.
RedeemCode
,
c
.
Setting
,
c
.
UsageCleanupTask
,
c
.
UsageLog
,
c
.
User
,
c
.
UserAttributeDefinition
,
c
.
UserAttributeValue
,
c
.
UserSubscription
,
c
.
UserAllowedGroup
,
c
.
UserAttributeDefinition
,
c
.
UserAttributeValue
,
c
.
UserSubscription
,
}
{
}
{
n
.
Use
(
hooks
...
)
n
.
Use
(
hooks
...
)
}
}
...
@@ -297,9 +304,10 @@ func (c *Client) Use(hooks ...Hook) {
...
@@ -297,9 +304,10 @@ func (c *Client) Use(hooks ...Hook) {
func
(
c
*
Client
)
Intercept
(
interceptors
...
Interceptor
)
{
func
(
c
*
Client
)
Intercept
(
interceptors
...
Interceptor
)
{
for
_
,
n
:=
range
[]
interface
{
Intercept
(
...
Interceptor
)
}{
for
_
,
n
:=
range
[]
interface
{
Intercept
(
...
Interceptor
)
}{
c
.
APIKey
,
c
.
Account
,
c
.
AccountGroup
,
c
.
Announcement
,
c
.
AnnouncementRead
,
c
.
APIKey
,
c
.
Account
,
c
.
AccountGroup
,
c
.
Announcement
,
c
.
AnnouncementRead
,
c
.
Group
,
c
.
PromoCode
,
c
.
PromoCodeUsage
,
c
.
Proxy
,
c
.
RedeemCode
,
c
.
Setting
,
c
.
ErrorPassthroughRule
,
c
.
Group
,
c
.
PromoCode
,
c
.
PromoCodeUsage
,
c
.
Proxy
,
c
.
UsageCleanupTask
,
c
.
UsageLog
,
c
.
User
,
c
.
UserAllowedGroup
,
c
.
RedeemCode
,
c
.
Setting
,
c
.
UsageCleanupTask
,
c
.
UsageLog
,
c
.
User
,
c
.
UserAttributeDefinition
,
c
.
UserAttributeValue
,
c
.
UserSubscription
,
c
.
UserAllowedGroup
,
c
.
UserAttributeDefinition
,
c
.
UserAttributeValue
,
c
.
UserSubscription
,
}
{
}
{
n
.
Intercept
(
interceptors
...
)
n
.
Intercept
(
interceptors
...
)
}
}
...
@@ -318,6 +326,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
...
@@ -318,6 +326,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
return
c
.
Announcement
.
mutate
(
ctx
,
m
)
return
c
.
Announcement
.
mutate
(
ctx
,
m
)
case
*
AnnouncementReadMutation
:
case
*
AnnouncementReadMutation
:
return
c
.
AnnouncementRead
.
mutate
(
ctx
,
m
)
return
c
.
AnnouncementRead
.
mutate
(
ctx
,
m
)
case
*
ErrorPassthroughRuleMutation
:
return
c
.
ErrorPassthroughRule
.
mutate
(
ctx
,
m
)
case
*
GroupMutation
:
case
*
GroupMutation
:
return
c
.
Group
.
mutate
(
ctx
,
m
)
return
c
.
Group
.
mutate
(
ctx
,
m
)
case
*
PromoCodeMutation
:
case
*
PromoCodeMutation
:
...
@@ -1161,6 +1171,139 @@ func (c *AnnouncementReadClient) mutate(ctx context.Context, m *AnnouncementRead
...
@@ -1161,6 +1171,139 @@ func (c *AnnouncementReadClient) mutate(ctx context.Context, m *AnnouncementRead
}
}
}
}
// ErrorPassthroughRuleClient is a client for the ErrorPassthroughRule schema.
type
ErrorPassthroughRuleClient
struct
{
config
}
// NewErrorPassthroughRuleClient returns a client for the ErrorPassthroughRule from the given config.
func
NewErrorPassthroughRuleClient
(
c
config
)
*
ErrorPassthroughRuleClient
{
return
&
ErrorPassthroughRuleClient
{
config
:
c
}
}
// Use adds a list of mutation hooks to the hooks stack.
// A call to `Use(f, g, h)` equals to `errorpassthroughrule.Hooks(f(g(h())))`.
func
(
c
*
ErrorPassthroughRuleClient
)
Use
(
hooks
...
Hook
)
{
c
.
hooks
.
ErrorPassthroughRule
=
append
(
c
.
hooks
.
ErrorPassthroughRule
,
hooks
...
)
}
// Intercept adds a list of query interceptors to the interceptors stack.
// A call to `Intercept(f, g, h)` equals to `errorpassthroughrule.Intercept(f(g(h())))`.
func
(
c
*
ErrorPassthroughRuleClient
)
Intercept
(
interceptors
...
Interceptor
)
{
c
.
inters
.
ErrorPassthroughRule
=
append
(
c
.
inters
.
ErrorPassthroughRule
,
interceptors
...
)
}
// Create returns a builder for creating a ErrorPassthroughRule entity.
func
(
c
*
ErrorPassthroughRuleClient
)
Create
()
*
ErrorPassthroughRuleCreate
{
mutation
:=
newErrorPassthroughRuleMutation
(
c
.
config
,
OpCreate
)
return
&
ErrorPassthroughRuleCreate
{
config
:
c
.
config
,
hooks
:
c
.
Hooks
(),
mutation
:
mutation
}
}
// CreateBulk returns a builder for creating a bulk of ErrorPassthroughRule entities.
func
(
c
*
ErrorPassthroughRuleClient
)
CreateBulk
(
builders
...*
ErrorPassthroughRuleCreate
)
*
ErrorPassthroughRuleCreateBulk
{
return
&
ErrorPassthroughRuleCreateBulk
{
config
:
c
.
config
,
builders
:
builders
}
}
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
// a builder and applies setFunc on it.
func
(
c
*
ErrorPassthroughRuleClient
)
MapCreateBulk
(
slice
any
,
setFunc
func
(
*
ErrorPassthroughRuleCreate
,
int
))
*
ErrorPassthroughRuleCreateBulk
{
rv
:=
reflect
.
ValueOf
(
slice
)
if
rv
.
Kind
()
!=
reflect
.
Slice
{
return
&
ErrorPassthroughRuleCreateBulk
{
err
:
fmt
.
Errorf
(
"calling to ErrorPassthroughRuleClient.MapCreateBulk with wrong type %T, need slice"
,
slice
)}
}
builders
:=
make
([]
*
ErrorPassthroughRuleCreate
,
rv
.
Len
())
for
i
:=
0
;
i
<
rv
.
Len
();
i
++
{
builders
[
i
]
=
c
.
Create
()
setFunc
(
builders
[
i
],
i
)
}
return
&
ErrorPassthroughRuleCreateBulk
{
config
:
c
.
config
,
builders
:
builders
}
}
// Update returns an update builder for ErrorPassthroughRule.
func
(
c
*
ErrorPassthroughRuleClient
)
Update
()
*
ErrorPassthroughRuleUpdate
{
mutation
:=
newErrorPassthroughRuleMutation
(
c
.
config
,
OpUpdate
)
return
&
ErrorPassthroughRuleUpdate
{
config
:
c
.
config
,
hooks
:
c
.
Hooks
(),
mutation
:
mutation
}
}
// UpdateOne returns an update builder for the given entity.
func
(
c
*
ErrorPassthroughRuleClient
)
UpdateOne
(
_m
*
ErrorPassthroughRule
)
*
ErrorPassthroughRuleUpdateOne
{
mutation
:=
newErrorPassthroughRuleMutation
(
c
.
config
,
OpUpdateOne
,
withErrorPassthroughRule
(
_m
))
return
&
ErrorPassthroughRuleUpdateOne
{
config
:
c
.
config
,
hooks
:
c
.
Hooks
(),
mutation
:
mutation
}
}
// UpdateOneID returns an update builder for the given id.
func
(
c
*
ErrorPassthroughRuleClient
)
UpdateOneID
(
id
int64
)
*
ErrorPassthroughRuleUpdateOne
{
mutation
:=
newErrorPassthroughRuleMutation
(
c
.
config
,
OpUpdateOne
,
withErrorPassthroughRuleID
(
id
))
return
&
ErrorPassthroughRuleUpdateOne
{
config
:
c
.
config
,
hooks
:
c
.
Hooks
(),
mutation
:
mutation
}
}
// Delete returns a delete builder for ErrorPassthroughRule.
func
(
c
*
ErrorPassthroughRuleClient
)
Delete
()
*
ErrorPassthroughRuleDelete
{
mutation
:=
newErrorPassthroughRuleMutation
(
c
.
config
,
OpDelete
)
return
&
ErrorPassthroughRuleDelete
{
config
:
c
.
config
,
hooks
:
c
.
Hooks
(),
mutation
:
mutation
}
}
// DeleteOne returns a builder for deleting the given entity.
func
(
c
*
ErrorPassthroughRuleClient
)
DeleteOne
(
_m
*
ErrorPassthroughRule
)
*
ErrorPassthroughRuleDeleteOne
{
return
c
.
DeleteOneID
(
_m
.
ID
)
}
// DeleteOneID returns a builder for deleting the given entity by its id.
func
(
c
*
ErrorPassthroughRuleClient
)
DeleteOneID
(
id
int64
)
*
ErrorPassthroughRuleDeleteOne
{
builder
:=
c
.
Delete
()
.
Where
(
errorpassthroughrule
.
ID
(
id
))
builder
.
mutation
.
id
=
&
id
builder
.
mutation
.
op
=
OpDeleteOne
return
&
ErrorPassthroughRuleDeleteOne
{
builder
}
}
// Query returns a query builder for ErrorPassthroughRule.
func
(
c
*
ErrorPassthroughRuleClient
)
Query
()
*
ErrorPassthroughRuleQuery
{
return
&
ErrorPassthroughRuleQuery
{
config
:
c
.
config
,
ctx
:
&
QueryContext
{
Type
:
TypeErrorPassthroughRule
},
inters
:
c
.
Interceptors
(),
}
}
// Get returns a ErrorPassthroughRule entity by its id.
func
(
c
*
ErrorPassthroughRuleClient
)
Get
(
ctx
context
.
Context
,
id
int64
)
(
*
ErrorPassthroughRule
,
error
)
{
return
c
.
Query
()
.
Where
(
errorpassthroughrule
.
ID
(
id
))
.
Only
(
ctx
)
}
// GetX is like Get, but panics if an error occurs.
func
(
c
*
ErrorPassthroughRuleClient
)
GetX
(
ctx
context
.
Context
,
id
int64
)
*
ErrorPassthroughRule
{
obj
,
err
:=
c
.
Get
(
ctx
,
id
)
if
err
!=
nil
{
panic
(
err
)
}
return
obj
}
// Hooks returns the client hooks.
func
(
c
*
ErrorPassthroughRuleClient
)
Hooks
()
[]
Hook
{
return
c
.
hooks
.
ErrorPassthroughRule
}
// Interceptors returns the client interceptors.
func
(
c
*
ErrorPassthroughRuleClient
)
Interceptors
()
[]
Interceptor
{
return
c
.
inters
.
ErrorPassthroughRule
}
func
(
c
*
ErrorPassthroughRuleClient
)
mutate
(
ctx
context
.
Context
,
m
*
ErrorPassthroughRuleMutation
)
(
Value
,
error
)
{
switch
m
.
Op
()
{
case
OpCreate
:
return
(
&
ErrorPassthroughRuleCreate
{
config
:
c
.
config
,
hooks
:
c
.
Hooks
(),
mutation
:
m
})
.
Save
(
ctx
)
case
OpUpdate
:
return
(
&
ErrorPassthroughRuleUpdate
{
config
:
c
.
config
,
hooks
:
c
.
Hooks
(),
mutation
:
m
})
.
Save
(
ctx
)
case
OpUpdateOne
:
return
(
&
ErrorPassthroughRuleUpdateOne
{
config
:
c
.
config
,
hooks
:
c
.
Hooks
(),
mutation
:
m
})
.
Save
(
ctx
)
case
OpDelete
,
OpDeleteOne
:
return
(
&
ErrorPassthroughRuleDelete
{
config
:
c
.
config
,
hooks
:
c
.
Hooks
(),
mutation
:
m
})
.
Exec
(
ctx
)
default
:
return
nil
,
fmt
.
Errorf
(
"ent: unknown ErrorPassthroughRule mutation op: %q"
,
m
.
Op
())
}
}
// GroupClient is a client for the Group schema.
// GroupClient is a client for the Group schema.
type
GroupClient
struct
{
type
GroupClient
struct
{
config
config
...
@@ -3462,16 +3605,16 @@ func (c *UserSubscriptionClient) mutate(ctx context.Context, m *UserSubscription
...
@@ -3462,16 +3605,16 @@ func (c *UserSubscriptionClient) mutate(ctx context.Context, m *UserSubscription
// hooks and interceptors per client, for fast access.
// hooks and interceptors per client, for fast access.
type
(
type
(
hooks
struct
{
hooks
struct
{
APIKey
,
Account
,
AccountGroup
,
Announcement
,
AnnouncementRead
,
Group
,
PromoCode
,
APIKey
,
Account
,
AccountGroup
,
Announcement
,
AnnouncementRead
,
PromoCodeUsage
,
Proxy
,
RedeemCode
,
Setting
,
UsageCleanupTask
,
UsageLog
,
User
,
ErrorPassthroughRule
,
Group
,
PromoCode
,
PromoCodeUsage
,
Proxy
,
RedeemCode
,
UserAllowedGroup
,
UserAttributeDefinition
,
UserAttributeValue
,
Setting
,
UsageCleanupTask
,
UsageLog
,
User
,
UserAllowedGroup
,
UserSubscription
[]
ent
.
Hook
UserAttributeDefinition
,
UserAttributeValue
,
UserSubscription
[]
ent
.
Hook
}
}
inters
struct
{
inters
struct
{
APIKey
,
Account
,
AccountGroup
,
Announcement
,
AnnouncementRead
,
Group
,
PromoCode
,
APIKey
,
Account
,
AccountGroup
,
Announcement
,
AnnouncementRead
,
PromoCodeUsage
,
Proxy
,
RedeemCode
,
Setting
,
UsageCleanupTask
,
UsageLog
,
User
,
ErrorPassthroughRule
,
Group
,
PromoCode
,
PromoCodeUsage
,
Proxy
,
RedeemCode
,
UserAllowedGroup
,
UserAttributeDefinition
,
UserAttributeValue
,
Setting
,
UsageCleanupTask
,
UsageLog
,
User
,
UserAllowedGroup
,
UserSubscription
[]
ent
.
Interceptor
UserAttributeDefinition
,
UserAttributeValue
,
UserSubscription
[]
ent
.
Interceptor
}
}
)
)
...
...
backend/ent/ent.go
View file @
7319122e
...
@@ -17,6 +17,7 @@ import (
...
@@ -17,6 +17,7 @@ import (
"github.com/Wei-Shaw/sub2api/ent/announcement"
"github.com/Wei-Shaw/sub2api/ent/announcement"
"github.com/Wei-Shaw/sub2api/ent/announcementread"
"github.com/Wei-Shaw/sub2api/ent/announcementread"
"github.com/Wei-Shaw/sub2api/ent/apikey"
"github.com/Wei-Shaw/sub2api/ent/apikey"
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
"github.com/Wei-Shaw/sub2api/ent/group"
"github.com/Wei-Shaw/sub2api/ent/group"
"github.com/Wei-Shaw/sub2api/ent/promocode"
"github.com/Wei-Shaw/sub2api/ent/promocode"
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
"github.com/Wei-Shaw/sub2api/ent/promocodeusage"
...
@@ -95,6 +96,7 @@ func checkColumn(t, c string) error {
...
@@ -95,6 +96,7 @@ func checkColumn(t, c string) error {
accountgroup
.
Table
:
accountgroup
.
ValidColumn
,
accountgroup
.
Table
:
accountgroup
.
ValidColumn
,
announcement
.
Table
:
announcement
.
ValidColumn
,
announcement
.
Table
:
announcement
.
ValidColumn
,
announcementread
.
Table
:
announcementread
.
ValidColumn
,
announcementread
.
Table
:
announcementread
.
ValidColumn
,
errorpassthroughrule
.
Table
:
errorpassthroughrule
.
ValidColumn
,
group
.
Table
:
group
.
ValidColumn
,
group
.
Table
:
group
.
ValidColumn
,
promocode
.
Table
:
promocode
.
ValidColumn
,
promocode
.
Table
:
promocode
.
ValidColumn
,
promocodeusage
.
Table
:
promocodeusage
.
ValidColumn
,
promocodeusage
.
Table
:
promocodeusage
.
ValidColumn
,
...
...
backend/ent/errorpassthroughrule.go
0 → 100644
View file @
7319122e
// Code generated by ent, DO NOT EDIT.
package
ent
import
(
"encoding/json"
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
)
// ErrorPassthroughRule is the model entity for the ErrorPassthroughRule schema.
type
ErrorPassthroughRule
struct
{
config
`json:"-"`
// ID of the ent.
ID
int64
`json:"id,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt
time
.
Time
`json:"created_at,omitempty"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt
time
.
Time
`json:"updated_at,omitempty"`
// Name holds the value of the "name" field.
Name
string
`json:"name,omitempty"`
// Enabled holds the value of the "enabled" field.
Enabled
bool
`json:"enabled,omitempty"`
// Priority holds the value of the "priority" field.
Priority
int
`json:"priority,omitempty"`
// ErrorCodes holds the value of the "error_codes" field.
ErrorCodes
[]
int
`json:"error_codes,omitempty"`
// Keywords holds the value of the "keywords" field.
Keywords
[]
string
`json:"keywords,omitempty"`
// MatchMode holds the value of the "match_mode" field.
MatchMode
string
`json:"match_mode,omitempty"`
// Platforms holds the value of the "platforms" field.
Platforms
[]
string
`json:"platforms,omitempty"`
// PassthroughCode holds the value of the "passthrough_code" field.
PassthroughCode
bool
`json:"passthrough_code,omitempty"`
// ResponseCode holds the value of the "response_code" field.
ResponseCode
*
int
`json:"response_code,omitempty"`
// PassthroughBody holds the value of the "passthrough_body" field.
PassthroughBody
bool
`json:"passthrough_body,omitempty"`
// CustomMessage holds the value of the "custom_message" field.
CustomMessage
*
string
`json:"custom_message,omitempty"`
// Description holds the value of the "description" field.
Description
*
string
`json:"description,omitempty"`
selectValues
sql
.
SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func
(
*
ErrorPassthroughRule
)
scanValues
(
columns
[]
string
)
([]
any
,
error
)
{
values
:=
make
([]
any
,
len
(
columns
))
for
i
:=
range
columns
{
switch
columns
[
i
]
{
case
errorpassthroughrule
.
FieldErrorCodes
,
errorpassthroughrule
.
FieldKeywords
,
errorpassthroughrule
.
FieldPlatforms
:
values
[
i
]
=
new
([]
byte
)
case
errorpassthroughrule
.
FieldEnabled
,
errorpassthroughrule
.
FieldPassthroughCode
,
errorpassthroughrule
.
FieldPassthroughBody
:
values
[
i
]
=
new
(
sql
.
NullBool
)
case
errorpassthroughrule
.
FieldID
,
errorpassthroughrule
.
FieldPriority
,
errorpassthroughrule
.
FieldResponseCode
:
values
[
i
]
=
new
(
sql
.
NullInt64
)
case
errorpassthroughrule
.
FieldName
,
errorpassthroughrule
.
FieldMatchMode
,
errorpassthroughrule
.
FieldCustomMessage
,
errorpassthroughrule
.
FieldDescription
:
values
[
i
]
=
new
(
sql
.
NullString
)
case
errorpassthroughrule
.
FieldCreatedAt
,
errorpassthroughrule
.
FieldUpdatedAt
:
values
[
i
]
=
new
(
sql
.
NullTime
)
default
:
values
[
i
]
=
new
(
sql
.
UnknownType
)
}
}
return
values
,
nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ErrorPassthroughRule fields.
func
(
_m
*
ErrorPassthroughRule
)
assignValues
(
columns
[]
string
,
values
[]
any
)
error
{
if
m
,
n
:=
len
(
values
),
len
(
columns
);
m
<
n
{
return
fmt
.
Errorf
(
"mismatch number of scan values: %d != %d"
,
m
,
n
)
}
for
i
:=
range
columns
{
switch
columns
[
i
]
{
case
errorpassthroughrule
.
FieldID
:
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullInt64
)
if
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field id"
,
value
)
}
_m
.
ID
=
int64
(
value
.
Int64
)
case
errorpassthroughrule
.
FieldCreatedAt
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullTime
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field created_at"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
CreatedAt
=
value
.
Time
}
case
errorpassthroughrule
.
FieldUpdatedAt
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullTime
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field updated_at"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
UpdatedAt
=
value
.
Time
}
case
errorpassthroughrule
.
FieldName
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field name"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
Name
=
value
.
String
}
case
errorpassthroughrule
.
FieldEnabled
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullBool
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field enabled"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
Enabled
=
value
.
Bool
}
case
errorpassthroughrule
.
FieldPriority
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullInt64
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field priority"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
Priority
=
int
(
value
.
Int64
)
}
case
errorpassthroughrule
.
FieldErrorCodes
:
if
value
,
ok
:=
values
[
i
]
.
(
*
[]
byte
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field error_codes"
,
values
[
i
])
}
else
if
value
!=
nil
&&
len
(
*
value
)
>
0
{
if
err
:=
json
.
Unmarshal
(
*
value
,
&
_m
.
ErrorCodes
);
err
!=
nil
{
return
fmt
.
Errorf
(
"unmarshal field error_codes: %w"
,
err
)
}
}
case
errorpassthroughrule
.
FieldKeywords
:
if
value
,
ok
:=
values
[
i
]
.
(
*
[]
byte
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field keywords"
,
values
[
i
])
}
else
if
value
!=
nil
&&
len
(
*
value
)
>
0
{
if
err
:=
json
.
Unmarshal
(
*
value
,
&
_m
.
Keywords
);
err
!=
nil
{
return
fmt
.
Errorf
(
"unmarshal field keywords: %w"
,
err
)
}
}
case
errorpassthroughrule
.
FieldMatchMode
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field match_mode"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
MatchMode
=
value
.
String
}
case
errorpassthroughrule
.
FieldPlatforms
:
if
value
,
ok
:=
values
[
i
]
.
(
*
[]
byte
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field platforms"
,
values
[
i
])
}
else
if
value
!=
nil
&&
len
(
*
value
)
>
0
{
if
err
:=
json
.
Unmarshal
(
*
value
,
&
_m
.
Platforms
);
err
!=
nil
{
return
fmt
.
Errorf
(
"unmarshal field platforms: %w"
,
err
)
}
}
case
errorpassthroughrule
.
FieldPassthroughCode
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullBool
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field passthrough_code"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
PassthroughCode
=
value
.
Bool
}
case
errorpassthroughrule
.
FieldResponseCode
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullInt64
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field response_code"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
ResponseCode
=
new
(
int
)
*
_m
.
ResponseCode
=
int
(
value
.
Int64
)
}
case
errorpassthroughrule
.
FieldPassthroughBody
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullBool
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field passthrough_body"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
PassthroughBody
=
value
.
Bool
}
case
errorpassthroughrule
.
FieldCustomMessage
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field custom_message"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
CustomMessage
=
new
(
string
)
*
_m
.
CustomMessage
=
value
.
String
}
case
errorpassthroughrule
.
FieldDescription
:
if
value
,
ok
:=
values
[
i
]
.
(
*
sql
.
NullString
);
!
ok
{
return
fmt
.
Errorf
(
"unexpected type %T for field description"
,
values
[
i
])
}
else
if
value
.
Valid
{
_m
.
Description
=
new
(
string
)
*
_m
.
Description
=
value
.
String
}
default
:
_m
.
selectValues
.
Set
(
columns
[
i
],
values
[
i
])
}
}
return
nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ErrorPassthroughRule.
// This includes values selected through modifiers, order, etc.
func
(
_m
*
ErrorPassthroughRule
)
Value
(
name
string
)
(
ent
.
Value
,
error
)
{
return
_m
.
selectValues
.
Get
(
name
)
}
// Update returns a builder for updating this ErrorPassthroughRule.
// Note that you need to call ErrorPassthroughRule.Unwrap() before calling this method if this ErrorPassthroughRule
// was returned from a transaction, and the transaction was committed or rolled back.
func
(
_m
*
ErrorPassthroughRule
)
Update
()
*
ErrorPassthroughRuleUpdateOne
{
return
NewErrorPassthroughRuleClient
(
_m
.
config
)
.
UpdateOne
(
_m
)
}
// Unwrap unwraps the ErrorPassthroughRule 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.
func
(
_m
*
ErrorPassthroughRule
)
Unwrap
()
*
ErrorPassthroughRule
{
_tx
,
ok
:=
_m
.
config
.
driver
.
(
*
txDriver
)
if
!
ok
{
panic
(
"ent: ErrorPassthroughRule is not a transactional entity"
)
}
_m
.
config
.
driver
=
_tx
.
drv
return
_m
}
// String implements the fmt.Stringer.
func
(
_m
*
ErrorPassthroughRule
)
String
()
string
{
var
builder
strings
.
Builder
builder
.
WriteString
(
"ErrorPassthroughRule("
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"id=%v, "
,
_m
.
ID
))
builder
.
WriteString
(
"created_at="
)
builder
.
WriteString
(
_m
.
CreatedAt
.
Format
(
time
.
ANSIC
))
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"updated_at="
)
builder
.
WriteString
(
_m
.
UpdatedAt
.
Format
(
time
.
ANSIC
))
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"name="
)
builder
.
WriteString
(
_m
.
Name
)
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"enabled="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
Enabled
))
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"priority="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
Priority
))
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"error_codes="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
ErrorCodes
))
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"keywords="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
Keywords
))
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"match_mode="
)
builder
.
WriteString
(
_m
.
MatchMode
)
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"platforms="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
Platforms
))
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"passthrough_code="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
PassthroughCode
))
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
ResponseCode
;
v
!=
nil
{
builder
.
WriteString
(
"response_code="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
*
v
))
}
builder
.
WriteString
(
", "
)
builder
.
WriteString
(
"passthrough_body="
)
builder
.
WriteString
(
fmt
.
Sprintf
(
"%v"
,
_m
.
PassthroughBody
))
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
CustomMessage
;
v
!=
nil
{
builder
.
WriteString
(
"custom_message="
)
builder
.
WriteString
(
*
v
)
}
builder
.
WriteString
(
", "
)
if
v
:=
_m
.
Description
;
v
!=
nil
{
builder
.
WriteString
(
"description="
)
builder
.
WriteString
(
*
v
)
}
builder
.
WriteByte
(
')'
)
return
builder
.
String
()
}
// ErrorPassthroughRules is a parsable slice of ErrorPassthroughRule.
type
ErrorPassthroughRules
[]
*
ErrorPassthroughRule
backend/ent/errorpassthroughrule/errorpassthroughrule.go
0 → 100644
View file @
7319122e
// Code generated by ent, DO NOT EDIT.
package
errorpassthroughrule
import
(
"time"
"entgo.io/ent/dialect/sql"
)
const
(
// Label holds the string label denoting the errorpassthroughrule type in the database.
Label
=
"error_passthrough_rule"
// FieldID holds the string denoting the id field in the database.
FieldID
=
"id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt
=
"created_at"
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
FieldUpdatedAt
=
"updated_at"
// FieldName holds the string denoting the name field in the database.
FieldName
=
"name"
// FieldEnabled holds the string denoting the enabled field in the database.
FieldEnabled
=
"enabled"
// FieldPriority holds the string denoting the priority field in the database.
FieldPriority
=
"priority"
// FieldErrorCodes holds the string denoting the error_codes field in the database.
FieldErrorCodes
=
"error_codes"
// FieldKeywords holds the string denoting the keywords field in the database.
FieldKeywords
=
"keywords"
// FieldMatchMode holds the string denoting the match_mode field in the database.
FieldMatchMode
=
"match_mode"
// FieldPlatforms holds the string denoting the platforms field in the database.
FieldPlatforms
=
"platforms"
// FieldPassthroughCode holds the string denoting the passthrough_code field in the database.
FieldPassthroughCode
=
"passthrough_code"
// FieldResponseCode holds the string denoting the response_code field in the database.
FieldResponseCode
=
"response_code"
// FieldPassthroughBody holds the string denoting the passthrough_body field in the database.
FieldPassthroughBody
=
"passthrough_body"
// FieldCustomMessage holds the string denoting the custom_message field in the database.
FieldCustomMessage
=
"custom_message"
// FieldDescription holds the string denoting the description field in the database.
FieldDescription
=
"description"
// Table holds the table name of the errorpassthroughrule in the database.
Table
=
"error_passthrough_rules"
)
// Columns holds all SQL columns for errorpassthroughrule fields.
var
Columns
=
[]
string
{
FieldID
,
FieldCreatedAt
,
FieldUpdatedAt
,
FieldName
,
FieldEnabled
,
FieldPriority
,
FieldErrorCodes
,
FieldKeywords
,
FieldMatchMode
,
FieldPlatforms
,
FieldPassthroughCode
,
FieldResponseCode
,
FieldPassthroughBody
,
FieldCustomMessage
,
FieldDescription
,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func
ValidColumn
(
column
string
)
bool
{
for
i
:=
range
Columns
{
if
column
==
Columns
[
i
]
{
return
true
}
}
return
false
}
var
(
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt
func
()
time
.
Time
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
DefaultUpdatedAt
func
()
time
.
Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt
func
()
time
.
Time
// NameValidator is a validator for the "name" field. It is called by the builders before save.
NameValidator
func
(
string
)
error
// DefaultEnabled holds the default value on creation for the "enabled" field.
DefaultEnabled
bool
// DefaultPriority holds the default value on creation for the "priority" field.
DefaultPriority
int
// DefaultMatchMode holds the default value on creation for the "match_mode" field.
DefaultMatchMode
string
// MatchModeValidator is a validator for the "match_mode" field. It is called by the builders before save.
MatchModeValidator
func
(
string
)
error
// DefaultPassthroughCode holds the default value on creation for the "passthrough_code" field.
DefaultPassthroughCode
bool
// DefaultPassthroughBody holds the default value on creation for the "passthrough_body" field.
DefaultPassthroughBody
bool
)
// OrderOption defines the ordering options for the ErrorPassthroughRule queries.
type
OrderOption
func
(
*
sql
.
Selector
)
// ByID orders the results by the id field.
func
ByID
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldID
,
opts
...
)
.
ToFunc
()
}
// ByCreatedAt orders the results by the created_at field.
func
ByCreatedAt
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldCreatedAt
,
opts
...
)
.
ToFunc
()
}
// ByUpdatedAt orders the results by the updated_at field.
func
ByUpdatedAt
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldUpdatedAt
,
opts
...
)
.
ToFunc
()
}
// ByName orders the results by the name field.
func
ByName
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldName
,
opts
...
)
.
ToFunc
()
}
// ByEnabled orders the results by the enabled field.
func
ByEnabled
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldEnabled
,
opts
...
)
.
ToFunc
()
}
// ByPriority orders the results by the priority field.
func
ByPriority
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldPriority
,
opts
...
)
.
ToFunc
()
}
// ByMatchMode orders the results by the match_mode field.
func
ByMatchMode
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldMatchMode
,
opts
...
)
.
ToFunc
()
}
// ByPassthroughCode orders the results by the passthrough_code field.
func
ByPassthroughCode
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldPassthroughCode
,
opts
...
)
.
ToFunc
()
}
// ByResponseCode orders the results by the response_code field.
func
ByResponseCode
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldResponseCode
,
opts
...
)
.
ToFunc
()
}
// ByPassthroughBody orders the results by the passthrough_body field.
func
ByPassthroughBody
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldPassthroughBody
,
opts
...
)
.
ToFunc
()
}
// ByCustomMessage orders the results by the custom_message field.
func
ByCustomMessage
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldCustomMessage
,
opts
...
)
.
ToFunc
()
}
// ByDescription orders the results by the description field.
func
ByDescription
(
opts
...
sql
.
OrderTermOption
)
OrderOption
{
return
sql
.
OrderByField
(
FieldDescription
,
opts
...
)
.
ToFunc
()
}
backend/ent/errorpassthroughrule/where.go
0 → 100644
View file @
7319122e
// Code generated by ent, DO NOT EDIT.
package
errorpassthroughrule
import
(
"time"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// ID filters vertices based on their ID field.
func
ID
(
id
int64
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldID
,
id
))
}
// IDEQ applies the EQ predicate on the ID field.
func
IDEQ
(
id
int64
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldID
,
id
))
}
// IDNEQ applies the NEQ predicate on the ID field.
func
IDNEQ
(
id
int64
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNEQ
(
FieldID
,
id
))
}
// IDIn applies the In predicate on the ID field.
func
IDIn
(
ids
...
int64
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldIn
(
FieldID
,
ids
...
))
}
// IDNotIn applies the NotIn predicate on the ID field.
func
IDNotIn
(
ids
...
int64
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNotIn
(
FieldID
,
ids
...
))
}
// IDGT applies the GT predicate on the ID field.
func
IDGT
(
id
int64
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldGT
(
FieldID
,
id
))
}
// IDGTE applies the GTE predicate on the ID field.
func
IDGTE
(
id
int64
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldGTE
(
FieldID
,
id
))
}
// IDLT applies the LT predicate on the ID field.
func
IDLT
(
id
int64
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldLT
(
FieldID
,
id
))
}
// IDLTE applies the LTE predicate on the ID field.
func
IDLTE
(
id
int64
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldLTE
(
FieldID
,
id
))
}
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
func
CreatedAt
(
v
time
.
Time
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldCreatedAt
,
v
))
}
// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
func
UpdatedAt
(
v
time
.
Time
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldUpdatedAt
,
v
))
}
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
func
Name
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldName
,
v
))
}
// Enabled applies equality check predicate on the "enabled" field. It's identical to EnabledEQ.
func
Enabled
(
v
bool
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldEnabled
,
v
))
}
// Priority applies equality check predicate on the "priority" field. It's identical to PriorityEQ.
func
Priority
(
v
int
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldPriority
,
v
))
}
// MatchMode applies equality check predicate on the "match_mode" field. It's identical to MatchModeEQ.
func
MatchMode
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldMatchMode
,
v
))
}
// PassthroughCode applies equality check predicate on the "passthrough_code" field. It's identical to PassthroughCodeEQ.
func
PassthroughCode
(
v
bool
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldPassthroughCode
,
v
))
}
// ResponseCode applies equality check predicate on the "response_code" field. It's identical to ResponseCodeEQ.
func
ResponseCode
(
v
int
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldResponseCode
,
v
))
}
// PassthroughBody applies equality check predicate on the "passthrough_body" field. It's identical to PassthroughBodyEQ.
func
PassthroughBody
(
v
bool
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldPassthroughBody
,
v
))
}
// CustomMessage applies equality check predicate on the "custom_message" field. It's identical to CustomMessageEQ.
func
CustomMessage
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldCustomMessage
,
v
))
}
// Description applies equality check predicate on the "description" field. It's identical to DescriptionEQ.
func
Description
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldDescription
,
v
))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
func
CreatedAtEQ
(
v
time
.
Time
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldCreatedAt
,
v
))
}
// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
func
CreatedAtNEQ
(
v
time
.
Time
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNEQ
(
FieldCreatedAt
,
v
))
}
// CreatedAtIn applies the In predicate on the "created_at" field.
func
CreatedAtIn
(
vs
...
time
.
Time
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldIn
(
FieldCreatedAt
,
vs
...
))
}
// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
func
CreatedAtNotIn
(
vs
...
time
.
Time
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNotIn
(
FieldCreatedAt
,
vs
...
))
}
// CreatedAtGT applies the GT predicate on the "created_at" field.
func
CreatedAtGT
(
v
time
.
Time
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldGT
(
FieldCreatedAt
,
v
))
}
// CreatedAtGTE applies the GTE predicate on the "created_at" field.
func
CreatedAtGTE
(
v
time
.
Time
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldGTE
(
FieldCreatedAt
,
v
))
}
// CreatedAtLT applies the LT predicate on the "created_at" field.
func
CreatedAtLT
(
v
time
.
Time
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldLT
(
FieldCreatedAt
,
v
))
}
// CreatedAtLTE applies the LTE predicate on the "created_at" field.
func
CreatedAtLTE
(
v
time
.
Time
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldLTE
(
FieldCreatedAt
,
v
))
}
// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
func
UpdatedAtEQ
(
v
time
.
Time
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldUpdatedAt
,
v
))
}
// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
func
UpdatedAtNEQ
(
v
time
.
Time
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNEQ
(
FieldUpdatedAt
,
v
))
}
// UpdatedAtIn applies the In predicate on the "updated_at" field.
func
UpdatedAtIn
(
vs
...
time
.
Time
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldIn
(
FieldUpdatedAt
,
vs
...
))
}
// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
func
UpdatedAtNotIn
(
vs
...
time
.
Time
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNotIn
(
FieldUpdatedAt
,
vs
...
))
}
// UpdatedAtGT applies the GT predicate on the "updated_at" field.
func
UpdatedAtGT
(
v
time
.
Time
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldGT
(
FieldUpdatedAt
,
v
))
}
// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
func
UpdatedAtGTE
(
v
time
.
Time
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldGTE
(
FieldUpdatedAt
,
v
))
}
// UpdatedAtLT applies the LT predicate on the "updated_at" field.
func
UpdatedAtLT
(
v
time
.
Time
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldLT
(
FieldUpdatedAt
,
v
))
}
// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
func
UpdatedAtLTE
(
v
time
.
Time
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldLTE
(
FieldUpdatedAt
,
v
))
}
// NameEQ applies the EQ predicate on the "name" field.
func
NameEQ
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldName
,
v
))
}
// NameNEQ applies the NEQ predicate on the "name" field.
func
NameNEQ
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNEQ
(
FieldName
,
v
))
}
// NameIn applies the In predicate on the "name" field.
func
NameIn
(
vs
...
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldIn
(
FieldName
,
vs
...
))
}
// NameNotIn applies the NotIn predicate on the "name" field.
func
NameNotIn
(
vs
...
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNotIn
(
FieldName
,
vs
...
))
}
// NameGT applies the GT predicate on the "name" field.
func
NameGT
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldGT
(
FieldName
,
v
))
}
// NameGTE applies the GTE predicate on the "name" field.
func
NameGTE
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldGTE
(
FieldName
,
v
))
}
// NameLT applies the LT predicate on the "name" field.
func
NameLT
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldLT
(
FieldName
,
v
))
}
// NameLTE applies the LTE predicate on the "name" field.
func
NameLTE
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldLTE
(
FieldName
,
v
))
}
// NameContains applies the Contains predicate on the "name" field.
func
NameContains
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldContains
(
FieldName
,
v
))
}
// NameHasPrefix applies the HasPrefix predicate on the "name" field.
func
NameHasPrefix
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldHasPrefix
(
FieldName
,
v
))
}
// NameHasSuffix applies the HasSuffix predicate on the "name" field.
func
NameHasSuffix
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldHasSuffix
(
FieldName
,
v
))
}
// NameEqualFold applies the EqualFold predicate on the "name" field.
func
NameEqualFold
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEqualFold
(
FieldName
,
v
))
}
// NameContainsFold applies the ContainsFold predicate on the "name" field.
func
NameContainsFold
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldContainsFold
(
FieldName
,
v
))
}
// EnabledEQ applies the EQ predicate on the "enabled" field.
func
EnabledEQ
(
v
bool
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldEnabled
,
v
))
}
// EnabledNEQ applies the NEQ predicate on the "enabled" field.
func
EnabledNEQ
(
v
bool
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNEQ
(
FieldEnabled
,
v
))
}
// PriorityEQ applies the EQ predicate on the "priority" field.
func
PriorityEQ
(
v
int
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldPriority
,
v
))
}
// PriorityNEQ applies the NEQ predicate on the "priority" field.
func
PriorityNEQ
(
v
int
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNEQ
(
FieldPriority
,
v
))
}
// PriorityIn applies the In predicate on the "priority" field.
func
PriorityIn
(
vs
...
int
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldIn
(
FieldPriority
,
vs
...
))
}
// PriorityNotIn applies the NotIn predicate on the "priority" field.
func
PriorityNotIn
(
vs
...
int
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNotIn
(
FieldPriority
,
vs
...
))
}
// PriorityGT applies the GT predicate on the "priority" field.
func
PriorityGT
(
v
int
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldGT
(
FieldPriority
,
v
))
}
// PriorityGTE applies the GTE predicate on the "priority" field.
func
PriorityGTE
(
v
int
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldGTE
(
FieldPriority
,
v
))
}
// PriorityLT applies the LT predicate on the "priority" field.
func
PriorityLT
(
v
int
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldLT
(
FieldPriority
,
v
))
}
// PriorityLTE applies the LTE predicate on the "priority" field.
func
PriorityLTE
(
v
int
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldLTE
(
FieldPriority
,
v
))
}
// ErrorCodesIsNil applies the IsNil predicate on the "error_codes" field.
func
ErrorCodesIsNil
()
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldIsNull
(
FieldErrorCodes
))
}
// ErrorCodesNotNil applies the NotNil predicate on the "error_codes" field.
func
ErrorCodesNotNil
()
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNotNull
(
FieldErrorCodes
))
}
// KeywordsIsNil applies the IsNil predicate on the "keywords" field.
func
KeywordsIsNil
()
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldIsNull
(
FieldKeywords
))
}
// KeywordsNotNil applies the NotNil predicate on the "keywords" field.
func
KeywordsNotNil
()
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNotNull
(
FieldKeywords
))
}
// MatchModeEQ applies the EQ predicate on the "match_mode" field.
func
MatchModeEQ
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldMatchMode
,
v
))
}
// MatchModeNEQ applies the NEQ predicate on the "match_mode" field.
func
MatchModeNEQ
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNEQ
(
FieldMatchMode
,
v
))
}
// MatchModeIn applies the In predicate on the "match_mode" field.
func
MatchModeIn
(
vs
...
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldIn
(
FieldMatchMode
,
vs
...
))
}
// MatchModeNotIn applies the NotIn predicate on the "match_mode" field.
func
MatchModeNotIn
(
vs
...
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNotIn
(
FieldMatchMode
,
vs
...
))
}
// MatchModeGT applies the GT predicate on the "match_mode" field.
func
MatchModeGT
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldGT
(
FieldMatchMode
,
v
))
}
// MatchModeGTE applies the GTE predicate on the "match_mode" field.
func
MatchModeGTE
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldGTE
(
FieldMatchMode
,
v
))
}
// MatchModeLT applies the LT predicate on the "match_mode" field.
func
MatchModeLT
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldLT
(
FieldMatchMode
,
v
))
}
// MatchModeLTE applies the LTE predicate on the "match_mode" field.
func
MatchModeLTE
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldLTE
(
FieldMatchMode
,
v
))
}
// MatchModeContains applies the Contains predicate on the "match_mode" field.
func
MatchModeContains
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldContains
(
FieldMatchMode
,
v
))
}
// MatchModeHasPrefix applies the HasPrefix predicate on the "match_mode" field.
func
MatchModeHasPrefix
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldHasPrefix
(
FieldMatchMode
,
v
))
}
// MatchModeHasSuffix applies the HasSuffix predicate on the "match_mode" field.
func
MatchModeHasSuffix
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldHasSuffix
(
FieldMatchMode
,
v
))
}
// MatchModeEqualFold applies the EqualFold predicate on the "match_mode" field.
func
MatchModeEqualFold
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEqualFold
(
FieldMatchMode
,
v
))
}
// MatchModeContainsFold applies the ContainsFold predicate on the "match_mode" field.
func
MatchModeContainsFold
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldContainsFold
(
FieldMatchMode
,
v
))
}
// PlatformsIsNil applies the IsNil predicate on the "platforms" field.
func
PlatformsIsNil
()
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldIsNull
(
FieldPlatforms
))
}
// PlatformsNotNil applies the NotNil predicate on the "platforms" field.
func
PlatformsNotNil
()
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNotNull
(
FieldPlatforms
))
}
// PassthroughCodeEQ applies the EQ predicate on the "passthrough_code" field.
func
PassthroughCodeEQ
(
v
bool
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldPassthroughCode
,
v
))
}
// PassthroughCodeNEQ applies the NEQ predicate on the "passthrough_code" field.
func
PassthroughCodeNEQ
(
v
bool
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNEQ
(
FieldPassthroughCode
,
v
))
}
// ResponseCodeEQ applies the EQ predicate on the "response_code" field.
func
ResponseCodeEQ
(
v
int
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldResponseCode
,
v
))
}
// ResponseCodeNEQ applies the NEQ predicate on the "response_code" field.
func
ResponseCodeNEQ
(
v
int
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNEQ
(
FieldResponseCode
,
v
))
}
// ResponseCodeIn applies the In predicate on the "response_code" field.
func
ResponseCodeIn
(
vs
...
int
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldIn
(
FieldResponseCode
,
vs
...
))
}
// ResponseCodeNotIn applies the NotIn predicate on the "response_code" field.
func
ResponseCodeNotIn
(
vs
...
int
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNotIn
(
FieldResponseCode
,
vs
...
))
}
// ResponseCodeGT applies the GT predicate on the "response_code" field.
func
ResponseCodeGT
(
v
int
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldGT
(
FieldResponseCode
,
v
))
}
// ResponseCodeGTE applies the GTE predicate on the "response_code" field.
func
ResponseCodeGTE
(
v
int
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldGTE
(
FieldResponseCode
,
v
))
}
// ResponseCodeLT applies the LT predicate on the "response_code" field.
func
ResponseCodeLT
(
v
int
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldLT
(
FieldResponseCode
,
v
))
}
// ResponseCodeLTE applies the LTE predicate on the "response_code" field.
func
ResponseCodeLTE
(
v
int
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldLTE
(
FieldResponseCode
,
v
))
}
// ResponseCodeIsNil applies the IsNil predicate on the "response_code" field.
func
ResponseCodeIsNil
()
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldIsNull
(
FieldResponseCode
))
}
// ResponseCodeNotNil applies the NotNil predicate on the "response_code" field.
func
ResponseCodeNotNil
()
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNotNull
(
FieldResponseCode
))
}
// PassthroughBodyEQ applies the EQ predicate on the "passthrough_body" field.
func
PassthroughBodyEQ
(
v
bool
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldPassthroughBody
,
v
))
}
// PassthroughBodyNEQ applies the NEQ predicate on the "passthrough_body" field.
func
PassthroughBodyNEQ
(
v
bool
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNEQ
(
FieldPassthroughBody
,
v
))
}
// CustomMessageEQ applies the EQ predicate on the "custom_message" field.
func
CustomMessageEQ
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldCustomMessage
,
v
))
}
// CustomMessageNEQ applies the NEQ predicate on the "custom_message" field.
func
CustomMessageNEQ
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNEQ
(
FieldCustomMessage
,
v
))
}
// CustomMessageIn applies the In predicate on the "custom_message" field.
func
CustomMessageIn
(
vs
...
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldIn
(
FieldCustomMessage
,
vs
...
))
}
// CustomMessageNotIn applies the NotIn predicate on the "custom_message" field.
func
CustomMessageNotIn
(
vs
...
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNotIn
(
FieldCustomMessage
,
vs
...
))
}
// CustomMessageGT applies the GT predicate on the "custom_message" field.
func
CustomMessageGT
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldGT
(
FieldCustomMessage
,
v
))
}
// CustomMessageGTE applies the GTE predicate on the "custom_message" field.
func
CustomMessageGTE
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldGTE
(
FieldCustomMessage
,
v
))
}
// CustomMessageLT applies the LT predicate on the "custom_message" field.
func
CustomMessageLT
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldLT
(
FieldCustomMessage
,
v
))
}
// CustomMessageLTE applies the LTE predicate on the "custom_message" field.
func
CustomMessageLTE
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldLTE
(
FieldCustomMessage
,
v
))
}
// CustomMessageContains applies the Contains predicate on the "custom_message" field.
func
CustomMessageContains
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldContains
(
FieldCustomMessage
,
v
))
}
// CustomMessageHasPrefix applies the HasPrefix predicate on the "custom_message" field.
func
CustomMessageHasPrefix
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldHasPrefix
(
FieldCustomMessage
,
v
))
}
// CustomMessageHasSuffix applies the HasSuffix predicate on the "custom_message" field.
func
CustomMessageHasSuffix
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldHasSuffix
(
FieldCustomMessage
,
v
))
}
// CustomMessageIsNil applies the IsNil predicate on the "custom_message" field.
func
CustomMessageIsNil
()
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldIsNull
(
FieldCustomMessage
))
}
// CustomMessageNotNil applies the NotNil predicate on the "custom_message" field.
func
CustomMessageNotNil
()
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNotNull
(
FieldCustomMessage
))
}
// CustomMessageEqualFold applies the EqualFold predicate on the "custom_message" field.
func
CustomMessageEqualFold
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEqualFold
(
FieldCustomMessage
,
v
))
}
// CustomMessageContainsFold applies the ContainsFold predicate on the "custom_message" field.
func
CustomMessageContainsFold
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldContainsFold
(
FieldCustomMessage
,
v
))
}
// DescriptionEQ applies the EQ predicate on the "description" field.
func
DescriptionEQ
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEQ
(
FieldDescription
,
v
))
}
// DescriptionNEQ applies the NEQ predicate on the "description" field.
func
DescriptionNEQ
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNEQ
(
FieldDescription
,
v
))
}
// DescriptionIn applies the In predicate on the "description" field.
func
DescriptionIn
(
vs
...
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldIn
(
FieldDescription
,
vs
...
))
}
// DescriptionNotIn applies the NotIn predicate on the "description" field.
func
DescriptionNotIn
(
vs
...
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNotIn
(
FieldDescription
,
vs
...
))
}
// DescriptionGT applies the GT predicate on the "description" field.
func
DescriptionGT
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldGT
(
FieldDescription
,
v
))
}
// DescriptionGTE applies the GTE predicate on the "description" field.
func
DescriptionGTE
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldGTE
(
FieldDescription
,
v
))
}
// DescriptionLT applies the LT predicate on the "description" field.
func
DescriptionLT
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldLT
(
FieldDescription
,
v
))
}
// DescriptionLTE applies the LTE predicate on the "description" field.
func
DescriptionLTE
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldLTE
(
FieldDescription
,
v
))
}
// DescriptionContains applies the Contains predicate on the "description" field.
func
DescriptionContains
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldContains
(
FieldDescription
,
v
))
}
// DescriptionHasPrefix applies the HasPrefix predicate on the "description" field.
func
DescriptionHasPrefix
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldHasPrefix
(
FieldDescription
,
v
))
}
// DescriptionHasSuffix applies the HasSuffix predicate on the "description" field.
func
DescriptionHasSuffix
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldHasSuffix
(
FieldDescription
,
v
))
}
// DescriptionIsNil applies the IsNil predicate on the "description" field.
func
DescriptionIsNil
()
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldIsNull
(
FieldDescription
))
}
// DescriptionNotNil applies the NotNil predicate on the "description" field.
func
DescriptionNotNil
()
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldNotNull
(
FieldDescription
))
}
// DescriptionEqualFold applies the EqualFold predicate on the "description" field.
func
DescriptionEqualFold
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldEqualFold
(
FieldDescription
,
v
))
}
// DescriptionContainsFold applies the ContainsFold predicate on the "description" field.
func
DescriptionContainsFold
(
v
string
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
FieldContainsFold
(
FieldDescription
,
v
))
}
// And groups predicates with the AND operator between them.
func
And
(
predicates
...
predicate
.
ErrorPassthroughRule
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
AndPredicates
(
predicates
...
))
}
// Or groups predicates with the OR operator between them.
func
Or
(
predicates
...
predicate
.
ErrorPassthroughRule
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
OrPredicates
(
predicates
...
))
}
// Not applies the not operator on the given predicate.
func
Not
(
p
predicate
.
ErrorPassthroughRule
)
predicate
.
ErrorPassthroughRule
{
return
predicate
.
ErrorPassthroughRule
(
sql
.
NotPredicates
(
p
))
}
backend/ent/errorpassthroughrule_create.go
0 → 100644
View file @
7319122e
// Code generated by ent, DO NOT EDIT.
package
ent
import
(
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
)
// ErrorPassthroughRuleCreate is the builder for creating a ErrorPassthroughRule entity.
type
ErrorPassthroughRuleCreate
struct
{
config
mutation
*
ErrorPassthroughRuleMutation
hooks
[]
Hook
conflict
[]
sql
.
ConflictOption
}
// SetCreatedAt sets the "created_at" field.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetCreatedAt
(
v
time
.
Time
)
*
ErrorPassthroughRuleCreate
{
_c
.
mutation
.
SetCreatedAt
(
v
)
return
_c
}
// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetNillableCreatedAt
(
v
*
time
.
Time
)
*
ErrorPassthroughRuleCreate
{
if
v
!=
nil
{
_c
.
SetCreatedAt
(
*
v
)
}
return
_c
}
// SetUpdatedAt sets the "updated_at" field.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetUpdatedAt
(
v
time
.
Time
)
*
ErrorPassthroughRuleCreate
{
_c
.
mutation
.
SetUpdatedAt
(
v
)
return
_c
}
// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetNillableUpdatedAt
(
v
*
time
.
Time
)
*
ErrorPassthroughRuleCreate
{
if
v
!=
nil
{
_c
.
SetUpdatedAt
(
*
v
)
}
return
_c
}
// SetName sets the "name" field.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetName
(
v
string
)
*
ErrorPassthroughRuleCreate
{
_c
.
mutation
.
SetName
(
v
)
return
_c
}
// SetEnabled sets the "enabled" field.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetEnabled
(
v
bool
)
*
ErrorPassthroughRuleCreate
{
_c
.
mutation
.
SetEnabled
(
v
)
return
_c
}
// SetNillableEnabled sets the "enabled" field if the given value is not nil.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetNillableEnabled
(
v
*
bool
)
*
ErrorPassthroughRuleCreate
{
if
v
!=
nil
{
_c
.
SetEnabled
(
*
v
)
}
return
_c
}
// SetPriority sets the "priority" field.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetPriority
(
v
int
)
*
ErrorPassthroughRuleCreate
{
_c
.
mutation
.
SetPriority
(
v
)
return
_c
}
// SetNillablePriority sets the "priority" field if the given value is not nil.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetNillablePriority
(
v
*
int
)
*
ErrorPassthroughRuleCreate
{
if
v
!=
nil
{
_c
.
SetPriority
(
*
v
)
}
return
_c
}
// SetErrorCodes sets the "error_codes" field.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetErrorCodes
(
v
[]
int
)
*
ErrorPassthroughRuleCreate
{
_c
.
mutation
.
SetErrorCodes
(
v
)
return
_c
}
// SetKeywords sets the "keywords" field.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetKeywords
(
v
[]
string
)
*
ErrorPassthroughRuleCreate
{
_c
.
mutation
.
SetKeywords
(
v
)
return
_c
}
// SetMatchMode sets the "match_mode" field.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetMatchMode
(
v
string
)
*
ErrorPassthroughRuleCreate
{
_c
.
mutation
.
SetMatchMode
(
v
)
return
_c
}
// SetNillableMatchMode sets the "match_mode" field if the given value is not nil.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetNillableMatchMode
(
v
*
string
)
*
ErrorPassthroughRuleCreate
{
if
v
!=
nil
{
_c
.
SetMatchMode
(
*
v
)
}
return
_c
}
// SetPlatforms sets the "platforms" field.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetPlatforms
(
v
[]
string
)
*
ErrorPassthroughRuleCreate
{
_c
.
mutation
.
SetPlatforms
(
v
)
return
_c
}
// SetPassthroughCode sets the "passthrough_code" field.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetPassthroughCode
(
v
bool
)
*
ErrorPassthroughRuleCreate
{
_c
.
mutation
.
SetPassthroughCode
(
v
)
return
_c
}
// SetNillablePassthroughCode sets the "passthrough_code" field if the given value is not nil.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetNillablePassthroughCode
(
v
*
bool
)
*
ErrorPassthroughRuleCreate
{
if
v
!=
nil
{
_c
.
SetPassthroughCode
(
*
v
)
}
return
_c
}
// SetResponseCode sets the "response_code" field.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetResponseCode
(
v
int
)
*
ErrorPassthroughRuleCreate
{
_c
.
mutation
.
SetResponseCode
(
v
)
return
_c
}
// SetNillableResponseCode sets the "response_code" field if the given value is not nil.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetNillableResponseCode
(
v
*
int
)
*
ErrorPassthroughRuleCreate
{
if
v
!=
nil
{
_c
.
SetResponseCode
(
*
v
)
}
return
_c
}
// SetPassthroughBody sets the "passthrough_body" field.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetPassthroughBody
(
v
bool
)
*
ErrorPassthroughRuleCreate
{
_c
.
mutation
.
SetPassthroughBody
(
v
)
return
_c
}
// SetNillablePassthroughBody sets the "passthrough_body" field if the given value is not nil.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetNillablePassthroughBody
(
v
*
bool
)
*
ErrorPassthroughRuleCreate
{
if
v
!=
nil
{
_c
.
SetPassthroughBody
(
*
v
)
}
return
_c
}
// SetCustomMessage sets the "custom_message" field.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetCustomMessage
(
v
string
)
*
ErrorPassthroughRuleCreate
{
_c
.
mutation
.
SetCustomMessage
(
v
)
return
_c
}
// SetNillableCustomMessage sets the "custom_message" field if the given value is not nil.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetNillableCustomMessage
(
v
*
string
)
*
ErrorPassthroughRuleCreate
{
if
v
!=
nil
{
_c
.
SetCustomMessage
(
*
v
)
}
return
_c
}
// SetDescription sets the "description" field.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetDescription
(
v
string
)
*
ErrorPassthroughRuleCreate
{
_c
.
mutation
.
SetDescription
(
v
)
return
_c
}
// SetNillableDescription sets the "description" field if the given value is not nil.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SetNillableDescription
(
v
*
string
)
*
ErrorPassthroughRuleCreate
{
if
v
!=
nil
{
_c
.
SetDescription
(
*
v
)
}
return
_c
}
// Mutation returns the ErrorPassthroughRuleMutation object of the builder.
func
(
_c
*
ErrorPassthroughRuleCreate
)
Mutation
()
*
ErrorPassthroughRuleMutation
{
return
_c
.
mutation
}
// Save creates the ErrorPassthroughRule in the database.
func
(
_c
*
ErrorPassthroughRuleCreate
)
Save
(
ctx
context
.
Context
)
(
*
ErrorPassthroughRule
,
error
)
{
_c
.
defaults
()
return
withHooks
(
ctx
,
_c
.
sqlSave
,
_c
.
mutation
,
_c
.
hooks
)
}
// SaveX calls Save and panics if Save returns an error.
func
(
_c
*
ErrorPassthroughRuleCreate
)
SaveX
(
ctx
context
.
Context
)
*
ErrorPassthroughRule
{
v
,
err
:=
_c
.
Save
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
v
}
// Exec executes the query.
func
(
_c
*
ErrorPassthroughRuleCreate
)
Exec
(
ctx
context
.
Context
)
error
{
_
,
err
:=
_c
.
Save
(
ctx
)
return
err
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_c
*
ErrorPassthroughRuleCreate
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_c
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
// defaults sets the default values of the builder before save.
func
(
_c
*
ErrorPassthroughRuleCreate
)
defaults
()
{
if
_
,
ok
:=
_c
.
mutation
.
CreatedAt
();
!
ok
{
v
:=
errorpassthroughrule
.
DefaultCreatedAt
()
_c
.
mutation
.
SetCreatedAt
(
v
)
}
if
_
,
ok
:=
_c
.
mutation
.
UpdatedAt
();
!
ok
{
v
:=
errorpassthroughrule
.
DefaultUpdatedAt
()
_c
.
mutation
.
SetUpdatedAt
(
v
)
}
if
_
,
ok
:=
_c
.
mutation
.
Enabled
();
!
ok
{
v
:=
errorpassthroughrule
.
DefaultEnabled
_c
.
mutation
.
SetEnabled
(
v
)
}
if
_
,
ok
:=
_c
.
mutation
.
Priority
();
!
ok
{
v
:=
errorpassthroughrule
.
DefaultPriority
_c
.
mutation
.
SetPriority
(
v
)
}
if
_
,
ok
:=
_c
.
mutation
.
MatchMode
();
!
ok
{
v
:=
errorpassthroughrule
.
DefaultMatchMode
_c
.
mutation
.
SetMatchMode
(
v
)
}
if
_
,
ok
:=
_c
.
mutation
.
PassthroughCode
();
!
ok
{
v
:=
errorpassthroughrule
.
DefaultPassthroughCode
_c
.
mutation
.
SetPassthroughCode
(
v
)
}
if
_
,
ok
:=
_c
.
mutation
.
PassthroughBody
();
!
ok
{
v
:=
errorpassthroughrule
.
DefaultPassthroughBody
_c
.
mutation
.
SetPassthroughBody
(
v
)
}
}
// check runs all checks and user-defined validators on the builder.
func
(
_c
*
ErrorPassthroughRuleCreate
)
check
()
error
{
if
_
,
ok
:=
_c
.
mutation
.
CreatedAt
();
!
ok
{
return
&
ValidationError
{
Name
:
"created_at"
,
err
:
errors
.
New
(
`ent: missing required field "ErrorPassthroughRule.created_at"`
)}
}
if
_
,
ok
:=
_c
.
mutation
.
UpdatedAt
();
!
ok
{
return
&
ValidationError
{
Name
:
"updated_at"
,
err
:
errors
.
New
(
`ent: missing required field "ErrorPassthroughRule.updated_at"`
)}
}
if
_
,
ok
:=
_c
.
mutation
.
Name
();
!
ok
{
return
&
ValidationError
{
Name
:
"name"
,
err
:
errors
.
New
(
`ent: missing required field "ErrorPassthroughRule.name"`
)}
}
if
v
,
ok
:=
_c
.
mutation
.
Name
();
ok
{
if
err
:=
errorpassthroughrule
.
NameValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"name"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "ErrorPassthroughRule.name": %w`
,
err
)}
}
}
if
_
,
ok
:=
_c
.
mutation
.
Enabled
();
!
ok
{
return
&
ValidationError
{
Name
:
"enabled"
,
err
:
errors
.
New
(
`ent: missing required field "ErrorPassthroughRule.enabled"`
)}
}
if
_
,
ok
:=
_c
.
mutation
.
Priority
();
!
ok
{
return
&
ValidationError
{
Name
:
"priority"
,
err
:
errors
.
New
(
`ent: missing required field "ErrorPassthroughRule.priority"`
)}
}
if
_
,
ok
:=
_c
.
mutation
.
MatchMode
();
!
ok
{
return
&
ValidationError
{
Name
:
"match_mode"
,
err
:
errors
.
New
(
`ent: missing required field "ErrorPassthroughRule.match_mode"`
)}
}
if
v
,
ok
:=
_c
.
mutation
.
MatchMode
();
ok
{
if
err
:=
errorpassthroughrule
.
MatchModeValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"match_mode"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "ErrorPassthroughRule.match_mode": %w`
,
err
)}
}
}
if
_
,
ok
:=
_c
.
mutation
.
PassthroughCode
();
!
ok
{
return
&
ValidationError
{
Name
:
"passthrough_code"
,
err
:
errors
.
New
(
`ent: missing required field "ErrorPassthroughRule.passthrough_code"`
)}
}
if
_
,
ok
:=
_c
.
mutation
.
PassthroughBody
();
!
ok
{
return
&
ValidationError
{
Name
:
"passthrough_body"
,
err
:
errors
.
New
(
`ent: missing required field "ErrorPassthroughRule.passthrough_body"`
)}
}
return
nil
}
func
(
_c
*
ErrorPassthroughRuleCreate
)
sqlSave
(
ctx
context
.
Context
)
(
*
ErrorPassthroughRule
,
error
)
{
if
err
:=
_c
.
check
();
err
!=
nil
{
return
nil
,
err
}
_node
,
_spec
:=
_c
.
createSpec
()
if
err
:=
sqlgraph
.
CreateNode
(
ctx
,
_c
.
driver
,
_spec
);
err
!=
nil
{
if
sqlgraph
.
IsConstraintError
(
err
)
{
err
=
&
ConstraintError
{
msg
:
err
.
Error
(),
wrap
:
err
}
}
return
nil
,
err
}
id
:=
_spec
.
ID
.
Value
.
(
int64
)
_node
.
ID
=
int64
(
id
)
_c
.
mutation
.
id
=
&
_node
.
ID
_c
.
mutation
.
done
=
true
return
_node
,
nil
}
func
(
_c
*
ErrorPassthroughRuleCreate
)
createSpec
()
(
*
ErrorPassthroughRule
,
*
sqlgraph
.
CreateSpec
)
{
var
(
_node
=
&
ErrorPassthroughRule
{
config
:
_c
.
config
}
_spec
=
sqlgraph
.
NewCreateSpec
(
errorpassthroughrule
.
Table
,
sqlgraph
.
NewFieldSpec
(
errorpassthroughrule
.
FieldID
,
field
.
TypeInt64
))
)
_spec
.
OnConflict
=
_c
.
conflict
if
value
,
ok
:=
_c
.
mutation
.
CreatedAt
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldCreatedAt
,
field
.
TypeTime
,
value
)
_node
.
CreatedAt
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
UpdatedAt
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldUpdatedAt
,
field
.
TypeTime
,
value
)
_node
.
UpdatedAt
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
Name
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldName
,
field
.
TypeString
,
value
)
_node
.
Name
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
Enabled
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldEnabled
,
field
.
TypeBool
,
value
)
_node
.
Enabled
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
Priority
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldPriority
,
field
.
TypeInt
,
value
)
_node
.
Priority
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
ErrorCodes
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldErrorCodes
,
field
.
TypeJSON
,
value
)
_node
.
ErrorCodes
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
Keywords
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldKeywords
,
field
.
TypeJSON
,
value
)
_node
.
Keywords
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
MatchMode
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldMatchMode
,
field
.
TypeString
,
value
)
_node
.
MatchMode
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
Platforms
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldPlatforms
,
field
.
TypeJSON
,
value
)
_node
.
Platforms
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
PassthroughCode
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldPassthroughCode
,
field
.
TypeBool
,
value
)
_node
.
PassthroughCode
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
ResponseCode
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldResponseCode
,
field
.
TypeInt
,
value
)
_node
.
ResponseCode
=
&
value
}
if
value
,
ok
:=
_c
.
mutation
.
PassthroughBody
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldPassthroughBody
,
field
.
TypeBool
,
value
)
_node
.
PassthroughBody
=
value
}
if
value
,
ok
:=
_c
.
mutation
.
CustomMessage
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldCustomMessage
,
field
.
TypeString
,
value
)
_node
.
CustomMessage
=
&
value
}
if
value
,
ok
:=
_c
.
mutation
.
Description
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldDescription
,
field
.
TypeString
,
value
)
_node
.
Description
=
&
value
}
return
_node
,
_spec
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.ErrorPassthroughRule.Create().
// SetCreatedAt(v).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
// sql.ResolveWithNewValues(),
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.ErrorPassthroughRuleUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func
(
_c
*
ErrorPassthroughRuleCreate
)
OnConflict
(
opts
...
sql
.
ConflictOption
)
*
ErrorPassthroughRuleUpsertOne
{
_c
.
conflict
=
opts
return
&
ErrorPassthroughRuleUpsertOne
{
create
:
_c
,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.ErrorPassthroughRule.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func
(
_c
*
ErrorPassthroughRuleCreate
)
OnConflictColumns
(
columns
...
string
)
*
ErrorPassthroughRuleUpsertOne
{
_c
.
conflict
=
append
(
_c
.
conflict
,
sql
.
ConflictColumns
(
columns
...
))
return
&
ErrorPassthroughRuleUpsertOne
{
create
:
_c
,
}
}
type
(
// ErrorPassthroughRuleUpsertOne is the builder for "upsert"-ing
// one ErrorPassthroughRule node.
ErrorPassthroughRuleUpsertOne
struct
{
create
*
ErrorPassthroughRuleCreate
}
// ErrorPassthroughRuleUpsert is the "OnConflict" setter.
ErrorPassthroughRuleUpsert
struct
{
*
sql
.
UpdateSet
}
)
// SetUpdatedAt sets the "updated_at" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
SetUpdatedAt
(
v
time
.
Time
)
*
ErrorPassthroughRuleUpsert
{
u
.
Set
(
errorpassthroughrule
.
FieldUpdatedAt
,
v
)
return
u
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsert
)
UpdateUpdatedAt
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetExcluded
(
errorpassthroughrule
.
FieldUpdatedAt
)
return
u
}
// SetName sets the "name" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
SetName
(
v
string
)
*
ErrorPassthroughRuleUpsert
{
u
.
Set
(
errorpassthroughrule
.
FieldName
,
v
)
return
u
}
// UpdateName sets the "name" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsert
)
UpdateName
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetExcluded
(
errorpassthroughrule
.
FieldName
)
return
u
}
// SetEnabled sets the "enabled" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
SetEnabled
(
v
bool
)
*
ErrorPassthroughRuleUpsert
{
u
.
Set
(
errorpassthroughrule
.
FieldEnabled
,
v
)
return
u
}
// UpdateEnabled sets the "enabled" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsert
)
UpdateEnabled
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetExcluded
(
errorpassthroughrule
.
FieldEnabled
)
return
u
}
// SetPriority sets the "priority" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
SetPriority
(
v
int
)
*
ErrorPassthroughRuleUpsert
{
u
.
Set
(
errorpassthroughrule
.
FieldPriority
,
v
)
return
u
}
// UpdatePriority sets the "priority" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsert
)
UpdatePriority
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetExcluded
(
errorpassthroughrule
.
FieldPriority
)
return
u
}
// AddPriority adds v to the "priority" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
AddPriority
(
v
int
)
*
ErrorPassthroughRuleUpsert
{
u
.
Add
(
errorpassthroughrule
.
FieldPriority
,
v
)
return
u
}
// SetErrorCodes sets the "error_codes" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
SetErrorCodes
(
v
[]
int
)
*
ErrorPassthroughRuleUpsert
{
u
.
Set
(
errorpassthroughrule
.
FieldErrorCodes
,
v
)
return
u
}
// UpdateErrorCodes sets the "error_codes" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsert
)
UpdateErrorCodes
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetExcluded
(
errorpassthroughrule
.
FieldErrorCodes
)
return
u
}
// ClearErrorCodes clears the value of the "error_codes" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
ClearErrorCodes
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetNull
(
errorpassthroughrule
.
FieldErrorCodes
)
return
u
}
// SetKeywords sets the "keywords" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
SetKeywords
(
v
[]
string
)
*
ErrorPassthroughRuleUpsert
{
u
.
Set
(
errorpassthroughrule
.
FieldKeywords
,
v
)
return
u
}
// UpdateKeywords sets the "keywords" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsert
)
UpdateKeywords
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetExcluded
(
errorpassthroughrule
.
FieldKeywords
)
return
u
}
// ClearKeywords clears the value of the "keywords" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
ClearKeywords
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetNull
(
errorpassthroughrule
.
FieldKeywords
)
return
u
}
// SetMatchMode sets the "match_mode" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
SetMatchMode
(
v
string
)
*
ErrorPassthroughRuleUpsert
{
u
.
Set
(
errorpassthroughrule
.
FieldMatchMode
,
v
)
return
u
}
// UpdateMatchMode sets the "match_mode" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsert
)
UpdateMatchMode
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetExcluded
(
errorpassthroughrule
.
FieldMatchMode
)
return
u
}
// SetPlatforms sets the "platforms" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
SetPlatforms
(
v
[]
string
)
*
ErrorPassthroughRuleUpsert
{
u
.
Set
(
errorpassthroughrule
.
FieldPlatforms
,
v
)
return
u
}
// UpdatePlatforms sets the "platforms" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsert
)
UpdatePlatforms
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetExcluded
(
errorpassthroughrule
.
FieldPlatforms
)
return
u
}
// ClearPlatforms clears the value of the "platforms" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
ClearPlatforms
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetNull
(
errorpassthroughrule
.
FieldPlatforms
)
return
u
}
// SetPassthroughCode sets the "passthrough_code" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
SetPassthroughCode
(
v
bool
)
*
ErrorPassthroughRuleUpsert
{
u
.
Set
(
errorpassthroughrule
.
FieldPassthroughCode
,
v
)
return
u
}
// UpdatePassthroughCode sets the "passthrough_code" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsert
)
UpdatePassthroughCode
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetExcluded
(
errorpassthroughrule
.
FieldPassthroughCode
)
return
u
}
// SetResponseCode sets the "response_code" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
SetResponseCode
(
v
int
)
*
ErrorPassthroughRuleUpsert
{
u
.
Set
(
errorpassthroughrule
.
FieldResponseCode
,
v
)
return
u
}
// UpdateResponseCode sets the "response_code" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsert
)
UpdateResponseCode
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetExcluded
(
errorpassthroughrule
.
FieldResponseCode
)
return
u
}
// AddResponseCode adds v to the "response_code" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
AddResponseCode
(
v
int
)
*
ErrorPassthroughRuleUpsert
{
u
.
Add
(
errorpassthroughrule
.
FieldResponseCode
,
v
)
return
u
}
// ClearResponseCode clears the value of the "response_code" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
ClearResponseCode
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetNull
(
errorpassthroughrule
.
FieldResponseCode
)
return
u
}
// SetPassthroughBody sets the "passthrough_body" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
SetPassthroughBody
(
v
bool
)
*
ErrorPassthroughRuleUpsert
{
u
.
Set
(
errorpassthroughrule
.
FieldPassthroughBody
,
v
)
return
u
}
// UpdatePassthroughBody sets the "passthrough_body" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsert
)
UpdatePassthroughBody
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetExcluded
(
errorpassthroughrule
.
FieldPassthroughBody
)
return
u
}
// SetCustomMessage sets the "custom_message" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
SetCustomMessage
(
v
string
)
*
ErrorPassthroughRuleUpsert
{
u
.
Set
(
errorpassthroughrule
.
FieldCustomMessage
,
v
)
return
u
}
// UpdateCustomMessage sets the "custom_message" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsert
)
UpdateCustomMessage
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetExcluded
(
errorpassthroughrule
.
FieldCustomMessage
)
return
u
}
// ClearCustomMessage clears the value of the "custom_message" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
ClearCustomMessage
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetNull
(
errorpassthroughrule
.
FieldCustomMessage
)
return
u
}
// SetDescription sets the "description" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
SetDescription
(
v
string
)
*
ErrorPassthroughRuleUpsert
{
u
.
Set
(
errorpassthroughrule
.
FieldDescription
,
v
)
return
u
}
// UpdateDescription sets the "description" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsert
)
UpdateDescription
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetExcluded
(
errorpassthroughrule
.
FieldDescription
)
return
u
}
// ClearDescription clears the value of the "description" field.
func
(
u
*
ErrorPassthroughRuleUpsert
)
ClearDescription
()
*
ErrorPassthroughRuleUpsert
{
u
.
SetNull
(
errorpassthroughrule
.
FieldDescription
)
return
u
}
// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
// client.ErrorPassthroughRule.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
UpdateNewValues
()
*
ErrorPassthroughRuleUpsertOne
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWithNewValues
())
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWith
(
func
(
s
*
sql
.
UpdateSet
)
{
if
_
,
exists
:=
u
.
create
.
mutation
.
CreatedAt
();
exists
{
s
.
SetIgnore
(
errorpassthroughrule
.
FieldCreatedAt
)
}
}))
return
u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.ErrorPassthroughRule.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
Ignore
()
*
ErrorPassthroughRuleUpsertOne
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWithIgnore
())
return
u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
DoNothing
()
*
ErrorPassthroughRuleUpsertOne
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
DoNothing
())
return
u
}
// Update allows overriding fields `UPDATE` values. See the ErrorPassthroughRuleCreate.OnConflict
// documentation for more info.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
Update
(
set
func
(
*
ErrorPassthroughRuleUpsert
))
*
ErrorPassthroughRuleUpsertOne
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWith
(
func
(
update
*
sql
.
UpdateSet
)
{
set
(
&
ErrorPassthroughRuleUpsert
{
UpdateSet
:
update
})
}))
return
u
}
// SetUpdatedAt sets the "updated_at" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
SetUpdatedAt
(
v
time
.
Time
)
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetUpdatedAt
(
v
)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
UpdateUpdatedAt
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdateUpdatedAt
()
})
}
// SetName sets the "name" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
SetName
(
v
string
)
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetName
(
v
)
})
}
// UpdateName sets the "name" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
UpdateName
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdateName
()
})
}
// SetEnabled sets the "enabled" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
SetEnabled
(
v
bool
)
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetEnabled
(
v
)
})
}
// UpdateEnabled sets the "enabled" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
UpdateEnabled
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdateEnabled
()
})
}
// SetPriority sets the "priority" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
SetPriority
(
v
int
)
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetPriority
(
v
)
})
}
// AddPriority adds v to the "priority" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
AddPriority
(
v
int
)
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
AddPriority
(
v
)
})
}
// UpdatePriority sets the "priority" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
UpdatePriority
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdatePriority
()
})
}
// SetErrorCodes sets the "error_codes" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
SetErrorCodes
(
v
[]
int
)
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetErrorCodes
(
v
)
})
}
// UpdateErrorCodes sets the "error_codes" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
UpdateErrorCodes
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdateErrorCodes
()
})
}
// ClearErrorCodes clears the value of the "error_codes" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
ClearErrorCodes
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
ClearErrorCodes
()
})
}
// SetKeywords sets the "keywords" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
SetKeywords
(
v
[]
string
)
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetKeywords
(
v
)
})
}
// UpdateKeywords sets the "keywords" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
UpdateKeywords
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdateKeywords
()
})
}
// ClearKeywords clears the value of the "keywords" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
ClearKeywords
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
ClearKeywords
()
})
}
// SetMatchMode sets the "match_mode" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
SetMatchMode
(
v
string
)
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetMatchMode
(
v
)
})
}
// UpdateMatchMode sets the "match_mode" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
UpdateMatchMode
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdateMatchMode
()
})
}
// SetPlatforms sets the "platforms" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
SetPlatforms
(
v
[]
string
)
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetPlatforms
(
v
)
})
}
// UpdatePlatforms sets the "platforms" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
UpdatePlatforms
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdatePlatforms
()
})
}
// ClearPlatforms clears the value of the "platforms" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
ClearPlatforms
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
ClearPlatforms
()
})
}
// SetPassthroughCode sets the "passthrough_code" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
SetPassthroughCode
(
v
bool
)
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetPassthroughCode
(
v
)
})
}
// UpdatePassthroughCode sets the "passthrough_code" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
UpdatePassthroughCode
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdatePassthroughCode
()
})
}
// SetResponseCode sets the "response_code" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
SetResponseCode
(
v
int
)
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetResponseCode
(
v
)
})
}
// AddResponseCode adds v to the "response_code" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
AddResponseCode
(
v
int
)
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
AddResponseCode
(
v
)
})
}
// UpdateResponseCode sets the "response_code" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
UpdateResponseCode
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdateResponseCode
()
})
}
// ClearResponseCode clears the value of the "response_code" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
ClearResponseCode
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
ClearResponseCode
()
})
}
// SetPassthroughBody sets the "passthrough_body" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
SetPassthroughBody
(
v
bool
)
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetPassthroughBody
(
v
)
})
}
// UpdatePassthroughBody sets the "passthrough_body" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
UpdatePassthroughBody
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdatePassthroughBody
()
})
}
// SetCustomMessage sets the "custom_message" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
SetCustomMessage
(
v
string
)
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetCustomMessage
(
v
)
})
}
// UpdateCustomMessage sets the "custom_message" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
UpdateCustomMessage
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdateCustomMessage
()
})
}
// ClearCustomMessage clears the value of the "custom_message" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
ClearCustomMessage
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
ClearCustomMessage
()
})
}
// SetDescription sets the "description" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
SetDescription
(
v
string
)
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetDescription
(
v
)
})
}
// UpdateDescription sets the "description" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
UpdateDescription
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdateDescription
()
})
}
// ClearDescription clears the value of the "description" field.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
ClearDescription
()
*
ErrorPassthroughRuleUpsertOne
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
ClearDescription
()
})
}
// Exec executes the query.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
Exec
(
ctx
context
.
Context
)
error
{
if
len
(
u
.
create
.
conflict
)
==
0
{
return
errors
.
New
(
"ent: missing options for ErrorPassthroughRuleCreate.OnConflict"
)
}
return
u
.
create
.
Exec
(
ctx
)
}
// ExecX is like Exec, but panics if an error occurs.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
u
.
create
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
// Exec executes the UPSERT query and returns the inserted/updated ID.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
ID
(
ctx
context
.
Context
)
(
id
int64
,
err
error
)
{
node
,
err
:=
u
.
create
.
Save
(
ctx
)
if
err
!=
nil
{
return
id
,
err
}
return
node
.
ID
,
nil
}
// IDX is like ID, but panics if an error occurs.
func
(
u
*
ErrorPassthroughRuleUpsertOne
)
IDX
(
ctx
context
.
Context
)
int64
{
id
,
err
:=
u
.
ID
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
id
}
// ErrorPassthroughRuleCreateBulk is the builder for creating many ErrorPassthroughRule entities in bulk.
type
ErrorPassthroughRuleCreateBulk
struct
{
config
err
error
builders
[]
*
ErrorPassthroughRuleCreate
conflict
[]
sql
.
ConflictOption
}
// Save creates the ErrorPassthroughRule entities in the database.
func
(
_c
*
ErrorPassthroughRuleCreateBulk
)
Save
(
ctx
context
.
Context
)
([]
*
ErrorPassthroughRule
,
error
)
{
if
_c
.
err
!=
nil
{
return
nil
,
_c
.
err
}
specs
:=
make
([]
*
sqlgraph
.
CreateSpec
,
len
(
_c
.
builders
))
nodes
:=
make
([]
*
ErrorPassthroughRule
,
len
(
_c
.
builders
))
mutators
:=
make
([]
Mutator
,
len
(
_c
.
builders
))
for
i
:=
range
_c
.
builders
{
func
(
i
int
,
root
context
.
Context
)
{
builder
:=
_c
.
builders
[
i
]
builder
.
defaults
()
var
mut
Mutator
=
MutateFunc
(
func
(
ctx
context
.
Context
,
m
Mutation
)
(
Value
,
error
)
{
mutation
,
ok
:=
m
.
(
*
ErrorPassthroughRuleMutation
)
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"unexpected mutation type %T"
,
m
)
}
if
err
:=
builder
.
check
();
err
!=
nil
{
return
nil
,
err
}
builder
.
mutation
=
mutation
var
err
error
nodes
[
i
],
specs
[
i
]
=
builder
.
createSpec
()
if
i
<
len
(
mutators
)
-
1
{
_
,
err
=
mutators
[
i
+
1
]
.
Mutate
(
root
,
_c
.
builders
[
i
+
1
]
.
mutation
)
}
else
{
spec
:=
&
sqlgraph
.
BatchCreateSpec
{
Nodes
:
specs
}
spec
.
OnConflict
=
_c
.
conflict
// Invoke the actual operation on the latest mutation in the chain.
if
err
=
sqlgraph
.
BatchCreate
(
ctx
,
_c
.
driver
,
spec
);
err
!=
nil
{
if
sqlgraph
.
IsConstraintError
(
err
)
{
err
=
&
ConstraintError
{
msg
:
err
.
Error
(),
wrap
:
err
}
}
}
}
if
err
!=
nil
{
return
nil
,
err
}
mutation
.
id
=
&
nodes
[
i
]
.
ID
if
specs
[
i
]
.
ID
.
Value
!=
nil
{
id
:=
specs
[
i
]
.
ID
.
Value
.
(
int64
)
nodes
[
i
]
.
ID
=
int64
(
id
)
}
mutation
.
done
=
true
return
nodes
[
i
],
nil
})
for
i
:=
len
(
builder
.
hooks
)
-
1
;
i
>=
0
;
i
--
{
mut
=
builder
.
hooks
[
i
](
mut
)
}
mutators
[
i
]
=
mut
}(
i
,
ctx
)
}
if
len
(
mutators
)
>
0
{
if
_
,
err
:=
mutators
[
0
]
.
Mutate
(
ctx
,
_c
.
builders
[
0
]
.
mutation
);
err
!=
nil
{
return
nil
,
err
}
}
return
nodes
,
nil
}
// SaveX is like Save, but panics if an error occurs.
func
(
_c
*
ErrorPassthroughRuleCreateBulk
)
SaveX
(
ctx
context
.
Context
)
[]
*
ErrorPassthroughRule
{
v
,
err
:=
_c
.
Save
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
v
}
// Exec executes the query.
func
(
_c
*
ErrorPassthroughRuleCreateBulk
)
Exec
(
ctx
context
.
Context
)
error
{
_
,
err
:=
_c
.
Save
(
ctx
)
return
err
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_c
*
ErrorPassthroughRuleCreateBulk
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_c
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
// client.ErrorPassthroughRule.CreateBulk(builders...).
// OnConflict(
// // Update the row with the new values
// // the was proposed for insertion.
// sql.ResolveWithNewValues(),
// ).
// // Override some of the fields with custom
// // update values.
// Update(func(u *ent.ErrorPassthroughRuleUpsert) {
// SetCreatedAt(v+v).
// }).
// Exec(ctx)
func
(
_c
*
ErrorPassthroughRuleCreateBulk
)
OnConflict
(
opts
...
sql
.
ConflictOption
)
*
ErrorPassthroughRuleUpsertBulk
{
_c
.
conflict
=
opts
return
&
ErrorPassthroughRuleUpsertBulk
{
create
:
_c
,
}
}
// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
// client.ErrorPassthroughRule.Create().
// OnConflict(sql.ConflictColumns(columns...)).
// Exec(ctx)
func
(
_c
*
ErrorPassthroughRuleCreateBulk
)
OnConflictColumns
(
columns
...
string
)
*
ErrorPassthroughRuleUpsertBulk
{
_c
.
conflict
=
append
(
_c
.
conflict
,
sql
.
ConflictColumns
(
columns
...
))
return
&
ErrorPassthroughRuleUpsertBulk
{
create
:
_c
,
}
}
// ErrorPassthroughRuleUpsertBulk is the builder for "upsert"-ing
// a bulk of ErrorPassthroughRule nodes.
type
ErrorPassthroughRuleUpsertBulk
struct
{
create
*
ErrorPassthroughRuleCreateBulk
}
// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
// client.ErrorPassthroughRule.Create().
// OnConflict(
// sql.ResolveWithNewValues(),
// ).
// Exec(ctx)
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
UpdateNewValues
()
*
ErrorPassthroughRuleUpsertBulk
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWithNewValues
())
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWith
(
func
(
s
*
sql
.
UpdateSet
)
{
for
_
,
b
:=
range
u
.
create
.
builders
{
if
_
,
exists
:=
b
.
mutation
.
CreatedAt
();
exists
{
s
.
SetIgnore
(
errorpassthroughrule
.
FieldCreatedAt
)
}
}
}))
return
u
}
// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
// client.ErrorPassthroughRule.Create().
// OnConflict(sql.ResolveWithIgnore()).
// Exec(ctx)
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
Ignore
()
*
ErrorPassthroughRuleUpsertBulk
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWithIgnore
())
return
u
}
// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
DoNothing
()
*
ErrorPassthroughRuleUpsertBulk
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
DoNothing
())
return
u
}
// Update allows overriding fields `UPDATE` values. See the ErrorPassthroughRuleCreateBulk.OnConflict
// documentation for more info.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
Update
(
set
func
(
*
ErrorPassthroughRuleUpsert
))
*
ErrorPassthroughRuleUpsertBulk
{
u
.
create
.
conflict
=
append
(
u
.
create
.
conflict
,
sql
.
ResolveWith
(
func
(
update
*
sql
.
UpdateSet
)
{
set
(
&
ErrorPassthroughRuleUpsert
{
UpdateSet
:
update
})
}))
return
u
}
// SetUpdatedAt sets the "updated_at" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
SetUpdatedAt
(
v
time
.
Time
)
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetUpdatedAt
(
v
)
})
}
// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
UpdateUpdatedAt
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdateUpdatedAt
()
})
}
// SetName sets the "name" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
SetName
(
v
string
)
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetName
(
v
)
})
}
// UpdateName sets the "name" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
UpdateName
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdateName
()
})
}
// SetEnabled sets the "enabled" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
SetEnabled
(
v
bool
)
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetEnabled
(
v
)
})
}
// UpdateEnabled sets the "enabled" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
UpdateEnabled
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdateEnabled
()
})
}
// SetPriority sets the "priority" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
SetPriority
(
v
int
)
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetPriority
(
v
)
})
}
// AddPriority adds v to the "priority" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
AddPriority
(
v
int
)
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
AddPriority
(
v
)
})
}
// UpdatePriority sets the "priority" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
UpdatePriority
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdatePriority
()
})
}
// SetErrorCodes sets the "error_codes" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
SetErrorCodes
(
v
[]
int
)
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetErrorCodes
(
v
)
})
}
// UpdateErrorCodes sets the "error_codes" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
UpdateErrorCodes
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdateErrorCodes
()
})
}
// ClearErrorCodes clears the value of the "error_codes" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
ClearErrorCodes
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
ClearErrorCodes
()
})
}
// SetKeywords sets the "keywords" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
SetKeywords
(
v
[]
string
)
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetKeywords
(
v
)
})
}
// UpdateKeywords sets the "keywords" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
UpdateKeywords
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdateKeywords
()
})
}
// ClearKeywords clears the value of the "keywords" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
ClearKeywords
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
ClearKeywords
()
})
}
// SetMatchMode sets the "match_mode" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
SetMatchMode
(
v
string
)
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetMatchMode
(
v
)
})
}
// UpdateMatchMode sets the "match_mode" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
UpdateMatchMode
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdateMatchMode
()
})
}
// SetPlatforms sets the "platforms" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
SetPlatforms
(
v
[]
string
)
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetPlatforms
(
v
)
})
}
// UpdatePlatforms sets the "platforms" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
UpdatePlatforms
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdatePlatforms
()
})
}
// ClearPlatforms clears the value of the "platforms" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
ClearPlatforms
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
ClearPlatforms
()
})
}
// SetPassthroughCode sets the "passthrough_code" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
SetPassthroughCode
(
v
bool
)
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetPassthroughCode
(
v
)
})
}
// UpdatePassthroughCode sets the "passthrough_code" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
UpdatePassthroughCode
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdatePassthroughCode
()
})
}
// SetResponseCode sets the "response_code" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
SetResponseCode
(
v
int
)
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetResponseCode
(
v
)
})
}
// AddResponseCode adds v to the "response_code" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
AddResponseCode
(
v
int
)
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
AddResponseCode
(
v
)
})
}
// UpdateResponseCode sets the "response_code" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
UpdateResponseCode
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdateResponseCode
()
})
}
// ClearResponseCode clears the value of the "response_code" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
ClearResponseCode
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
ClearResponseCode
()
})
}
// SetPassthroughBody sets the "passthrough_body" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
SetPassthroughBody
(
v
bool
)
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetPassthroughBody
(
v
)
})
}
// UpdatePassthroughBody sets the "passthrough_body" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
UpdatePassthroughBody
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdatePassthroughBody
()
})
}
// SetCustomMessage sets the "custom_message" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
SetCustomMessage
(
v
string
)
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetCustomMessage
(
v
)
})
}
// UpdateCustomMessage sets the "custom_message" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
UpdateCustomMessage
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdateCustomMessage
()
})
}
// ClearCustomMessage clears the value of the "custom_message" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
ClearCustomMessage
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
ClearCustomMessage
()
})
}
// SetDescription sets the "description" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
SetDescription
(
v
string
)
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
SetDescription
(
v
)
})
}
// UpdateDescription sets the "description" field to the value that was provided on create.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
UpdateDescription
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
UpdateDescription
()
})
}
// ClearDescription clears the value of the "description" field.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
ClearDescription
()
*
ErrorPassthroughRuleUpsertBulk
{
return
u
.
Update
(
func
(
s
*
ErrorPassthroughRuleUpsert
)
{
s
.
ClearDescription
()
})
}
// Exec executes the query.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
Exec
(
ctx
context
.
Context
)
error
{
if
u
.
create
.
err
!=
nil
{
return
u
.
create
.
err
}
for
i
,
b
:=
range
u
.
create
.
builders
{
if
len
(
b
.
conflict
)
!=
0
{
return
fmt
.
Errorf
(
"ent: OnConflict was set for builder %d. Set it on the ErrorPassthroughRuleCreateBulk instead"
,
i
)
}
}
if
len
(
u
.
create
.
conflict
)
==
0
{
return
errors
.
New
(
"ent: missing options for ErrorPassthroughRuleCreateBulk.OnConflict"
)
}
return
u
.
create
.
Exec
(
ctx
)
}
// ExecX is like Exec, but panics if an error occurs.
func
(
u
*
ErrorPassthroughRuleUpsertBulk
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
u
.
create
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
backend/ent/errorpassthroughrule_delete.go
0 → 100644
View file @
7319122e
// Code generated by ent, DO NOT EDIT.
package
ent
import
(
"context"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// ErrorPassthroughRuleDelete is the builder for deleting a ErrorPassthroughRule entity.
type
ErrorPassthroughRuleDelete
struct
{
config
hooks
[]
Hook
mutation
*
ErrorPassthroughRuleMutation
}
// Where appends a list predicates to the ErrorPassthroughRuleDelete builder.
func
(
_d
*
ErrorPassthroughRuleDelete
)
Where
(
ps
...
predicate
.
ErrorPassthroughRule
)
*
ErrorPassthroughRuleDelete
{
_d
.
mutation
.
Where
(
ps
...
)
return
_d
}
// Exec executes the deletion query and returns how many vertices were deleted.
func
(
_d
*
ErrorPassthroughRuleDelete
)
Exec
(
ctx
context
.
Context
)
(
int
,
error
)
{
return
withHooks
(
ctx
,
_d
.
sqlExec
,
_d
.
mutation
,
_d
.
hooks
)
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_d
*
ErrorPassthroughRuleDelete
)
ExecX
(
ctx
context
.
Context
)
int
{
n
,
err
:=
_d
.
Exec
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
n
}
func
(
_d
*
ErrorPassthroughRuleDelete
)
sqlExec
(
ctx
context
.
Context
)
(
int
,
error
)
{
_spec
:=
sqlgraph
.
NewDeleteSpec
(
errorpassthroughrule
.
Table
,
sqlgraph
.
NewFieldSpec
(
errorpassthroughrule
.
FieldID
,
field
.
TypeInt64
))
if
ps
:=
_d
.
mutation
.
predicates
;
len
(
ps
)
>
0
{
_spec
.
Predicate
=
func
(
selector
*
sql
.
Selector
)
{
for
i
:=
range
ps
{
ps
[
i
](
selector
)
}
}
}
affected
,
err
:=
sqlgraph
.
DeleteNodes
(
ctx
,
_d
.
driver
,
_spec
)
if
err
!=
nil
&&
sqlgraph
.
IsConstraintError
(
err
)
{
err
=
&
ConstraintError
{
msg
:
err
.
Error
(),
wrap
:
err
}
}
_d
.
mutation
.
done
=
true
return
affected
,
err
}
// ErrorPassthroughRuleDeleteOne is the builder for deleting a single ErrorPassthroughRule entity.
type
ErrorPassthroughRuleDeleteOne
struct
{
_d
*
ErrorPassthroughRuleDelete
}
// Where appends a list predicates to the ErrorPassthroughRuleDelete builder.
func
(
_d
*
ErrorPassthroughRuleDeleteOne
)
Where
(
ps
...
predicate
.
ErrorPassthroughRule
)
*
ErrorPassthroughRuleDeleteOne
{
_d
.
_d
.
mutation
.
Where
(
ps
...
)
return
_d
}
// Exec executes the deletion query.
func
(
_d
*
ErrorPassthroughRuleDeleteOne
)
Exec
(
ctx
context
.
Context
)
error
{
n
,
err
:=
_d
.
_d
.
Exec
(
ctx
)
switch
{
case
err
!=
nil
:
return
err
case
n
==
0
:
return
&
NotFoundError
{
errorpassthroughrule
.
Label
}
default
:
return
nil
}
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_d
*
ErrorPassthroughRuleDeleteOne
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_d
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
backend/ent/errorpassthroughrule_query.go
0 → 100644
View file @
7319122e
// Code generated by ent, DO NOT EDIT.
package
ent
import
(
"context"
"fmt"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// ErrorPassthroughRuleQuery is the builder for querying ErrorPassthroughRule entities.
type
ErrorPassthroughRuleQuery
struct
{
config
ctx
*
QueryContext
order
[]
errorpassthroughrule
.
OrderOption
inters
[]
Interceptor
predicates
[]
predicate
.
ErrorPassthroughRule
modifiers
[]
func
(
*
sql
.
Selector
)
// intermediate query (i.e. traversal path).
sql
*
sql
.
Selector
path
func
(
context
.
Context
)
(
*
sql
.
Selector
,
error
)
}
// Where adds a new predicate for the ErrorPassthroughRuleQuery builder.
func
(
_q
*
ErrorPassthroughRuleQuery
)
Where
(
ps
...
predicate
.
ErrorPassthroughRule
)
*
ErrorPassthroughRuleQuery
{
_q
.
predicates
=
append
(
_q
.
predicates
,
ps
...
)
return
_q
}
// Limit the number of records to be returned by this query.
func
(
_q
*
ErrorPassthroughRuleQuery
)
Limit
(
limit
int
)
*
ErrorPassthroughRuleQuery
{
_q
.
ctx
.
Limit
=
&
limit
return
_q
}
// Offset to start from.
func
(
_q
*
ErrorPassthroughRuleQuery
)
Offset
(
offset
int
)
*
ErrorPassthroughRuleQuery
{
_q
.
ctx
.
Offset
=
&
offset
return
_q
}
// Unique configures the query builder to filter duplicate records on query.
// By default, unique is set to true, and can be disabled using this method.
func
(
_q
*
ErrorPassthroughRuleQuery
)
Unique
(
unique
bool
)
*
ErrorPassthroughRuleQuery
{
_q
.
ctx
.
Unique
=
&
unique
return
_q
}
// Order specifies how the records should be ordered.
func
(
_q
*
ErrorPassthroughRuleQuery
)
Order
(
o
...
errorpassthroughrule
.
OrderOption
)
*
ErrorPassthroughRuleQuery
{
_q
.
order
=
append
(
_q
.
order
,
o
...
)
return
_q
}
// First returns the first ErrorPassthroughRule entity from the query.
// Returns a *NotFoundError when no ErrorPassthroughRule was found.
func
(
_q
*
ErrorPassthroughRuleQuery
)
First
(
ctx
context
.
Context
)
(
*
ErrorPassthroughRule
,
error
)
{
nodes
,
err
:=
_q
.
Limit
(
1
)
.
All
(
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryFirst
))
if
err
!=
nil
{
return
nil
,
err
}
if
len
(
nodes
)
==
0
{
return
nil
,
&
NotFoundError
{
errorpassthroughrule
.
Label
}
}
return
nodes
[
0
],
nil
}
// FirstX is like First, but panics if an error occurs.
func
(
_q
*
ErrorPassthroughRuleQuery
)
FirstX
(
ctx
context
.
Context
)
*
ErrorPassthroughRule
{
node
,
err
:=
_q
.
First
(
ctx
)
if
err
!=
nil
&&
!
IsNotFound
(
err
)
{
panic
(
err
)
}
return
node
}
// FirstID returns the first ErrorPassthroughRule ID from the query.
// Returns a *NotFoundError when no ErrorPassthroughRule ID was found.
func
(
_q
*
ErrorPassthroughRuleQuery
)
FirstID
(
ctx
context
.
Context
)
(
id
int64
,
err
error
)
{
var
ids
[]
int64
if
ids
,
err
=
_q
.
Limit
(
1
)
.
IDs
(
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryFirstID
));
err
!=
nil
{
return
}
if
len
(
ids
)
==
0
{
err
=
&
NotFoundError
{
errorpassthroughrule
.
Label
}
return
}
return
ids
[
0
],
nil
}
// FirstIDX is like FirstID, but panics if an error occurs.
func
(
_q
*
ErrorPassthroughRuleQuery
)
FirstIDX
(
ctx
context
.
Context
)
int64
{
id
,
err
:=
_q
.
FirstID
(
ctx
)
if
err
!=
nil
&&
!
IsNotFound
(
err
)
{
panic
(
err
)
}
return
id
}
// Only returns a single ErrorPassthroughRule entity found by the query, ensuring it only returns one.
// Returns a *NotSingularError when more than one ErrorPassthroughRule entity is found.
// Returns a *NotFoundError when no ErrorPassthroughRule entities are found.
func
(
_q
*
ErrorPassthroughRuleQuery
)
Only
(
ctx
context
.
Context
)
(
*
ErrorPassthroughRule
,
error
)
{
nodes
,
err
:=
_q
.
Limit
(
2
)
.
All
(
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryOnly
))
if
err
!=
nil
{
return
nil
,
err
}
switch
len
(
nodes
)
{
case
1
:
return
nodes
[
0
],
nil
case
0
:
return
nil
,
&
NotFoundError
{
errorpassthroughrule
.
Label
}
default
:
return
nil
,
&
NotSingularError
{
errorpassthroughrule
.
Label
}
}
}
// OnlyX is like Only, but panics if an error occurs.
func
(
_q
*
ErrorPassthroughRuleQuery
)
OnlyX
(
ctx
context
.
Context
)
*
ErrorPassthroughRule
{
node
,
err
:=
_q
.
Only
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
node
}
// OnlyID is like Only, but returns the only ErrorPassthroughRule ID in the query.
// Returns a *NotSingularError when more than one ErrorPassthroughRule ID is found.
// Returns a *NotFoundError when no entities are found.
func
(
_q
*
ErrorPassthroughRuleQuery
)
OnlyID
(
ctx
context
.
Context
)
(
id
int64
,
err
error
)
{
var
ids
[]
int64
if
ids
,
err
=
_q
.
Limit
(
2
)
.
IDs
(
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryOnlyID
));
err
!=
nil
{
return
}
switch
len
(
ids
)
{
case
1
:
id
=
ids
[
0
]
case
0
:
err
=
&
NotFoundError
{
errorpassthroughrule
.
Label
}
default
:
err
=
&
NotSingularError
{
errorpassthroughrule
.
Label
}
}
return
}
// OnlyIDX is like OnlyID, but panics if an error occurs.
func
(
_q
*
ErrorPassthroughRuleQuery
)
OnlyIDX
(
ctx
context
.
Context
)
int64
{
id
,
err
:=
_q
.
OnlyID
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
id
}
// All executes the query and returns a list of ErrorPassthroughRules.
func
(
_q
*
ErrorPassthroughRuleQuery
)
All
(
ctx
context
.
Context
)
([]
*
ErrorPassthroughRule
,
error
)
{
ctx
=
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryAll
)
if
err
:=
_q
.
prepareQuery
(
ctx
);
err
!=
nil
{
return
nil
,
err
}
qr
:=
querierAll
[[]
*
ErrorPassthroughRule
,
*
ErrorPassthroughRuleQuery
]()
return
withInterceptors
[[]
*
ErrorPassthroughRule
](
ctx
,
_q
,
qr
,
_q
.
inters
)
}
// AllX is like All, but panics if an error occurs.
func
(
_q
*
ErrorPassthroughRuleQuery
)
AllX
(
ctx
context
.
Context
)
[]
*
ErrorPassthroughRule
{
nodes
,
err
:=
_q
.
All
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
nodes
}
// IDs executes the query and returns a list of ErrorPassthroughRule IDs.
func
(
_q
*
ErrorPassthroughRuleQuery
)
IDs
(
ctx
context
.
Context
)
(
ids
[]
int64
,
err
error
)
{
if
_q
.
ctx
.
Unique
==
nil
&&
_q
.
path
!=
nil
{
_q
.
Unique
(
true
)
}
ctx
=
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryIDs
)
if
err
=
_q
.
Select
(
errorpassthroughrule
.
FieldID
)
.
Scan
(
ctx
,
&
ids
);
err
!=
nil
{
return
nil
,
err
}
return
ids
,
nil
}
// IDsX is like IDs, but panics if an error occurs.
func
(
_q
*
ErrorPassthroughRuleQuery
)
IDsX
(
ctx
context
.
Context
)
[]
int64
{
ids
,
err
:=
_q
.
IDs
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
ids
}
// Count returns the count of the given query.
func
(
_q
*
ErrorPassthroughRuleQuery
)
Count
(
ctx
context
.
Context
)
(
int
,
error
)
{
ctx
=
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryCount
)
if
err
:=
_q
.
prepareQuery
(
ctx
);
err
!=
nil
{
return
0
,
err
}
return
withInterceptors
[
int
](
ctx
,
_q
,
querierCount
[
*
ErrorPassthroughRuleQuery
](),
_q
.
inters
)
}
// CountX is like Count, but panics if an error occurs.
func
(
_q
*
ErrorPassthroughRuleQuery
)
CountX
(
ctx
context
.
Context
)
int
{
count
,
err
:=
_q
.
Count
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
count
}
// Exist returns true if the query has elements in the graph.
func
(
_q
*
ErrorPassthroughRuleQuery
)
Exist
(
ctx
context
.
Context
)
(
bool
,
error
)
{
ctx
=
setContextOp
(
ctx
,
_q
.
ctx
,
ent
.
OpQueryExist
)
switch
_
,
err
:=
_q
.
FirstID
(
ctx
);
{
case
IsNotFound
(
err
)
:
return
false
,
nil
case
err
!=
nil
:
return
false
,
fmt
.
Errorf
(
"ent: check existence: %w"
,
err
)
default
:
return
true
,
nil
}
}
// ExistX is like Exist, but panics if an error occurs.
func
(
_q
*
ErrorPassthroughRuleQuery
)
ExistX
(
ctx
context
.
Context
)
bool
{
exist
,
err
:=
_q
.
Exist
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
exist
}
// Clone returns a duplicate of the ErrorPassthroughRuleQuery builder, including all associated steps. It can be
// used to prepare common query builders and use them differently after the clone is made.
func
(
_q
*
ErrorPassthroughRuleQuery
)
Clone
()
*
ErrorPassthroughRuleQuery
{
if
_q
==
nil
{
return
nil
}
return
&
ErrorPassthroughRuleQuery
{
config
:
_q
.
config
,
ctx
:
_q
.
ctx
.
Clone
(),
order
:
append
([]
errorpassthroughrule
.
OrderOption
{},
_q
.
order
...
),
inters
:
append
([]
Interceptor
{},
_q
.
inters
...
),
predicates
:
append
([]
predicate
.
ErrorPassthroughRule
{},
_q
.
predicates
...
),
// clone intermediate query.
sql
:
_q
.
sql
.
Clone
(),
path
:
_q
.
path
,
}
}
// GroupBy is used to group vertices by one or more fields/columns.
// It is often used with aggregate functions, like: count, max, mean, min, sum.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// Count int `json:"count,omitempty"`
// }
//
// client.ErrorPassthroughRule.Query().
// GroupBy(errorpassthroughrule.FieldCreatedAt).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
func
(
_q
*
ErrorPassthroughRuleQuery
)
GroupBy
(
field
string
,
fields
...
string
)
*
ErrorPassthroughRuleGroupBy
{
_q
.
ctx
.
Fields
=
append
([]
string
{
field
},
fields
...
)
grbuild
:=
&
ErrorPassthroughRuleGroupBy
{
build
:
_q
}
grbuild
.
flds
=
&
_q
.
ctx
.
Fields
grbuild
.
label
=
errorpassthroughrule
.
Label
grbuild
.
scan
=
grbuild
.
Scan
return
grbuild
}
// Select allows the selection one or more fields/columns for the given query,
// instead of selecting all fields in the entity.
//
// Example:
//
// var v []struct {
// CreatedAt time.Time `json:"created_at,omitempty"`
// }
//
// client.ErrorPassthroughRule.Query().
// Select(errorpassthroughrule.FieldCreatedAt).
// Scan(ctx, &v)
func
(
_q
*
ErrorPassthroughRuleQuery
)
Select
(
fields
...
string
)
*
ErrorPassthroughRuleSelect
{
_q
.
ctx
.
Fields
=
append
(
_q
.
ctx
.
Fields
,
fields
...
)
sbuild
:=
&
ErrorPassthroughRuleSelect
{
ErrorPassthroughRuleQuery
:
_q
}
sbuild
.
label
=
errorpassthroughrule
.
Label
sbuild
.
flds
,
sbuild
.
scan
=
&
_q
.
ctx
.
Fields
,
sbuild
.
Scan
return
sbuild
}
// Aggregate returns a ErrorPassthroughRuleSelect configured with the given aggregations.
func
(
_q
*
ErrorPassthroughRuleQuery
)
Aggregate
(
fns
...
AggregateFunc
)
*
ErrorPassthroughRuleSelect
{
return
_q
.
Select
()
.
Aggregate
(
fns
...
)
}
func
(
_q
*
ErrorPassthroughRuleQuery
)
prepareQuery
(
ctx
context
.
Context
)
error
{
for
_
,
inter
:=
range
_q
.
inters
{
if
inter
==
nil
{
return
fmt
.
Errorf
(
"ent: uninitialized interceptor (forgotten import ent/runtime?)"
)
}
if
trv
,
ok
:=
inter
.
(
Traverser
);
ok
{
if
err
:=
trv
.
Traverse
(
ctx
,
_q
);
err
!=
nil
{
return
err
}
}
}
for
_
,
f
:=
range
_q
.
ctx
.
Fields
{
if
!
errorpassthroughrule
.
ValidColumn
(
f
)
{
return
&
ValidationError
{
Name
:
f
,
err
:
fmt
.
Errorf
(
"ent: invalid field %q for query"
,
f
)}
}
}
if
_q
.
path
!=
nil
{
prev
,
err
:=
_q
.
path
(
ctx
)
if
err
!=
nil
{
return
err
}
_q
.
sql
=
prev
}
return
nil
}
func
(
_q
*
ErrorPassthroughRuleQuery
)
sqlAll
(
ctx
context
.
Context
,
hooks
...
queryHook
)
([]
*
ErrorPassthroughRule
,
error
)
{
var
(
nodes
=
[]
*
ErrorPassthroughRule
{}
_spec
=
_q
.
querySpec
()
)
_spec
.
ScanValues
=
func
(
columns
[]
string
)
([]
any
,
error
)
{
return
(
*
ErrorPassthroughRule
)
.
scanValues
(
nil
,
columns
)
}
_spec
.
Assign
=
func
(
columns
[]
string
,
values
[]
any
)
error
{
node
:=
&
ErrorPassthroughRule
{
config
:
_q
.
config
}
nodes
=
append
(
nodes
,
node
)
return
node
.
assignValues
(
columns
,
values
)
}
if
len
(
_q
.
modifiers
)
>
0
{
_spec
.
Modifiers
=
_q
.
modifiers
}
for
i
:=
range
hooks
{
hooks
[
i
](
ctx
,
_spec
)
}
if
err
:=
sqlgraph
.
QueryNodes
(
ctx
,
_q
.
driver
,
_spec
);
err
!=
nil
{
return
nil
,
err
}
if
len
(
nodes
)
==
0
{
return
nodes
,
nil
}
return
nodes
,
nil
}
func
(
_q
*
ErrorPassthroughRuleQuery
)
sqlCount
(
ctx
context
.
Context
)
(
int
,
error
)
{
_spec
:=
_q
.
querySpec
()
if
len
(
_q
.
modifiers
)
>
0
{
_spec
.
Modifiers
=
_q
.
modifiers
}
_spec
.
Node
.
Columns
=
_q
.
ctx
.
Fields
if
len
(
_q
.
ctx
.
Fields
)
>
0
{
_spec
.
Unique
=
_q
.
ctx
.
Unique
!=
nil
&&
*
_q
.
ctx
.
Unique
}
return
sqlgraph
.
CountNodes
(
ctx
,
_q
.
driver
,
_spec
)
}
func
(
_q
*
ErrorPassthroughRuleQuery
)
querySpec
()
*
sqlgraph
.
QuerySpec
{
_spec
:=
sqlgraph
.
NewQuerySpec
(
errorpassthroughrule
.
Table
,
errorpassthroughrule
.
Columns
,
sqlgraph
.
NewFieldSpec
(
errorpassthroughrule
.
FieldID
,
field
.
TypeInt64
))
_spec
.
From
=
_q
.
sql
if
unique
:=
_q
.
ctx
.
Unique
;
unique
!=
nil
{
_spec
.
Unique
=
*
unique
}
else
if
_q
.
path
!=
nil
{
_spec
.
Unique
=
true
}
if
fields
:=
_q
.
ctx
.
Fields
;
len
(
fields
)
>
0
{
_spec
.
Node
.
Columns
=
make
([]
string
,
0
,
len
(
fields
))
_spec
.
Node
.
Columns
=
append
(
_spec
.
Node
.
Columns
,
errorpassthroughrule
.
FieldID
)
for
i
:=
range
fields
{
if
fields
[
i
]
!=
errorpassthroughrule
.
FieldID
{
_spec
.
Node
.
Columns
=
append
(
_spec
.
Node
.
Columns
,
fields
[
i
])
}
}
}
if
ps
:=
_q
.
predicates
;
len
(
ps
)
>
0
{
_spec
.
Predicate
=
func
(
selector
*
sql
.
Selector
)
{
for
i
:=
range
ps
{
ps
[
i
](
selector
)
}
}
}
if
limit
:=
_q
.
ctx
.
Limit
;
limit
!=
nil
{
_spec
.
Limit
=
*
limit
}
if
offset
:=
_q
.
ctx
.
Offset
;
offset
!=
nil
{
_spec
.
Offset
=
*
offset
}
if
ps
:=
_q
.
order
;
len
(
ps
)
>
0
{
_spec
.
Order
=
func
(
selector
*
sql
.
Selector
)
{
for
i
:=
range
ps
{
ps
[
i
](
selector
)
}
}
}
return
_spec
}
func
(
_q
*
ErrorPassthroughRuleQuery
)
sqlQuery
(
ctx
context
.
Context
)
*
sql
.
Selector
{
builder
:=
sql
.
Dialect
(
_q
.
driver
.
Dialect
())
t1
:=
builder
.
Table
(
errorpassthroughrule
.
Table
)
columns
:=
_q
.
ctx
.
Fields
if
len
(
columns
)
==
0
{
columns
=
errorpassthroughrule
.
Columns
}
selector
:=
builder
.
Select
(
t1
.
Columns
(
columns
...
)
...
)
.
From
(
t1
)
if
_q
.
sql
!=
nil
{
selector
=
_q
.
sql
selector
.
Select
(
selector
.
Columns
(
columns
...
)
...
)
}
if
_q
.
ctx
.
Unique
!=
nil
&&
*
_q
.
ctx
.
Unique
{
selector
.
Distinct
()
}
for
_
,
m
:=
range
_q
.
modifiers
{
m
(
selector
)
}
for
_
,
p
:=
range
_q
.
predicates
{
p
(
selector
)
}
for
_
,
p
:=
range
_q
.
order
{
p
(
selector
)
}
if
offset
:=
_q
.
ctx
.
Offset
;
offset
!=
nil
{
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector
.
Offset
(
*
offset
)
.
Limit
(
math
.
MaxInt32
)
}
if
limit
:=
_q
.
ctx
.
Limit
;
limit
!=
nil
{
selector
.
Limit
(
*
limit
)
}
return
selector
}
// ForUpdate locks the selected rows against concurrent updates, and prevent them from being
// updated, deleted or "selected ... for update" by other sessions, until the transaction is
// either committed or rolled-back.
func
(
_q
*
ErrorPassthroughRuleQuery
)
ForUpdate
(
opts
...
sql
.
LockOption
)
*
ErrorPassthroughRuleQuery
{
if
_q
.
driver
.
Dialect
()
==
dialect
.
Postgres
{
_q
.
Unique
(
false
)
}
_q
.
modifiers
=
append
(
_q
.
modifiers
,
func
(
s
*
sql
.
Selector
)
{
s
.
ForUpdate
(
opts
...
)
})
return
_q
}
// ForShare behaves similarly to ForUpdate, except that it acquires a shared mode lock
// on any rows that are read. Other sessions can read the rows, but cannot modify them
// until your transaction commits.
func
(
_q
*
ErrorPassthroughRuleQuery
)
ForShare
(
opts
...
sql
.
LockOption
)
*
ErrorPassthroughRuleQuery
{
if
_q
.
driver
.
Dialect
()
==
dialect
.
Postgres
{
_q
.
Unique
(
false
)
}
_q
.
modifiers
=
append
(
_q
.
modifiers
,
func
(
s
*
sql
.
Selector
)
{
s
.
ForShare
(
opts
...
)
})
return
_q
}
// ErrorPassthroughRuleGroupBy is the group-by builder for ErrorPassthroughRule entities.
type
ErrorPassthroughRuleGroupBy
struct
{
selector
build
*
ErrorPassthroughRuleQuery
}
// Aggregate adds the given aggregation functions to the group-by query.
func
(
_g
*
ErrorPassthroughRuleGroupBy
)
Aggregate
(
fns
...
AggregateFunc
)
*
ErrorPassthroughRuleGroupBy
{
_g
.
fns
=
append
(
_g
.
fns
,
fns
...
)
return
_g
}
// Scan applies the selector query and scans the result into the given value.
func
(
_g
*
ErrorPassthroughRuleGroupBy
)
Scan
(
ctx
context
.
Context
,
v
any
)
error
{
ctx
=
setContextOp
(
ctx
,
_g
.
build
.
ctx
,
ent
.
OpQueryGroupBy
)
if
err
:=
_g
.
build
.
prepareQuery
(
ctx
);
err
!=
nil
{
return
err
}
return
scanWithInterceptors
[
*
ErrorPassthroughRuleQuery
,
*
ErrorPassthroughRuleGroupBy
](
ctx
,
_g
.
build
,
_g
,
_g
.
build
.
inters
,
v
)
}
func
(
_g
*
ErrorPassthroughRuleGroupBy
)
sqlScan
(
ctx
context
.
Context
,
root
*
ErrorPassthroughRuleQuery
,
v
any
)
error
{
selector
:=
root
.
sqlQuery
(
ctx
)
.
Select
()
aggregation
:=
make
([]
string
,
0
,
len
(
_g
.
fns
))
for
_
,
fn
:=
range
_g
.
fns
{
aggregation
=
append
(
aggregation
,
fn
(
selector
))
}
if
len
(
selector
.
SelectedColumns
())
==
0
{
columns
:=
make
([]
string
,
0
,
len
(
*
_g
.
flds
)
+
len
(
_g
.
fns
))
for
_
,
f
:=
range
*
_g
.
flds
{
columns
=
append
(
columns
,
selector
.
C
(
f
))
}
columns
=
append
(
columns
,
aggregation
...
)
selector
.
Select
(
columns
...
)
}
selector
.
GroupBy
(
selector
.
Columns
(
*
_g
.
flds
...
)
...
)
if
err
:=
selector
.
Err
();
err
!=
nil
{
return
err
}
rows
:=
&
sql
.
Rows
{}
query
,
args
:=
selector
.
Query
()
if
err
:=
_g
.
build
.
driver
.
Query
(
ctx
,
query
,
args
,
rows
);
err
!=
nil
{
return
err
}
defer
rows
.
Close
()
return
sql
.
ScanSlice
(
rows
,
v
)
}
// ErrorPassthroughRuleSelect is the builder for selecting fields of ErrorPassthroughRule entities.
type
ErrorPassthroughRuleSelect
struct
{
*
ErrorPassthroughRuleQuery
selector
}
// Aggregate adds the given aggregation functions to the selector query.
func
(
_s
*
ErrorPassthroughRuleSelect
)
Aggregate
(
fns
...
AggregateFunc
)
*
ErrorPassthroughRuleSelect
{
_s
.
fns
=
append
(
_s
.
fns
,
fns
...
)
return
_s
}
// Scan applies the selector query and scans the result into the given value.
func
(
_s
*
ErrorPassthroughRuleSelect
)
Scan
(
ctx
context
.
Context
,
v
any
)
error
{
ctx
=
setContextOp
(
ctx
,
_s
.
ctx
,
ent
.
OpQuerySelect
)
if
err
:=
_s
.
prepareQuery
(
ctx
);
err
!=
nil
{
return
err
}
return
scanWithInterceptors
[
*
ErrorPassthroughRuleQuery
,
*
ErrorPassthroughRuleSelect
](
ctx
,
_s
.
ErrorPassthroughRuleQuery
,
_s
,
_s
.
inters
,
v
)
}
func
(
_s
*
ErrorPassthroughRuleSelect
)
sqlScan
(
ctx
context
.
Context
,
root
*
ErrorPassthroughRuleQuery
,
v
any
)
error
{
selector
:=
root
.
sqlQuery
(
ctx
)
aggregation
:=
make
([]
string
,
0
,
len
(
_s
.
fns
))
for
_
,
fn
:=
range
_s
.
fns
{
aggregation
=
append
(
aggregation
,
fn
(
selector
))
}
switch
n
:=
len
(
*
_s
.
selector
.
flds
);
{
case
n
==
0
&&
len
(
aggregation
)
>
0
:
selector
.
Select
(
aggregation
...
)
case
n
!=
0
&&
len
(
aggregation
)
>
0
:
selector
.
AppendSelect
(
aggregation
...
)
}
rows
:=
&
sql
.
Rows
{}
query
,
args
:=
selector
.
Query
()
if
err
:=
_s
.
driver
.
Query
(
ctx
,
query
,
args
,
rows
);
err
!=
nil
{
return
err
}
defer
rows
.
Close
()
return
sql
.
ScanSlice
(
rows
,
v
)
}
backend/ent/errorpassthroughrule_update.go
0 → 100644
View file @
7319122e
// Code generated by ent, DO NOT EDIT.
package
ent
import
(
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/Wei-Shaw/sub2api/ent/errorpassthroughrule"
"github.com/Wei-Shaw/sub2api/ent/predicate"
)
// ErrorPassthroughRuleUpdate is the builder for updating ErrorPassthroughRule entities.
type
ErrorPassthroughRuleUpdate
struct
{
config
hooks
[]
Hook
mutation
*
ErrorPassthroughRuleMutation
}
// Where appends a list predicates to the ErrorPassthroughRuleUpdate builder.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
Where
(
ps
...
predicate
.
ErrorPassthroughRule
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
Where
(
ps
...
)
return
_u
}
// SetUpdatedAt sets the "updated_at" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetUpdatedAt
(
v
time
.
Time
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
SetUpdatedAt
(
v
)
return
_u
}
// SetName sets the "name" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetName
(
v
string
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
SetName
(
v
)
return
_u
}
// SetNillableName sets the "name" field if the given value is not nil.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetNillableName
(
v
*
string
)
*
ErrorPassthroughRuleUpdate
{
if
v
!=
nil
{
_u
.
SetName
(
*
v
)
}
return
_u
}
// SetEnabled sets the "enabled" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetEnabled
(
v
bool
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
SetEnabled
(
v
)
return
_u
}
// SetNillableEnabled sets the "enabled" field if the given value is not nil.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetNillableEnabled
(
v
*
bool
)
*
ErrorPassthroughRuleUpdate
{
if
v
!=
nil
{
_u
.
SetEnabled
(
*
v
)
}
return
_u
}
// SetPriority sets the "priority" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetPriority
(
v
int
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
ResetPriority
()
_u
.
mutation
.
SetPriority
(
v
)
return
_u
}
// SetNillablePriority sets the "priority" field if the given value is not nil.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetNillablePriority
(
v
*
int
)
*
ErrorPassthroughRuleUpdate
{
if
v
!=
nil
{
_u
.
SetPriority
(
*
v
)
}
return
_u
}
// AddPriority adds value to the "priority" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
AddPriority
(
v
int
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
AddPriority
(
v
)
return
_u
}
// SetErrorCodes sets the "error_codes" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetErrorCodes
(
v
[]
int
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
SetErrorCodes
(
v
)
return
_u
}
// AppendErrorCodes appends value to the "error_codes" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
AppendErrorCodes
(
v
[]
int
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
AppendErrorCodes
(
v
)
return
_u
}
// ClearErrorCodes clears the value of the "error_codes" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
ClearErrorCodes
()
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
ClearErrorCodes
()
return
_u
}
// SetKeywords sets the "keywords" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetKeywords
(
v
[]
string
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
SetKeywords
(
v
)
return
_u
}
// AppendKeywords appends value to the "keywords" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
AppendKeywords
(
v
[]
string
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
AppendKeywords
(
v
)
return
_u
}
// ClearKeywords clears the value of the "keywords" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
ClearKeywords
()
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
ClearKeywords
()
return
_u
}
// SetMatchMode sets the "match_mode" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetMatchMode
(
v
string
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
SetMatchMode
(
v
)
return
_u
}
// SetNillableMatchMode sets the "match_mode" field if the given value is not nil.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetNillableMatchMode
(
v
*
string
)
*
ErrorPassthroughRuleUpdate
{
if
v
!=
nil
{
_u
.
SetMatchMode
(
*
v
)
}
return
_u
}
// SetPlatforms sets the "platforms" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetPlatforms
(
v
[]
string
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
SetPlatforms
(
v
)
return
_u
}
// AppendPlatforms appends value to the "platforms" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
AppendPlatforms
(
v
[]
string
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
AppendPlatforms
(
v
)
return
_u
}
// ClearPlatforms clears the value of the "platforms" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
ClearPlatforms
()
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
ClearPlatforms
()
return
_u
}
// SetPassthroughCode sets the "passthrough_code" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetPassthroughCode
(
v
bool
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
SetPassthroughCode
(
v
)
return
_u
}
// SetNillablePassthroughCode sets the "passthrough_code" field if the given value is not nil.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetNillablePassthroughCode
(
v
*
bool
)
*
ErrorPassthroughRuleUpdate
{
if
v
!=
nil
{
_u
.
SetPassthroughCode
(
*
v
)
}
return
_u
}
// SetResponseCode sets the "response_code" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetResponseCode
(
v
int
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
ResetResponseCode
()
_u
.
mutation
.
SetResponseCode
(
v
)
return
_u
}
// SetNillableResponseCode sets the "response_code" field if the given value is not nil.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetNillableResponseCode
(
v
*
int
)
*
ErrorPassthroughRuleUpdate
{
if
v
!=
nil
{
_u
.
SetResponseCode
(
*
v
)
}
return
_u
}
// AddResponseCode adds value to the "response_code" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
AddResponseCode
(
v
int
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
AddResponseCode
(
v
)
return
_u
}
// ClearResponseCode clears the value of the "response_code" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
ClearResponseCode
()
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
ClearResponseCode
()
return
_u
}
// SetPassthroughBody sets the "passthrough_body" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetPassthroughBody
(
v
bool
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
SetPassthroughBody
(
v
)
return
_u
}
// SetNillablePassthroughBody sets the "passthrough_body" field if the given value is not nil.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetNillablePassthroughBody
(
v
*
bool
)
*
ErrorPassthroughRuleUpdate
{
if
v
!=
nil
{
_u
.
SetPassthroughBody
(
*
v
)
}
return
_u
}
// SetCustomMessage sets the "custom_message" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetCustomMessage
(
v
string
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
SetCustomMessage
(
v
)
return
_u
}
// SetNillableCustomMessage sets the "custom_message" field if the given value is not nil.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetNillableCustomMessage
(
v
*
string
)
*
ErrorPassthroughRuleUpdate
{
if
v
!=
nil
{
_u
.
SetCustomMessage
(
*
v
)
}
return
_u
}
// ClearCustomMessage clears the value of the "custom_message" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
ClearCustomMessage
()
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
ClearCustomMessage
()
return
_u
}
// SetDescription sets the "description" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetDescription
(
v
string
)
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
SetDescription
(
v
)
return
_u
}
// SetNillableDescription sets the "description" field if the given value is not nil.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SetNillableDescription
(
v
*
string
)
*
ErrorPassthroughRuleUpdate
{
if
v
!=
nil
{
_u
.
SetDescription
(
*
v
)
}
return
_u
}
// ClearDescription clears the value of the "description" field.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
ClearDescription
()
*
ErrorPassthroughRuleUpdate
{
_u
.
mutation
.
ClearDescription
()
return
_u
}
// Mutation returns the ErrorPassthroughRuleMutation object of the builder.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
Mutation
()
*
ErrorPassthroughRuleMutation
{
return
_u
.
mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
Save
(
ctx
context
.
Context
)
(
int
,
error
)
{
_u
.
defaults
()
return
withHooks
(
ctx
,
_u
.
sqlSave
,
_u
.
mutation
,
_u
.
hooks
)
}
// SaveX is like Save, but panics if an error occurs.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
SaveX
(
ctx
context
.
Context
)
int
{
affected
,
err
:=
_u
.
Save
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
affected
}
// Exec executes the query.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
Exec
(
ctx
context
.
Context
)
error
{
_
,
err
:=
_u
.
Save
(
ctx
)
return
err
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_u
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
// defaults sets the default values of the builder before save.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
defaults
()
{
if
_
,
ok
:=
_u
.
mutation
.
UpdatedAt
();
!
ok
{
v
:=
errorpassthroughrule
.
UpdateDefaultUpdatedAt
()
_u
.
mutation
.
SetUpdatedAt
(
v
)
}
}
// check runs all checks and user-defined validators on the builder.
func
(
_u
*
ErrorPassthroughRuleUpdate
)
check
()
error
{
if
v
,
ok
:=
_u
.
mutation
.
Name
();
ok
{
if
err
:=
errorpassthroughrule
.
NameValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"name"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "ErrorPassthroughRule.name": %w`
,
err
)}
}
}
if
v
,
ok
:=
_u
.
mutation
.
MatchMode
();
ok
{
if
err
:=
errorpassthroughrule
.
MatchModeValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"match_mode"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "ErrorPassthroughRule.match_mode": %w`
,
err
)}
}
}
return
nil
}
func
(
_u
*
ErrorPassthroughRuleUpdate
)
sqlSave
(
ctx
context
.
Context
)
(
_node
int
,
err
error
)
{
if
err
:=
_u
.
check
();
err
!=
nil
{
return
_node
,
err
}
_spec
:=
sqlgraph
.
NewUpdateSpec
(
errorpassthroughrule
.
Table
,
errorpassthroughrule
.
Columns
,
sqlgraph
.
NewFieldSpec
(
errorpassthroughrule
.
FieldID
,
field
.
TypeInt64
))
if
ps
:=
_u
.
mutation
.
predicates
;
len
(
ps
)
>
0
{
_spec
.
Predicate
=
func
(
selector
*
sql
.
Selector
)
{
for
i
:=
range
ps
{
ps
[
i
](
selector
)
}
}
}
if
value
,
ok
:=
_u
.
mutation
.
UpdatedAt
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldUpdatedAt
,
field
.
TypeTime
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
Name
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldName
,
field
.
TypeString
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
Enabled
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldEnabled
,
field
.
TypeBool
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
Priority
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldPriority
,
field
.
TypeInt
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
AddedPriority
();
ok
{
_spec
.
AddField
(
errorpassthroughrule
.
FieldPriority
,
field
.
TypeInt
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
ErrorCodes
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldErrorCodes
,
field
.
TypeJSON
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
AppendedErrorCodes
();
ok
{
_spec
.
AddModifier
(
func
(
u
*
sql
.
UpdateBuilder
)
{
sqljson
.
Append
(
u
,
errorpassthroughrule
.
FieldErrorCodes
,
value
)
})
}
if
_u
.
mutation
.
ErrorCodesCleared
()
{
_spec
.
ClearField
(
errorpassthroughrule
.
FieldErrorCodes
,
field
.
TypeJSON
)
}
if
value
,
ok
:=
_u
.
mutation
.
Keywords
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldKeywords
,
field
.
TypeJSON
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
AppendedKeywords
();
ok
{
_spec
.
AddModifier
(
func
(
u
*
sql
.
UpdateBuilder
)
{
sqljson
.
Append
(
u
,
errorpassthroughrule
.
FieldKeywords
,
value
)
})
}
if
_u
.
mutation
.
KeywordsCleared
()
{
_spec
.
ClearField
(
errorpassthroughrule
.
FieldKeywords
,
field
.
TypeJSON
)
}
if
value
,
ok
:=
_u
.
mutation
.
MatchMode
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldMatchMode
,
field
.
TypeString
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
Platforms
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldPlatforms
,
field
.
TypeJSON
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
AppendedPlatforms
();
ok
{
_spec
.
AddModifier
(
func
(
u
*
sql
.
UpdateBuilder
)
{
sqljson
.
Append
(
u
,
errorpassthroughrule
.
FieldPlatforms
,
value
)
})
}
if
_u
.
mutation
.
PlatformsCleared
()
{
_spec
.
ClearField
(
errorpassthroughrule
.
FieldPlatforms
,
field
.
TypeJSON
)
}
if
value
,
ok
:=
_u
.
mutation
.
PassthroughCode
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldPassthroughCode
,
field
.
TypeBool
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
ResponseCode
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldResponseCode
,
field
.
TypeInt
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
AddedResponseCode
();
ok
{
_spec
.
AddField
(
errorpassthroughrule
.
FieldResponseCode
,
field
.
TypeInt
,
value
)
}
if
_u
.
mutation
.
ResponseCodeCleared
()
{
_spec
.
ClearField
(
errorpassthroughrule
.
FieldResponseCode
,
field
.
TypeInt
)
}
if
value
,
ok
:=
_u
.
mutation
.
PassthroughBody
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldPassthroughBody
,
field
.
TypeBool
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
CustomMessage
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldCustomMessage
,
field
.
TypeString
,
value
)
}
if
_u
.
mutation
.
CustomMessageCleared
()
{
_spec
.
ClearField
(
errorpassthroughrule
.
FieldCustomMessage
,
field
.
TypeString
)
}
if
value
,
ok
:=
_u
.
mutation
.
Description
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldDescription
,
field
.
TypeString
,
value
)
}
if
_u
.
mutation
.
DescriptionCleared
()
{
_spec
.
ClearField
(
errorpassthroughrule
.
FieldDescription
,
field
.
TypeString
)
}
if
_node
,
err
=
sqlgraph
.
UpdateNodes
(
ctx
,
_u
.
driver
,
_spec
);
err
!=
nil
{
if
_
,
ok
:=
err
.
(
*
sqlgraph
.
NotFoundError
);
ok
{
err
=
&
NotFoundError
{
errorpassthroughrule
.
Label
}
}
else
if
sqlgraph
.
IsConstraintError
(
err
)
{
err
=
&
ConstraintError
{
msg
:
err
.
Error
(),
wrap
:
err
}
}
return
0
,
err
}
_u
.
mutation
.
done
=
true
return
_node
,
nil
}
// ErrorPassthroughRuleUpdateOne is the builder for updating a single ErrorPassthroughRule entity.
type
ErrorPassthroughRuleUpdateOne
struct
{
config
fields
[]
string
hooks
[]
Hook
mutation
*
ErrorPassthroughRuleMutation
}
// SetUpdatedAt sets the "updated_at" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetUpdatedAt
(
v
time
.
Time
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
SetUpdatedAt
(
v
)
return
_u
}
// SetName sets the "name" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetName
(
v
string
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
SetName
(
v
)
return
_u
}
// SetNillableName sets the "name" field if the given value is not nil.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetNillableName
(
v
*
string
)
*
ErrorPassthroughRuleUpdateOne
{
if
v
!=
nil
{
_u
.
SetName
(
*
v
)
}
return
_u
}
// SetEnabled sets the "enabled" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetEnabled
(
v
bool
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
SetEnabled
(
v
)
return
_u
}
// SetNillableEnabled sets the "enabled" field if the given value is not nil.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetNillableEnabled
(
v
*
bool
)
*
ErrorPassthroughRuleUpdateOne
{
if
v
!=
nil
{
_u
.
SetEnabled
(
*
v
)
}
return
_u
}
// SetPriority sets the "priority" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetPriority
(
v
int
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
ResetPriority
()
_u
.
mutation
.
SetPriority
(
v
)
return
_u
}
// SetNillablePriority sets the "priority" field if the given value is not nil.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetNillablePriority
(
v
*
int
)
*
ErrorPassthroughRuleUpdateOne
{
if
v
!=
nil
{
_u
.
SetPriority
(
*
v
)
}
return
_u
}
// AddPriority adds value to the "priority" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
AddPriority
(
v
int
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
AddPriority
(
v
)
return
_u
}
// SetErrorCodes sets the "error_codes" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetErrorCodes
(
v
[]
int
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
SetErrorCodes
(
v
)
return
_u
}
// AppendErrorCodes appends value to the "error_codes" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
AppendErrorCodes
(
v
[]
int
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
AppendErrorCodes
(
v
)
return
_u
}
// ClearErrorCodes clears the value of the "error_codes" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
ClearErrorCodes
()
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
ClearErrorCodes
()
return
_u
}
// SetKeywords sets the "keywords" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetKeywords
(
v
[]
string
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
SetKeywords
(
v
)
return
_u
}
// AppendKeywords appends value to the "keywords" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
AppendKeywords
(
v
[]
string
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
AppendKeywords
(
v
)
return
_u
}
// ClearKeywords clears the value of the "keywords" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
ClearKeywords
()
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
ClearKeywords
()
return
_u
}
// SetMatchMode sets the "match_mode" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetMatchMode
(
v
string
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
SetMatchMode
(
v
)
return
_u
}
// SetNillableMatchMode sets the "match_mode" field if the given value is not nil.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetNillableMatchMode
(
v
*
string
)
*
ErrorPassthroughRuleUpdateOne
{
if
v
!=
nil
{
_u
.
SetMatchMode
(
*
v
)
}
return
_u
}
// SetPlatforms sets the "platforms" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetPlatforms
(
v
[]
string
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
SetPlatforms
(
v
)
return
_u
}
// AppendPlatforms appends value to the "platforms" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
AppendPlatforms
(
v
[]
string
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
AppendPlatforms
(
v
)
return
_u
}
// ClearPlatforms clears the value of the "platforms" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
ClearPlatforms
()
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
ClearPlatforms
()
return
_u
}
// SetPassthroughCode sets the "passthrough_code" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetPassthroughCode
(
v
bool
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
SetPassthroughCode
(
v
)
return
_u
}
// SetNillablePassthroughCode sets the "passthrough_code" field if the given value is not nil.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetNillablePassthroughCode
(
v
*
bool
)
*
ErrorPassthroughRuleUpdateOne
{
if
v
!=
nil
{
_u
.
SetPassthroughCode
(
*
v
)
}
return
_u
}
// SetResponseCode sets the "response_code" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetResponseCode
(
v
int
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
ResetResponseCode
()
_u
.
mutation
.
SetResponseCode
(
v
)
return
_u
}
// SetNillableResponseCode sets the "response_code" field if the given value is not nil.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetNillableResponseCode
(
v
*
int
)
*
ErrorPassthroughRuleUpdateOne
{
if
v
!=
nil
{
_u
.
SetResponseCode
(
*
v
)
}
return
_u
}
// AddResponseCode adds value to the "response_code" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
AddResponseCode
(
v
int
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
AddResponseCode
(
v
)
return
_u
}
// ClearResponseCode clears the value of the "response_code" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
ClearResponseCode
()
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
ClearResponseCode
()
return
_u
}
// SetPassthroughBody sets the "passthrough_body" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetPassthroughBody
(
v
bool
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
SetPassthroughBody
(
v
)
return
_u
}
// SetNillablePassthroughBody sets the "passthrough_body" field if the given value is not nil.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetNillablePassthroughBody
(
v
*
bool
)
*
ErrorPassthroughRuleUpdateOne
{
if
v
!=
nil
{
_u
.
SetPassthroughBody
(
*
v
)
}
return
_u
}
// SetCustomMessage sets the "custom_message" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetCustomMessage
(
v
string
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
SetCustomMessage
(
v
)
return
_u
}
// SetNillableCustomMessage sets the "custom_message" field if the given value is not nil.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetNillableCustomMessage
(
v
*
string
)
*
ErrorPassthroughRuleUpdateOne
{
if
v
!=
nil
{
_u
.
SetCustomMessage
(
*
v
)
}
return
_u
}
// ClearCustomMessage clears the value of the "custom_message" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
ClearCustomMessage
()
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
ClearCustomMessage
()
return
_u
}
// SetDescription sets the "description" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetDescription
(
v
string
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
SetDescription
(
v
)
return
_u
}
// SetNillableDescription sets the "description" field if the given value is not nil.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SetNillableDescription
(
v
*
string
)
*
ErrorPassthroughRuleUpdateOne
{
if
v
!=
nil
{
_u
.
SetDescription
(
*
v
)
}
return
_u
}
// ClearDescription clears the value of the "description" field.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
ClearDescription
()
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
ClearDescription
()
return
_u
}
// Mutation returns the ErrorPassthroughRuleMutation object of the builder.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
Mutation
()
*
ErrorPassthroughRuleMutation
{
return
_u
.
mutation
}
// Where appends a list predicates to the ErrorPassthroughRuleUpdate builder.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
Where
(
ps
...
predicate
.
ErrorPassthroughRule
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
mutation
.
Where
(
ps
...
)
return
_u
}
// Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
Select
(
field
string
,
fields
...
string
)
*
ErrorPassthroughRuleUpdateOne
{
_u
.
fields
=
append
([]
string
{
field
},
fields
...
)
return
_u
}
// Save executes the query and returns the updated ErrorPassthroughRule entity.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
Save
(
ctx
context
.
Context
)
(
*
ErrorPassthroughRule
,
error
)
{
_u
.
defaults
()
return
withHooks
(
ctx
,
_u
.
sqlSave
,
_u
.
mutation
,
_u
.
hooks
)
}
// SaveX is like Save, but panics if an error occurs.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
SaveX
(
ctx
context
.
Context
)
*
ErrorPassthroughRule
{
node
,
err
:=
_u
.
Save
(
ctx
)
if
err
!=
nil
{
panic
(
err
)
}
return
node
}
// Exec executes the query on the entity.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
Exec
(
ctx
context
.
Context
)
error
{
_
,
err
:=
_u
.
Save
(
ctx
)
return
err
}
// ExecX is like Exec, but panics if an error occurs.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
ExecX
(
ctx
context
.
Context
)
{
if
err
:=
_u
.
Exec
(
ctx
);
err
!=
nil
{
panic
(
err
)
}
}
// defaults sets the default values of the builder before save.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
defaults
()
{
if
_
,
ok
:=
_u
.
mutation
.
UpdatedAt
();
!
ok
{
v
:=
errorpassthroughrule
.
UpdateDefaultUpdatedAt
()
_u
.
mutation
.
SetUpdatedAt
(
v
)
}
}
// check runs all checks and user-defined validators on the builder.
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
check
()
error
{
if
v
,
ok
:=
_u
.
mutation
.
Name
();
ok
{
if
err
:=
errorpassthroughrule
.
NameValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"name"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "ErrorPassthroughRule.name": %w`
,
err
)}
}
}
if
v
,
ok
:=
_u
.
mutation
.
MatchMode
();
ok
{
if
err
:=
errorpassthroughrule
.
MatchModeValidator
(
v
);
err
!=
nil
{
return
&
ValidationError
{
Name
:
"match_mode"
,
err
:
fmt
.
Errorf
(
`ent: validator failed for field "ErrorPassthroughRule.match_mode": %w`
,
err
)}
}
}
return
nil
}
func
(
_u
*
ErrorPassthroughRuleUpdateOne
)
sqlSave
(
ctx
context
.
Context
)
(
_node
*
ErrorPassthroughRule
,
err
error
)
{
if
err
:=
_u
.
check
();
err
!=
nil
{
return
_node
,
err
}
_spec
:=
sqlgraph
.
NewUpdateSpec
(
errorpassthroughrule
.
Table
,
errorpassthroughrule
.
Columns
,
sqlgraph
.
NewFieldSpec
(
errorpassthroughrule
.
FieldID
,
field
.
TypeInt64
))
id
,
ok
:=
_u
.
mutation
.
ID
()
if
!
ok
{
return
nil
,
&
ValidationError
{
Name
:
"id"
,
err
:
errors
.
New
(
`ent: missing "ErrorPassthroughRule.id" for update`
)}
}
_spec
.
Node
.
ID
.
Value
=
id
if
fields
:=
_u
.
fields
;
len
(
fields
)
>
0
{
_spec
.
Node
.
Columns
=
make
([]
string
,
0
,
len
(
fields
))
_spec
.
Node
.
Columns
=
append
(
_spec
.
Node
.
Columns
,
errorpassthroughrule
.
FieldID
)
for
_
,
f
:=
range
fields
{
if
!
errorpassthroughrule
.
ValidColumn
(
f
)
{
return
nil
,
&
ValidationError
{
Name
:
f
,
err
:
fmt
.
Errorf
(
"ent: invalid field %q for query"
,
f
)}
}
if
f
!=
errorpassthroughrule
.
FieldID
{
_spec
.
Node
.
Columns
=
append
(
_spec
.
Node
.
Columns
,
f
)
}
}
}
if
ps
:=
_u
.
mutation
.
predicates
;
len
(
ps
)
>
0
{
_spec
.
Predicate
=
func
(
selector
*
sql
.
Selector
)
{
for
i
:=
range
ps
{
ps
[
i
](
selector
)
}
}
}
if
value
,
ok
:=
_u
.
mutation
.
UpdatedAt
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldUpdatedAt
,
field
.
TypeTime
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
Name
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldName
,
field
.
TypeString
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
Enabled
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldEnabled
,
field
.
TypeBool
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
Priority
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldPriority
,
field
.
TypeInt
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
AddedPriority
();
ok
{
_spec
.
AddField
(
errorpassthroughrule
.
FieldPriority
,
field
.
TypeInt
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
ErrorCodes
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldErrorCodes
,
field
.
TypeJSON
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
AppendedErrorCodes
();
ok
{
_spec
.
AddModifier
(
func
(
u
*
sql
.
UpdateBuilder
)
{
sqljson
.
Append
(
u
,
errorpassthroughrule
.
FieldErrorCodes
,
value
)
})
}
if
_u
.
mutation
.
ErrorCodesCleared
()
{
_spec
.
ClearField
(
errorpassthroughrule
.
FieldErrorCodes
,
field
.
TypeJSON
)
}
if
value
,
ok
:=
_u
.
mutation
.
Keywords
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldKeywords
,
field
.
TypeJSON
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
AppendedKeywords
();
ok
{
_spec
.
AddModifier
(
func
(
u
*
sql
.
UpdateBuilder
)
{
sqljson
.
Append
(
u
,
errorpassthroughrule
.
FieldKeywords
,
value
)
})
}
if
_u
.
mutation
.
KeywordsCleared
()
{
_spec
.
ClearField
(
errorpassthroughrule
.
FieldKeywords
,
field
.
TypeJSON
)
}
if
value
,
ok
:=
_u
.
mutation
.
MatchMode
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldMatchMode
,
field
.
TypeString
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
Platforms
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldPlatforms
,
field
.
TypeJSON
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
AppendedPlatforms
();
ok
{
_spec
.
AddModifier
(
func
(
u
*
sql
.
UpdateBuilder
)
{
sqljson
.
Append
(
u
,
errorpassthroughrule
.
FieldPlatforms
,
value
)
})
}
if
_u
.
mutation
.
PlatformsCleared
()
{
_spec
.
ClearField
(
errorpassthroughrule
.
FieldPlatforms
,
field
.
TypeJSON
)
}
if
value
,
ok
:=
_u
.
mutation
.
PassthroughCode
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldPassthroughCode
,
field
.
TypeBool
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
ResponseCode
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldResponseCode
,
field
.
TypeInt
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
AddedResponseCode
();
ok
{
_spec
.
AddField
(
errorpassthroughrule
.
FieldResponseCode
,
field
.
TypeInt
,
value
)
}
if
_u
.
mutation
.
ResponseCodeCleared
()
{
_spec
.
ClearField
(
errorpassthroughrule
.
FieldResponseCode
,
field
.
TypeInt
)
}
if
value
,
ok
:=
_u
.
mutation
.
PassthroughBody
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldPassthroughBody
,
field
.
TypeBool
,
value
)
}
if
value
,
ok
:=
_u
.
mutation
.
CustomMessage
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldCustomMessage
,
field
.
TypeString
,
value
)
}
if
_u
.
mutation
.
CustomMessageCleared
()
{
_spec
.
ClearField
(
errorpassthroughrule
.
FieldCustomMessage
,
field
.
TypeString
)
}
if
value
,
ok
:=
_u
.
mutation
.
Description
();
ok
{
_spec
.
SetField
(
errorpassthroughrule
.
FieldDescription
,
field
.
TypeString
,
value
)
}
if
_u
.
mutation
.
DescriptionCleared
()
{
_spec
.
ClearField
(
errorpassthroughrule
.
FieldDescription
,
field
.
TypeString
)
}
_node
=
&
ErrorPassthroughRule
{
config
:
_u
.
config
}
_spec
.
Assign
=
_node
.
assignValues
_spec
.
ScanValues
=
_node
.
scanValues
if
err
=
sqlgraph
.
UpdateNode
(
ctx
,
_u
.
driver
,
_spec
);
err
!=
nil
{
if
_
,
ok
:=
err
.
(
*
sqlgraph
.
NotFoundError
);
ok
{
err
=
&
NotFoundError
{
errorpassthroughrule
.
Label
}
}
else
if
sqlgraph
.
IsConstraintError
(
err
)
{
err
=
&
ConstraintError
{
msg
:
err
.
Error
(),
wrap
:
err
}
}
return
nil
,
err
}
_u
.
mutation
.
done
=
true
return
_node
,
nil
}
backend/ent/hook/hook.go
View file @
7319122e
...
@@ -69,6 +69,18 @@ func (f AnnouncementReadFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.V
...
@@ -69,6 +69,18 @@ func (f AnnouncementReadFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.V
return
nil
,
fmt
.
Errorf
(
"unexpected mutation type %T. expect *ent.AnnouncementReadMutation"
,
m
)
return
nil
,
fmt
.
Errorf
(
"unexpected mutation type %T. expect *ent.AnnouncementReadMutation"
,
m
)
}
}
// The ErrorPassthroughRuleFunc type is an adapter to allow the use of ordinary
// function as ErrorPassthroughRule mutator.
type
ErrorPassthroughRuleFunc
func
(
context
.
Context
,
*
ent
.
ErrorPassthroughRuleMutation
)
(
ent
.
Value
,
error
)
// Mutate calls f(ctx, m).
func
(
f
ErrorPassthroughRuleFunc
)
Mutate
(
ctx
context
.
Context
,
m
ent
.
Mutation
)
(
ent
.
Value
,
error
)
{
if
mv
,
ok
:=
m
.
(
*
ent
.
ErrorPassthroughRuleMutation
);
ok
{
return
f
(
ctx
,
mv
)
}
return
nil
,
fmt
.
Errorf
(
"unexpected mutation type %T. expect *ent.ErrorPassthroughRuleMutation"
,
m
)
}
// The GroupFunc type is an adapter to allow the use of ordinary
// The GroupFunc type is an adapter to allow the use of ordinary
// function as Group mutator.
// function as Group mutator.
type
GroupFunc
func
(
context
.
Context
,
*
ent
.
GroupMutation
)
(
ent
.
Value
,
error
)
type
GroupFunc
func
(
context
.
Context
,
*
ent
.
GroupMutation
)
(
ent
.
Value
,
error
)
...
...
Prev
1
2
3
4
5
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment