ulule/loukoum

Slices being spread out into values

icholy opened this issue · 4 comments

What's the use case for this behaviour?

package main

import (
	"fmt"
	lk "github.com/ulule/loukoum"
)

func main() {
	fmt.Println(
		lk.Insert("foo").Set(
			lk.Pair("a", []int{1, 2, 3}),
		).String(),
	)
}

output:

INSERT INTO foo (a) VALUES (1, 2, 3)

Where is stmt.Array actually useful?

Ok, so I've read through the code and it looks like the problem is that NewExpression and NewArrayExpression are calling each other recursively. Would you guys be opposed to using reflection to handle the arrays?

novln commented

It's definitely a corner case, but we trust loukoum's user to known how to generate a valid SQL query.

However, we could add a type checking to ensure pair's value has a valid type here:

return types.Pair{Key: key, Value: value}

What do you think @thoas & @gillesfabio ?

thoas commented

@novln sounds good for me 👍

@novln that won't work because []byte is a valid type here.