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

Added Int64Slice,StrSlice,Float64Slice and BoolSlice #27

Merged
merged 3 commits into from
Dec 16, 2018
Merged

Added Int64Slice,StrSlice,Float64Slice and BoolSlice #27

merged 3 commits into from
Dec 16, 2018

Conversation

derkan
Copy link
Contributor

@derkan derkan commented Nov 27, 2018

Added Int64Slice,Float64Slice,BoolSlice and StrSlice to types package.

  • StrSlice converts []string{"a","b","c"} to JSON bytes ["a","b","c"] which can be saved to BLOB, VARCHAR, TEXT. And when it reads ["a","b","c"] from DB, it converts to []string{"a","b","c"}
  • Int64Slice converts []int64{1,2,3} to JSON bytes [1,2,3] which can be saved to BLOB, VARCHAR, TEXT. And when it reads [1,2,3] from DB, it converts to []int64{1,2,3}
  • Float64Slice converts []float64{1.1,2.2,3.3} to JSON bytes [1.1,2.2,3.3] which can be saved to BLOB, VARCHAR, TEXT. And when it reads [1.1,2.2,3.3] from DB, it converts to []float64{1.1,2.2,3.3}
  • Bool64Slice converts []bool{true,false,true} to JSON bytes [true,false,true] which can be saved to BLOB, VARCHAR, TEXT. And when it reads [true,false,true] from DB, it converts to []bool{true,false,true}

Each can be nil also.

Closes #28

@derkan derkan changed the title Added Int64Slice and StrSlice Added Int64Slice,StrSlice,Float64Slice and BoolSlice Nov 28, 2018
Copy link
Owner

@samonzeweb samonzeweb left a comment

Choose a reason for hiding this comment

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

I've made some small remarks. Nothing about design of code.

vx, err := nullBoolSlice.Value()
So(err, ShouldEqual, nil)
So(string(vx.([]byte)), ShouldEqual, `[true,false,true]`)

Copy link
Owner

Choose a reason for hiding this comment

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

Blank line.

vx, err := nullFloat64Slice.Value()
So(err, ShouldEqual, nil)
So(string(vx.([]byte)), ShouldEqual, `[1.1,2.2,3.3]`)

Copy link
Owner

Choose a reason for hiding this comment

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

Blank line.

vx, err := nullInt64Slice.Value()
So(err, ShouldEqual, nil)
So(string(vx.([]byte)), ShouldEqual, `[1,2,3]`)

Copy link
Owner

Choose a reason for hiding this comment

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

Blank line.

//
//
// package main

Copy link
Owner

Choose a reason for hiding this comment

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

Comment ALL the example code (even blank lines)

vx, err := nullStrSlice.Value()
So(err, ShouldEqual, nil)
So(string(vx.([]byte)), ShouldEqual, `["a","b","c"]`)

Copy link
Owner

Choose a reason for hiding this comment

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

Blank line.

Convey("Given BoolSlice", t, func() {
Convey("valid value", func() {
v := []bool{true, false, true}
nullBoolSlice := BoolSlice(v)
Copy link
Owner

Choose a reason for hiding this comment

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

Why using nullBoolSlice in every tests, even when there is no involved null/nil values ?
(same for all tests of all new types).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At first I also added Null* types to these new types, but that was redundant as slices can be nil. Those null... named variables are spoils from that try. All "null" can be renamed to "v" so it will become for example vBoolSlice for BoolSlice. Thanks.

@samonzeweb samonzeweb merged commit 83e496c into samonzeweb:master Dec 16, 2018
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.

None yet

2 participants