2021-08-25 15:34:33 +02:00
|
|
|
package feature
|
|
|
|
|
2025-01-27 16:54:51 +01:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strconv"
|
|
|
|
|
|
|
|
"github.com/uptrace/bun/internal"
|
|
|
|
)
|
2021-08-25 15:34:33 +02:00
|
|
|
|
|
|
|
type Feature = internal.Flag
|
|
|
|
|
|
|
|
const (
|
2021-09-08 21:05:26 +02:00
|
|
|
CTE Feature = 1 << iota
|
2022-04-24 12:26:22 +02:00
|
|
|
WithValues
|
2021-09-08 21:05:26 +02:00
|
|
|
Returning
|
2022-04-24 12:26:22 +02:00
|
|
|
InsertReturning
|
|
|
|
Output // mssql
|
2021-08-25 15:34:33 +02:00
|
|
|
DefaultPlaceholder
|
|
|
|
DoubleColonCast
|
|
|
|
ValuesRow
|
|
|
|
UpdateMultiTable
|
|
|
|
InsertTableAlias
|
2022-04-24 12:26:22 +02:00
|
|
|
UpdateTableAlias
|
2021-08-25 15:34:33 +02:00
|
|
|
DeleteTableAlias
|
|
|
|
AutoIncrement
|
2022-04-24 12:26:22 +02:00
|
|
|
Identity
|
2021-08-25 15:34:33 +02:00
|
|
|
TableCascade
|
|
|
|
TableIdentity
|
|
|
|
TableTruncate
|
2021-11-27 15:26:58 +01:00
|
|
|
InsertOnConflict // INSERT ... ON CONFLICT
|
|
|
|
InsertOnDuplicateKey // INSERT ... ON DUPLICATE KEY
|
|
|
|
InsertIgnore // INSERT IGNORE ...
|
2022-04-24 12:26:22 +02:00
|
|
|
TableNotExists
|
|
|
|
OffsetFetch
|
|
|
|
SelectExists
|
|
|
|
UpdateFromTable
|
2022-08-15 12:35:05 +02:00
|
|
|
MSSavepoint
|
|
|
|
GeneratedIdentity
|
2024-11-25 16:42:37 +01:00
|
|
|
CompositeIn // ... WHERE (A,B) IN ((N, NN), (N, NN)...)
|
|
|
|
UpdateOrderLimit // UPDATE ... ORDER BY ... LIMIT ...
|
|
|
|
DeleteOrderLimit // DELETE ... ORDER BY ... LIMIT ...
|
|
|
|
DeleteReturning
|
2025-01-27 16:54:51 +01:00
|
|
|
AlterColumnExists // ADD/DROP COLUMN IF NOT EXISTS/IF EXISTS
|
2021-08-25 15:34:33 +02:00
|
|
|
)
|
2025-01-27 16:54:51 +01:00
|
|
|
|
|
|
|
type NotSupportError struct {
|
|
|
|
Flag Feature
|
|
|
|
}
|
|
|
|
|
|
|
|
func (err *NotSupportError) Error() string {
|
|
|
|
name, ok := flag2str[err.Flag]
|
|
|
|
if !ok {
|
|
|
|
name = strconv.FormatInt(int64(err.Flag), 10)
|
|
|
|
}
|
|
|
|
return fmt.Sprintf("bun: feature %s is not supported by current dialect", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewNotSupportError(flag Feature) *NotSupportError {
|
|
|
|
return &NotSupportError{Flag: flag}
|
|
|
|
}
|
|
|
|
|
|
|
|
var flag2str = map[Feature]string{
|
|
|
|
CTE: "CTE",
|
|
|
|
WithValues: "WithValues",
|
|
|
|
Returning: "Returning",
|
|
|
|
InsertReturning: "InsertReturning",
|
|
|
|
Output: "Output",
|
|
|
|
DefaultPlaceholder: "DefaultPlaceholder",
|
|
|
|
DoubleColonCast: "DoubleColonCast",
|
|
|
|
ValuesRow: "ValuesRow",
|
|
|
|
UpdateMultiTable: "UpdateMultiTable",
|
|
|
|
InsertTableAlias: "InsertTableAlias",
|
|
|
|
UpdateTableAlias: "UpdateTableAlias",
|
|
|
|
DeleteTableAlias: "DeleteTableAlias",
|
|
|
|
AutoIncrement: "AutoIncrement",
|
|
|
|
Identity: "Identity",
|
|
|
|
TableCascade: "TableCascade",
|
|
|
|
TableIdentity: "TableIdentity",
|
|
|
|
TableTruncate: "TableTruncate",
|
|
|
|
InsertOnConflict: "InsertOnConflict",
|
|
|
|
InsertOnDuplicateKey: "InsertOnDuplicateKey",
|
|
|
|
InsertIgnore: "InsertIgnore",
|
|
|
|
TableNotExists: "TableNotExists",
|
|
|
|
OffsetFetch: "OffsetFetch",
|
|
|
|
SelectExists: "SelectExists",
|
|
|
|
UpdateFromTable: "UpdateFromTable",
|
|
|
|
MSSavepoint: "MSSavepoint",
|
|
|
|
GeneratedIdentity: "GeneratedIdentity",
|
|
|
|
CompositeIn: "CompositeIn",
|
|
|
|
UpdateOrderLimit: "UpdateOrderLimit",
|
|
|
|
DeleteOrderLimit: "DeleteOrderLimit",
|
|
|
|
DeleteReturning: "DeleteReturning",
|
|
|
|
AlterColumnExists: "AlterColumnExists",
|
|
|
|
}
|