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

Is there a tag ignore non-existing SQL column? #374

Open
iredmail opened this issue Jan 11, 2023 · 0 comments
Open

Is there a tag ignore non-existing SQL column? #374

iredmail opened this issue Jan 11, 2023 · 0 comments
Assignees

Comments

@iredmail
Copy link

iredmail commented Jan 11, 2023

Dear all,

Is there a tag like omitempty in json package to ignore non-existing SQL columns and use zero value instead? For example

type MyTable struct {
	OTPEnabled bool   `db:"otp_enabled"`
}

var row MyTable
_,_,_ = goqu.From("my_table").Limit(1).ScanStruct(&row)

SQL column otp_enabled doesn't exist in old versions of our program, but it's used while login before user can apply the SQL structure changes.

Situation

With latest goqu release v9.18.0, it raises error message like Error 1054: Unknown column 'otp_enabled' in 'field list'.

Expected behaviour

I expect goqu to ignore this column and use a zero value (false) of the data type (bool) with a tag. e.g. goqu:"zeroifmissing".

Addtional

I found 3 tags supported by goqu, but none of them is suitable for my case.

  • goqu:"skipinsert"
  • goqu:"skipupdate"
  • goqu:"defaultifempty"
@iredmail iredmail changed the title Is there a tag like omitempty in json package to ignore non-existing SQL column? Is there a tag ignore non-existing SQL column? Jan 12, 2023
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

No branches or pull requests

2 participants