package utils

import (
	"database/sql"
	"fmt"

	"github.com/gogf/gf/v2/errors/gerror"
)

func OrmLike(s string) string {
	return fmt.Sprintf("%%%s%%", s)
}

func OrmTable(table string, column string) string {
	return fmt.Sprintf("`%s`.`%s`", table, column)
}

func OrmAs(field, column string) string {
	return fmt.Sprintf("%s AS `%s`", field, column)
}

func HandleNoRowsError(err error) error {
	if gerror.Is(err, sql.ErrNoRows) {
		return nil
	}
	return err
}
