Fix null values in DB (#2840)

* Fix album image_files being null.

* Fix small nitpick.

* Use ExecContext instead of Exec.

* Change more columns to not null and set default values.

* Remove columns that don't need to be changed from migration.

* Fix typo.

* Remove unnecessary select statements.

* Remove duplicate code.

* Do not apply changes to radio table.

* Do not apply changes full_text columns and respective indexes.

* Fix musicbrainz columns.

* Rename migration.

* Make ExternalInfoUpdatedAt nullable

* Make Share's timestamps nullable

---------

Co-authored-by: Deluan Quintão <deluan@navidrome.org>
This commit is contained in:
Caio Cotts 2024-02-07 17:45:08 -08:00 committed by GitHub
parent ac4ceab143
commit bf2bcb1279
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 693 additions and 84 deletions

View file

@ -30,3 +30,17 @@ func FirstOr[T comparable](or T, values ...T) T {
// If all the input values are zero, return the default value.
return or
}
// P returns a pointer to the input value
func P[T any](v T) *T {
return &v
}
// V returns the value of the input pointer, or a zero value if the input pointer is nil.
func V[T any](p *T) T {
if p == nil {
var zero T
return zero
}
return *p
}

View file

@ -56,4 +56,28 @@ var _ = Describe("GG", func() {
})
})
})
Describe("P", func() {
It("returns a pointer to the input value", func() {
v := 123
Expect(gg.P(123)).To(Equal(&v))
})
It("returns nil if the input value is zero", func() {
v := 0
Expect(gg.P(0)).To(Equal(&v))
})
})
Describe("V", func() {
It("returns the value of the input pointer", func() {
v := 123
Expect(gg.V(&v)).To(Equal(123))
})
It("returns a zero value if the input pointer is nil", func() {
var v *int
Expect(gg.V(v)).To(Equal(0))
})
})
})