mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: move multistorage logic to Go code
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/94 Reviewed By: alexsn Differential Revision: D17926186 fbshipit-source-id: b59dc418703bc4faca5230a7354edea1423b7d35
This commit is contained in:
committed by
Facebook Github Bot
parent
36a3971f3d
commit
0c46ce4e5e
@@ -13,7 +13,6 @@ in the LICENSE file in the root directory of this source tree.
|
||||
|
||||
{{ $builder := print (pascal $.Name) "Update" }}
|
||||
{{ $receiver := receiver $builder }}
|
||||
{{ $multistorage := gt (len $.Storage) 1 }}
|
||||
|
||||
// {{ $builder }} is the builder for updating {{ $.Name }} entities.
|
||||
type {{ $builder }} struct {
|
||||
@@ -41,7 +40,7 @@ func ({{ $receiver }} *{{ $builder }}) Save(ctx context.Context) (int, error) {
|
||||
{{ with extend $ "Receiver" $receiver "Package" $pkg "ZeroValue" 0 -}}
|
||||
{{ template "update/save" . }}
|
||||
{{- end -}}
|
||||
{{- if $multistorage -}}
|
||||
{{- if $.MultiStorage -}}
|
||||
switch {{ $receiver }}.driver.Dialect() {
|
||||
{{- range $_, $storage := $.Storage }}
|
||||
case {{ join $storage.Dialects ", " }}:
|
||||
@@ -108,7 +107,7 @@ func ({{ $receiver }} *{{ $onebuilder }} ) Save(ctx context.Context) (*{{ $.Name
|
||||
{{ with extend $ "Receiver" $receiver "Package" $pkg "ZeroValue" "nil" -}}
|
||||
{{ template "update/save" . }}
|
||||
{{- end -}}
|
||||
{{- if $multistorage -}}
|
||||
{{- if $.MultiStorage -}}
|
||||
switch {{ $receiver }}.driver.Dialect() {
|
||||
{{- range $_, $storage := $.Storage }}
|
||||
case {{ join $storage.Dialects ", " }}:
|
||||
|
||||
Reference in New Issue
Block a user