Skip to content

SelectBuilder.Where() broken #114

@hahanein

Description

@hahanein

Version: a6b9300

Where statements aren't being transformed into "WHERE IN (?, ...)" statements if the value of a squirrel.Eq key is of type []uint8.

Correct:

package main

import (
        "fmt"

        "github.com/Masterminds/squirrel"
)

func main() {
        query, args, err := squirrel.Select("*").Where(squirrel.Eq{"test": []uint32{1, 2, 3}}).ToSql()
        if err != nil {
                panic(err)
        }

        fmt.Println(query) // SELECT * WHERE test IN (?,?,?)
        fmt.Println(args) // [1 2 3]
}

Bug:

package main

import (
        "fmt"

        "github.com/Masterminds/squirrel"
)

func main() {
        query, args, err := squirrel.Select("*").Where(squirrel.Eq{"test": []uint8{1, 2, 3}}).ToSql()
        if err != nil {
                panic(err)
        }

        fmt.Println(query) // SELECT * WHERE test = ?
        fmt.Println(args) // [[1 2 3]]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions