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

Use reflection to set PK #266

Merged
merged 4 commits into from
Dec 6, 2020
Merged

Use reflection to set PK #266

merged 4 commits into from
Dec 6, 2020

Conversation

AlekSi
Copy link
Member

@AlekSi AlekSi commented Dec 6, 2020

Closes #245.

@@ -94,7 +94,7 @@ func (q *Querier) insert(str Struct, columns []string, values []interface{}) err
if err != nil {
return err
}
record.SetPK(id)
record.SetPK(id) // TODO optimize
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
querier_commands.go:97: Line contains TODO/BUG/FIXME: "TODO optimize" (godox)

t.Parallel()

var person Person
person.SetPK(int32(1))
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
SA1019: person.SetPK is deprecated: prefer direct field assignment where possible: s.ID = pk. (staticcheck)

var person Person
person.SetPK(int32(1))
assert.EqualValues(t, 1, person.ID)
person.SetPK(int64(2))
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
SA1019: person.SetPK is deprecated: prefer direct field assignment where possible: s.ID = pk. (staticcheck)

assert.EqualValues(t, 1, person.ID)
person.SetPK(int64(2))
assert.EqualValues(t, 2, person.ID)
person.SetPK(Integer(3))
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
SA1019: person.SetPK is deprecated: prefer direct field assignment where possible: s.ID = pk. (staticcheck)

assert.EqualValues(t, 3, person.ID)

var project Project
project.SetPK("baron")
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
SA1019: project.SetPK is deprecated: prefer direct field assignment where possible: s.ID = pk. (staticcheck)

var project Project
project.SetPK("baron")
assert.EqualValues(t, "baron", project.ID)
project.SetPK(1)
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
SA1019: project.SetPK is deprecated: prefer direct field assignment where possible: s.ID = pk. (staticcheck)

assert.EqualValues(t, "baron", project.ID)

var extra Extra
extra.SetPK(int32(1))
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
SA1019: extra.SetPK is deprecated: prefer direct field assignment where possible: s.ID = pk. (staticcheck)

var extra Extra
extra.SetPK(int32(1))
assert.EqualValues(t, 1, extra.ID)
extra.SetPK(int64(2))
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
SA1019: extra.SetPK is deprecated: prefer direct field assignment where possible: s.ID = pk. (staticcheck)

assert.EqualValues(t, 1, extra.ID)
extra.SetPK(int64(2))
assert.EqualValues(t, 2, extra.ID)
extra.SetPK(Integer(3))
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
SA1019: extra.SetPK is deprecated: prefer direct field assignment where possible: s.ID = pk. (staticcheck)

@AlekSi AlekSi marked this pull request as ready for review December 6, 2020 17:41
@@ -94,7 +94,7 @@ func (q *Querier) insert(str Struct, columns []string, values []interface{}) err
if err != nil {
return err
}
record.SetPK(id)
record.SetPK(id) // TODO optimize
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
querier_commands.go:97: Line contains TODO/BUG/FIXME: "TODO optimize" (godox)

t.Parallel()

var person Person
person.SetPK(int32(1))
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
SA1019: person.SetPK is deprecated: prefer direct field assignment where possible: s.ID = pk. (staticcheck)

var person Person
person.SetPK(int32(1))
assert.EqualValues(t, 1, person.ID)
person.SetPK(int64(2))
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
SA1019: person.SetPK is deprecated: prefer direct field assignment where possible: s.ID = pk. (staticcheck)

assert.EqualValues(t, 1, person.ID)
person.SetPK(int64(2))
assert.EqualValues(t, 2, person.ID)
person.SetPK(Integer(3))
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
SA1019: person.SetPK is deprecated: prefer direct field assignment where possible: s.ID = pk. (staticcheck)

assert.EqualValues(t, 3, person.ID)

var project Project
project.SetPK("baron")
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
SA1019: project.SetPK is deprecated: prefer direct field assignment where possible: s.ID = pk. (staticcheck)

var project Project
project.SetPK("baron")
assert.EqualValues(t, "baron", project.ID)
project.SetPK(1)
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
SA1019: project.SetPK is deprecated: prefer direct field assignment where possible: s.ID = pk. (staticcheck)

assert.EqualValues(t, "baron", project.ID)

var extra Extra
extra.SetPK(int32(1))
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
SA1019: extra.SetPK is deprecated: prefer direct field assignment where possible: s.ID = pk. (staticcheck)

var extra Extra
extra.SetPK(int32(1))
assert.EqualValues(t, 1, extra.ID)
extra.SetPK(int64(2))
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
SA1019: extra.SetPK is deprecated: prefer direct field assignment where possible: s.ID = pk. (staticcheck)

assert.EqualValues(t, 1, extra.ID)
extra.SetPK(int64(2))
assert.EqualValues(t, 2, extra.ID)
extra.SetPK(Integer(3))
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
SA1019: extra.SetPK is deprecated: prefer direct field assignment where possible: s.ID = pk. (staticcheck)

@@ -94,7 +94,9 @@ func (q *Querier) insert(str Struct, columns []string, values []interface{}) err
if err != nil {
return err
}
record.SetPK(id)

// TODO optimize to avoid using reflection
Copy link
Member

Choose a reason for hiding this comment

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

🚫 [Optional linters] reported by reviewdog 🐶
querier_commands.go:98: Line contains TODO/BUG/FIXME: "TODO optimize to avoid using reflection" (godox)

@AlekSi AlekSi merged commit fb2fac5 into main Dec 6, 2020
@AlekSi AlekSi deleted the use-reflect branch December 6, 2020 19:00
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.

Go 1.15: generated code does not pass go vet
2 participants