mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
dialect/sql/schema: add field collation support (#1548)
* specific field collation support * go generate ./...
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -39,6 +39,7 @@ var (
|
||||
{{- with $c.Attr }} Attr: "{{ . }}",{{ end }}
|
||||
{{- with $c.Enums }} Enums: []string{ {{ range $e := . }}"{{ $e }}",{{ end }} },{{ end }}
|
||||
{{- if not (isNil $c.Default) }} Default: {{ $c.Default }},{{ end }}
|
||||
{{- if ne (len $c.Collation) 0 }} Collation: {{ $c.Collation }},{{ end }}
|
||||
{{- with $c.SchemaType }} SchemaType: map[string]string{ {{ range $k, $v := . }}"{{ $k }}": "{{ $v }}",{{ end }}}{{ end }}},
|
||||
{{- end }}
|
||||
}
|
||||
|
||||
@@ -1155,6 +1155,11 @@ func (f Field) Column() *schema.Column {
|
||||
if ant := f.EntSQL(); ant != nil && ant.Default != "" {
|
||||
c.Default = strconv.Quote(ant.Default)
|
||||
}
|
||||
// Override the collation defined in the
|
||||
// schema if it was provided by an annotation.
|
||||
if ant := f.EntSQL(); ant != nil && ant.Collation != "" {
|
||||
c.Collation = strconv.Quote(ant.Collation)
|
||||
}
|
||||
if f.def != nil {
|
||||
c.SchemaType = f.def.SchemaType
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user