func (repo *SQLiteRepository) QueryOneInTx(ctx context.Context, tx nero.Tx, q *Queryer) (*player.Player, error) {
	txx, ok := tx.(*sql.Tx)
	if !ok {
		return nil, errors.New("expecting tx to be *sql.Tx")
	}
	return repo.queryOne(ctx, txx, q)
}
QueryOneInTx queries a Player in a transaction
package playerrepo
import (
	"context"
	"database/sql"
	"fmt"
	"log"
	"os"
	"reflect"
	"strings"
	"github.com/Masterminds/squirrel"
	_ "github.com/mattn/go-sqlite3"
	"github.com/pkg/errors"
	"github.com/sf9v/nero"
	"github.com/sf9v/nero/aggregate"
	"github.com/sf9v/nero/comparison"
	"github.com/sf9v/nero/sort"
	"github.com/sf9v/nero/test/integration/player"
)
type SQLiteRepository struct {
	db     *sql.DB
	logger nero.Logger
	debug  bool
}
var _ Repository = (*SQLiteRepository)(nil)
func NewSQLiteRepository(db *sql.DB) *SQLiteRepository {
	return &SQLiteRepository{db: db}
}
func (repo *SQLiteRepository) Debug() *SQLiteRepository {
	l := log.New(os.Stdout, "[nero] ", log.LstdFlags|log.Lmicroseconds|log.Lmsgprefix)
	return &SQLiteRepository{
		db:     repo.db,
		debug:  true,
		logger: l,
	}
}
func (repo *SQLiteRepository) WithLogger(logger nero.Logger) *SQLiteRepository {
	repo.logger = logger
	return repo
}
func (repo *SQLiteRepository) BeginTx(ctx context.Context) (nero.Tx, error) {
	return repo.db.BeginTx(ctx, nil)
}
func (repo *SQLiteRepository) Create(ctx context.Context, c *Creator) (string, error) {
	return repo.create(ctx, repo.db, c)
}
func (repo *SQLiteRepository) CreateInTx(ctx context.Context, tx nero.Tx, c *Creator) (string, error) {
	txx, ok := tx.(*sql.Tx)
	if !ok {
		return "", errors.New("expecting tx to be *sql.Tx")
	}
	return repo.create(ctx, txx, c)
}
func (repo *SQLiteRepository) create(ctx context.Context, runner nero.SQLRunner, c *Creator) (string, error) {
	if err := c.Validate(); err != nil {
		return "", err
	}
	columns := []string{
		"\"email\"",
		"\"name\"",
		"\"age\"",
		"\"race\"",
	}
	values := []interface{}{
		c.email,
		c.name,
		c.age,
		c.race,
	}
	if !isZero(c.updatedAt) {
		columns = append(columns, "updated_at")
		values = append(values, c.updatedAt)
	}
	qb := squirrel.Insert("\"players\"").Columns(columns...).
		Values(values...).RunWith(runner)
	if repo.debug && repo.logger != nil {
		sql, args, err := qb.ToSql()
		repo.logger.Printf("method: Create, stmt: %q, args: %v, error: %v", sql, args, err)
	}
	_, err := qb.ExecContext(ctx)
	if err != nil {
		return "", err
	}
	var id string
	err = repo.db.QueryRowContext(ctx, "select last_insert_rowid()").Scan(&id)
	if err != nil {
		return "", err
	}
	return id, nil
}
func (repo *SQLiteRepository) CreateMany(ctx context.Context, cs ...*Creator) error {
	return repo.createMany(ctx, repo.db, cs...)
}
func (repo *SQLiteRepository) CreateManyInTx(ctx context.Context, tx nero.Tx, cs ...*Creator) error {
	txx, ok := tx.(*sql.Tx)
	if !ok {
		return errors.New("expecting tx to be *sql.Tx")
	}
	return repo.createMany(ctx, txx, cs...)
}
func (repo *SQLiteRepository) createMany(ctx context.Context, runner nero.SQLRunner, cs ...*Creator) error {
	if len(cs) == 0 {
		return nil
	}
	columns := []string{
		"\"email\"",
		"\"name\"",
		"\"age\"",
		"\"race\"",
		"\"updated_at\"",
	}
	qb := squirrel.Insert("\"players\"").Columns(columns...)
	for _, c := range cs {
		if err := c.Validate(); err != nil {
			return err
		}
		qb = qb.Values(
			c.email,
			c.name,
			c.age,
			c.race,
			c.updatedAt,
		)
	}
	if repo.debug && repo.logger != nil {
		sql, args, err := qb.ToSql()
		repo.logger.Printf("method: CreateMany, stmt: %q, args: %v, error: %v", sql, args, err)
	}
	_, err := qb.RunWith(runner).ExecContext(ctx)
	if err != nil {
		return err
	}
	return nil
}
func (repo *SQLiteRepository) Query(ctx context.Context, q *Queryer) ([]*player.Player, error) {
	return repo.query(ctx, repo.db, q)
}
func (repo *SQLiteRepository) QueryInTx(ctx context.Context, tx nero.Tx, q *Queryer) ([]*player.Player, error) {
	txx, ok := tx.(*sql.Tx)
	if !ok {
		return nil, errors.New("expecting tx to be *sql.Tx")
	}
	return repo.query(ctx, txx, q)
}
func (repo *SQLiteRepository) query(ctx context.Context, runner nero.SQLRunner, q *Queryer) ([]*player.Player, error) {
	qb := repo.buildSelect(q)
	if repo.debug && repo.logger != nil {
		sql, args, err := qb.ToSql()
		repo.logger.Printf("method: Query, stmt: %q, args: %v, error: %v", sql, args, err)
	}
	rows, err := qb.RunWith(runner).QueryContext(ctx)
	if err != nil {
		return nil, err
	}
	defer rows.Close()
	players := []*player.Player{}
	for rows.Next() {
		var player player.Player
		err = rows.Scan(
			&player.ID,
			&player.Email,
			&player.Name,
			&player.Age,
			&player.Race,
			&player.UpdatedAt,
			&player.CreatedAt,
		)
		if err != nil {
			return nil, err
		}
		players = append(players, &player)
	}
	return players, nil
}
func (repo *SQLiteRepository) QueryOne(ctx context.Context, q *Queryer) (*player.Player, error) {
	return repo.queryOne(ctx, repo.db, q)
}