Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: query failure_reason = "" #16

Closed
wants to merge 1 commit into from

Conversation

bendanzhentan
Copy link
Contributor

@bendanzhentan bendanzhentan commented Dec 4, 2023

When comparing if a ‘text’ type database field is empty, use = '' instead of IS NULL.

Copy link

@welkin22 welkin22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -93,7 +93,7 @@ func ProcessUnprovenBotDelegatedWithdrawals(ctx context.Context, log log.Logger,
maxBlockTime := time.Now().Unix() - cfg.Misc.ProposeTimeWindow

unprovens := make([]core.L2ContractEvent, 0)
result := db.Order("id asc").Where("proven = false AND block_time < ? AND failure_reason IS NULL", maxBlockTime).Limit(limit).Find(&unprovens)
result := db.Order("id asc").Where("proven = false AND block_time < ? AND failure_reason = ''", maxBlockTime).Limit(limit).Find(&unprovens)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do this change? Seems the schema still allows NULL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is related to the Go type definition. The failure reason is defined as a Go string instead of a string. That makes L2ContractEvent.FailureReason default to be empty string "" but not nil. Due to this, the failure reason inserted is "" not NULL.

type L2ContractEvent struct {
        ...
	FailureReason   string `gorm:"type:text"`
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am gonna close this PR and fix this issue by changing L2ContractEvent.FailureReason to *string.

@bendanzhentan
Copy link
Contributor Author

I am gonna close this PR and fix this issue by changing L2ContractEvent.FailureReason to *string.

@bendanzhentan bendanzhentan deleted the fix-query-filter-failure-reason branch December 8, 2023 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants